* more on nyacc extension languages
@ 2018-08-31 14:42 Matt Wette
2018-09-01 19:38 ` Matt Wette
0 siblings, 1 reply; 2+ messages in thread
From: Matt Wette @ 2018-08-31 14:42 UTC (permalink / raw)
To: guile-user
Just goofing off a bit:
scheme@(guile-user)> ,use (nyacc lang nx-lib)
scheme@(guile-user)> (install-inline-language-evaluator)
scheme@(guile-user)> #<nx-matlab: a=[1, 2, 3]; >#
scheme@(guile-user)> (define b (vector-ref a 2))
scheme@(guile-user)> #<nx-javascript: var c = b + 2; >#
scheme@(guile-user)> c
$1 = 5
scheme@(guile-user)> (define d 1)
scheme@(guile-user)> (set! d #<nx-matlab: d + 1; >#)
scheme@(guile-user)> (set! d #<nx-javascript: d + 1; >#)
scheme@(guile-user)> d
$2 = 3
This is using read-hash-extend with a handler that looks
up the language then compiles the code to tree-il, then
decompiles to scheme and returns the scheme form.
Matt
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: more on nyacc extension languages
2018-08-31 14:42 more on nyacc extension languages Matt Wette
@ 2018-09-01 19:38 ` Matt Wette
0 siblings, 0 replies; 2+ messages in thread
From: Matt Wette @ 2018-09-01 19:38 UTC (permalink / raw)
To: guile-user
Working on nx-tcl now. I am working to extract common utilities for
generating language extensions based on the three I have now:
nx-tcl, nx-octave (was nx-matlab) and nx-javascript.
scheme@(guile-user)> ,L nx-tcl
Happy hacking with nx-tcl! To switch back, type `,L scheme'.
nx-tcl@(guile-user)> proc foo {a {b 1} args} { set c 1; return [expr $a+$b+$c] }
nx-tcl@(guile-user)> ,L scheme
Happy hacking with Scheme! To switch back, type `,L nx-tcl'.
scheme@(guile-user)> (foo "5" "6")
$1 = 12
scheme@(guile-user)> (foo 5 6)
$2 = 12
scheme@(guile-user)> (foo 5)
$3 = 7
Making nx-tcl compatible with other languages is still something I'm thinking
about. In Tcl all values are strings, but some items are intended to be non-
strings. So the implementation needs to deal with converting to strings. I
am trying to be lazy about that and see where it turns out.
Matt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-01 19:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-31 14:42 more on nyacc extension languages Matt Wette
2018-09-01 19:38 ` Matt Wette
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).