Jose A. Ortega Ruiz wrote:

> I'm implementing sending code in emacs factor buffers to the listener
> for evaluation.

Cool!

> When i'm sending just part of the buffer (say, a word 
> definition), i'm assuming that i need to tell the listener where to
> evaluate the definition using IN:, and the list of USING: vocabs (as
> pointed out by Slava in a previous mail). So my strategy is:
>
>   1) Recover from the listener its current vocab:
>       ( initial-vocab ) in get .
>      storing it for later.
>   2) Provide the USING: form in the buffer
>       ( initial-vocab ) USING: a b c ..;
>   3) Change to the buffer vocab with:
>       ( initial-vocab ) IN: buffer-vocab
>   4) Evaluate the definition
>       ( buffer-vocab ) : blah ( -- ) foo bar ;
>   5) Return to the vocab recovered in 1):
>       ( buffer-vocab ) IN: initial-vocab
>       ( initial-vocab )
>

> Does that make any sense?

Yup. And the nice thing is that it looks like a solid strategy in that it's 
what somebody would do manually, and in that respect, the above should always 
work.

> Assuming it does, I was wondering if there's a 
> better way of doing the above. In particular:

>  - I've tried to find some form of push/pop vocab for 1) and 5) without
>    success.

Well, 'in' doesn't represent a list like 'use' does so pushing and poping from 
it doesn't make sense. However, you could have your own stack for 
saving/restoring 'in'. Something like:

    : in-stack V{ } ;

    : save-in in get in-stack push ;

    : restore-in in-stack pop in set ;

But it sounds like you don't need something even that elaborate.

>  - I've noticed that USING: keeps adding new elements to the 'use'
>    variable, which sounds like a bit of duplication if the user keeps
>    evaluating redefinitions with the same USING:... should that be a
>    concern?

I've notice this too, have wondered the same thing, and it's a good question 
for Slava. :-)

Ed

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to