programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: SWOOP and Context

From: Rick VanNorman <rvn_at_forth.com>
Date: Sun, 16 Feb 2003 10:12:17 -0800

Bill,

The issue is using a defined object and one of the "USING" or
"->" words. Executing the name of a defined object automatically
changes the search order so that the methods that belong to the
class that the object is an instance of can be found. The words
USING and -> are for arbitrarily defined memory content, not
for defined objects. These words want a pure memory address
to act on. If you really feel the need to use them on an object,
dereference the object to its address in memory by using
the ADDR method. For example:

FOO BUILDS BAR
BAR ADDR using otherclass non-foo-method

The structure of the examples suffers similar problems.

The phrase [OBJECTS FOO MAKES BAR OBJECTS] creates a new but
temporary object named BAR of class FOO. One would not apply
the USING or -> keywords to such an object.

The phrase [OBJECTS FOO NAMES BAR OBJECTS] temporarily associates
the class FOO to an object named BAR whose existence is established
in memory external to the definition in question. But since there
is an association of a class to the object, one would still not
use the USING or -> actions.

rick

On Sunday, February 16, 2003, at 06:51 AM, Bill McCarthy wrote:

>
> 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 ) :-)

----------------------------------------------------------------------
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.

>From mail_at_forthcad.com Thu Apr 1 10:01:27 1999
To: sftalk_at_forth.com
Message-Id: <m0000216_at_gerd.forthinc.com>
Date: Thu, 1 Apr 1999 10:01:27 +0100
From: ForthCAD <mail_at_forthcad.com>
Subject: verbose silent manual error

In user manual, page 45, I read

"...The level of monitoring is controlled by a bit-mapped variable named MONITOR. ..."

and later

"For example
        VERBOSE %101 WATCHING ! ( see text and stack)
        < troublesome code >
        SILENT
"

I have checked then variable MONITOR nor WATCHING exists.

It seems the real variable name is in fact: MONITORS.

Charles Mélice

.
Received on Sun Feb 16 2003 - 10:10:49 PST

This archive was generated by hypermail 2.2.0 : Wed Jan 07 2009 - 03:04:04 PST