Wow, that's more than I dared to ask! :-)
2014-12-17 2:35 GMT+01:00 tgkuo tgk...@gmail.com:
Quotations are just squeneces -- That's the key point that I not got yet...
So, if I wante to put quotation inside a sequence, I would use:
IN: scratchpad { 1 2 } [ 3 ] 1quotation append .
{ 1 2 [ 3
While quotations are sequences, in order for the stack-checker to
infer the proper effect for combinators, you can't call append on two
quotations, you must call compose instead. Likewise with
suffix/prefix, you should call curry.
For what I undertood and learned, quotations and sequences
Hi, I am trying to define some syntax words that should have effect on
a global (or dynamic) variable. What I am trying to achieve is
something similar to how the LIBRARY: word affects later occurrences
of FUNCTION:
The problem is, it does not seem to work. The simplest example I can
make is up
You can call set-global and get-global instead of set and get. The words
are executing in the dynamic scope of the parser and the values getting
lost when parsing returns.
Doug
On Tue, Dec 16, 2014 at 8:55 AM, Andrea Ferretti ferrettiand...@gmail.com
wrote:
Hi, I am trying to define some
Also, I'm not sure why you need a parsing word for that, you can just:
IN: foo
SYMBOL: foo
IN: bar
foo [ hello ] initialize
... or
hello foo set-global
the first will initialize if not ``f``, the second will always set.
On Tue, Dec 16, 2014 at 8:55 AM, Andrea Ferretti
Oh, thank you, it was more trivial than I had realized!
2014-12-16 17:57 GMT+01:00 Doug Coleman doug.cole...@gmail.com:
You can call set-global and get-global instead of set and get. The words are
executing in the dynamic scope of the parser and the values getting lost
when parsing returns.
If you want your code to work the way you intend, using a local namespace,
then how about this:
SYNTAX: FOO: scan-token '[ _ foo set ] append! ;
That will set in the namespace that you want.
On Tue, Dec 16, 2014 at 8:59 AM, John Benediktsson mrj...@gmail.com wrote:
Also, I'm not sure why you
Yes, I know, this was just a minimal example
2014-12-16 17:59 GMT+01:00 John Benediktsson mrj...@gmail.com:
Also, I'm not sure why you need a parsing word for that, you can just:
IN: foo
SYMBOL: foo
IN: bar
foo [ hello ] initialize
... or
hello foo set-global
the first will
Hi,
About the parsing using append! as below
SYNTAX: FOO: scan-token '[ _ foo set ] append! ;
seemed to have the same effect as this one, which is more understandable
SYNTAX: FOO1: scan-token '[ _ foo set ] suffix! \ call suffix! ;
As I knew, append! has the stack effect of ( seq seq -- seq
You can see what code is generated for both approaches:
SYNTAX: FOO: scan-token '[ _ foo set ] append! ;
IN: scratchpad [ FOO: hello ] .
[ hello foo set ]
SYNTAX: FOO1: scan-token '[ _ foo set ] suffix! \ call suffix! ;
IN: scratchpad [ FOO1: hello ] .
[ [ hello foo set ] call
To understand what's going on with quotations you have to understand the
difference between run-time, compile-time, how the stack checker works, and
a few other details.
Run-time is after your code has been compiled and you have started to
execute it--it's your program.
Compile-time is when the
Quotations are just squeneces -- That's the key point that I not got yet...
So, if I wante to put quotation inside a sequence, I would use:
IN: scratchpad { 1 2 } [ 3 ] 1quotation append .
{ 1 2 [ 3 ] }
test passed.
Thanks.
kuo
? 2014/12/17 ??8:55, John Benediktsson ??:
You can see what
12 matches
Mail list logo