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 ] }
>
> test passed.
>
> Thanks.
>
> kuo
>
>
> 於 2014/12/17 上午8:55, John Benediktsson 提到:
>
> 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 ]
>
> The first is simpler, although the results should be the same as your
> version.
>
> And quotations are just sequences, see this:
>
>     IN: scratchpad [ 1 2 3 ] first .
>     1
>
>     IN: scratchpad [ 1 2 ] { 3 } append .
>     [ 1 2 3 ]
>
>     IN: scratchpad { 1 2 } [ 3 ] append .
>     { 1 2 3 }
>
> Knowing that, you could also do this, which looks a little weird but works:
>
> SYNTAX: FOO2: scan-token suffix! { foo set } append! ;
>
>     IN: scratchpad [ FOO2: hello ] .
>     [ "hello" foo set ]
>
>
>
> On Tue, Dec 16, 2014 at 4:17 PM, tgkuo <tgk...@gmail.com> wrote:
>>
>> 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 ) but the
>> quotation is not a kind of seq, how this works?
>>
>>
>> BR
>>
>> kuo
>>
>>
>>
>>
>>
>> 於 2014/12/17 上午1:00, John Benediktsson 提到:
>>
>> 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 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
>>> <ferrettiand...@gmail.com> wrote:
>>>>
>>>> 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 the following.
>>>>
>>>> In package foo
>>>>
>>>>     USING: kernel lexer namespaces ;
>>>>     IN: foo
>>>>
>>>>     SYMBOL: foo
>>>>
>>>>     SYNTAX: FOO: scan-token foo set ;
>>>>
>>>> Then in package bar
>>>>
>>>>     USING: namespaces foo prettyprint ;
>>>>     IN: bar
>>>>
>>>>     FOO: hello
>>>>
>>>>     foo get .
>>>>
>>>>
>>>> This executes the top level form `foo get .` but prints f instead of
>>>> "hello". The same happens if I use run-file directly. If, instead, I
>>>> make the same declaration
>>>>
>>>>     FOO: hello
>>>>
>>>> in the listener, I can check that foo is modified.
>>>>
>>>> Is there a way to make this work? I could also avoi the variable, but
>>>> while parsing I do not have access to the stack, and so I do not know
>>>> how to pass any information among parsing words.
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>>> with Interactivity, Sharing, Native Excel Exports, App Integration &
>>>> more
>>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>>
>>>> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
>>>> _______________________________________________
>>>> Factor-talk mailing list
>>>> Factor-talk@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
>>
>>
>>
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
>
>
>
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to