Hi Matt,

You're right that the compiler doesn't do any analysis on the result
of the 'get' because the namestack is too dynamic for the compiler to
able to infer anything. However, generally variable lookup on the
innermost namespace is pretty efficient, and Daniel Ehrenberg has
proposed an optimization which should improve it further, so unless
your code has performance issues I wouldn't worry about this too much.
If the dynamic variable lookup becomes a bottleneck, you could try
using locals instead, but you might end up with longer word
definitions in that case, since you wouldn't have as much freedom to
factor out bits and pieces as you do with dynamic variables.

Slava

On Sun, May 24, 2009 at 6:02 PM, Matthew Willis <matthew.wil...@mac.com> wrote:
> I find myself using the following pattern quite a bit when most of the
> words in a vocabulary seem to operate on a single important object:
>
> ! in a shogi vocab where most words operate on a shogi board
> : bg ( -- board-gadget ) board-gadget get ;
>
> : with-board-gadget ( gadget quot -- ) board-gadget swap with-
> variable ; inline
>
> The use of the namespace stack simplifies the code, but I'm wondering
> if it keeps the compiler from optimizing past the namespace lookup.
> Is there a way to do this that is more kind to the optimizing compiler?
>
> Matt
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to