![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

I finally started looking at SWOOP. I'm confused over context
switching of the search order. From the user manual, I started
off with a simple class definition:
class mypt
variable x
variable y
: show ( -- ) x @ . y @ . ;
: dot ( -- ) ." Point at " show ;
end-class
Next, I defined a static instance:
mypt builds bar
5 bar x !
8 bar y !
I noticed that in storing the variables above, 'bar' adds the
class wordlist and, say, 'x' removes it. Likewise, a colon
member also removes the class wordlist. That makes sense.
I also experimented with the dynamic manipulation words 'using'
and '->' applied to a static instance.
'bar using mypt dot' or '3 bar using mypt x !' work fine.
However, 'bar -> dot' and '3 bar -> x !' worked but changed the
context. '->' and 'calling' fail to restore the context. One
needs to write, for example, 'bar -> dot previous'. Apparently,
since 'calling' or '->' are usually used stored addresses that
haven't changed the context in the first place, it was felt there
was no need to restore the context. Is that right?
Next, I tried out a dynamic instance:
mypt new value foo
8 foo using mypt x !
99 foo calling y !
I noticed that 'using mypt' changed context but 'x' restored it.
Also, 'calling' or '->' had no effect on context. So no
surprises.
One last example for this post. The examples from the manual for
using [objects ... objects].
: try ( addr -- )
[objects mypt names sam objects]
sam dot ;
: test ( -- )
[objects mypt makes joe objects]
12 joe using mypt x !
15 joe using mypt y !
joe try ;
Although defining 'try' was uneventful, defining 'test' changed
the context. Is this a bug? Generally, when context is changed
during a definition, it's restored at the end (such as with CODE
name ... end-code).
Executing either of these two words appears to neither change nor
restore context.
'foo try' has no context effect and although 'bar try' does, it's
from 'bar' changing context. Until I get this down, I'll be
using OFAD often ( : OFAD only forth also definitions ) :-)
Bill
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe sftalk" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/sftalk -- check them out!
Search the archives! Visit http://www.forth.com/search for details.
Received on Sun Feb 16 2003 - 06:51:11 PST
This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:28 PST