Thanks, Slava!

Putting the variable into the gadget as a slot seems to be working fine.
Since the word where I use the getter is declared as
: pyramids-scene ( gadget -- ) ...
it was no need for find-parent, I just did "dup pyr-rot>> ..."

I must do some more work on it before I have the "animation" going.

/Jon

> Hi Jon,
>
> Factor's namespaces vocabulary implements dynamically-scoped
> variables. This means if you set a variable in the scope of the code
> calling open-window, your draw-gadget* and other callbacks won't be
> able to see that variable since that code runs in a different scope
> (and indeed, in a different thread).
>
> There are several ways to share state between gadgets:
>
> - Put it all in slots of a parent gadgets (that will subclass track,
> pack, frame, or similar). Have the children use find-parent to find
> the parent. Eg, [ foo-gadget? ] find-parent tidbit>>
> - Use local variables and lexical scope to bake your values into
> closures, storing the closure in a button's callback quotation or
> something. Look at "locals" about
> - Use global variables. I don't recommend this for obvious reasons.
>
> Slava
>
> On Thu, Apr 9, 2009 at 4:26 AM, Jon Kleiser <jon.klei...@usit.uio.no>
> wrote:
>> Hi,
>>
>> In my little OpenGL "pyramids" project I want to make use of a variable
>> holding an angle value that represents the current degree of folding.
>> I've
>> tried to use the "vars" vocabulary, but when I do things like "VAR:
>> pyr-rot 32.0 >pyr-rot" in the upper part of my program, the word
>> pyr-rot>
>> don't seem to give me anything (but f) where I need the value, in my
>> pyramids-scene word. There must be something about scope here that I
>> don't
>> understand. Can somebody give me a clue?
>>
>> My little project, which is to a high degree based on Joe Groff's
>> "spheres" code, can be found here:
>> <https://vortex.uio.no/brukere/jkleiser/factor/>
>>
>> /Jon



------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to