home .. forth .. colorforth mail list archive ..

[ColorForth] was: Re: immediate - i got the subject wrong! Should Read: OO


I wrote:
> Very nice! From what i know, Bernd does fantastic work, though

I just wanted to add that my message was lurking for a while in
my out box, i wrote it before Michael and Martin popped in...
and forgot to get online again to actually got it sent.
So don't feel disappointed that i only answered to Erics suggestions.

I just read the others, so i stilll gotta think a little about it...

In the meantime, i prototyped a variant of the "this is a global":
Storing the actuall object pointer in a global var "this",
and having words to save and restore it, like this:

:m method-of-obj-a ( -- ) ( when this method is called, "this"
  already points to "a" )
  m_b ( assume that this gives the address of a member variable
        b of object a )
  ( and now we want to call a method of m_b, so we gotta switch "this": )
  >this>r ( this word shall save "this" on the r stack and then
            store the top of the data stack in "this" )
  draw ( shall be a parameterless method of object m_b. Because we have
         set "this" before, "draw" can find out itself which object
         it deals with )
  r>this ( and a word that restores the "this" )
 ;

So that's my favourite ATM. Advantage is, no mystical automatic
nesting, but some rather simple
explicite means of handling the nesting. In the above example,
we wouldn't even need to restore because after the call to "draw"
the method ends. So in fact one could write:

:m method-of-obj-a ( -- ) ( when this method is called, "this"
  already points to "a" )
  m_b ( assume that this gives the address of a member variable
        b of object a )
  ( and now we want to call a method of m_b, so we gotta switch "this": )
  this ! 
  draw ( shall be a parameterless method of object m_b. Because we have
         set "this" before, "draw" can find out itself which object
         it deals with )
 ;
I think that this expllicit treatment of "this" is just as well
as creating special words in terms of ease-of-use... 

In any case, i haven't decided yet, and i will check the resources
you gave me! Thanks to all!

Download OCF and play with it! Let me know your opinion!


Dirk Heise
dheiseNOdebitelSPAMnet
is a "designer outlet" an extra orifice of an extreme body modifier?

------------------------

To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx with:
unsubscribe ColorForth
as the first and only line within the message body
Problems   -   List-Admin@xxxxxxxxxxxxxxxxxx
Main ColorForth site   -   http://www.ultratechnology.com