[retroforth] Re: RetroForth 8.0

  • From: Charles Childers <charles.childers@xxxxxxxxx>
  • To: retroforth@xxxxxxxxxxxxx
  • Date: Sat, 15 Jan 2005 18:44:59 -0500

> I dont like this at the moment. Could you explain better what happens after 
> "does (foo)" ? Is it possible to say:
> 
> : (foo) 10 + ;
> : foo create literal, does (foo) s" I created a (foo) doing thing!" cr ;

Yes, though you probably want to use ." or a type after the s". In
this case, you'd get:

10 foo a
I created a (foo) doing thing!
3 foo b
I created a (foo) doing thing!
a
20
b
13

> If so: how do you implement it? Is not it more complicated now, since the 
> return address on stack does not play a role?
 
: does 32 parse find m: literal F: compile M: ;; ;

Overall it's less complicated since it doesn't have to modify already
compiled code. does> had to change the "call dovar" that create
compiles to "call code_after_does" and patch a bit of code after does>
to get the address of the data on the stack.

> "Factoring" is fine. Wasting dictionary with trash is another thing. "does>" 
> is the default OO-part of FORTH and making a new "class" of words would need 
> to implement two words for implementation now.

loc: 
: (foo) 10 + . ;
: foo create literal, does (foo) ;
' foo
; loc alias foo

Now only "foo" will be visible in the dictionary. The loc: ;loc
pairings make local factoring possible, so you can factor more heavily
without actually polluting the overall dictionary.

> Why should I have to factor out for the following things:
> 
> : char-out create 1, does> c@ emit ;
> 32 char-out space
> 10 char-out cr
>  9 char-out tab

You could do this:

: char-out create literal, does emit ;
32 char-out space
10 char-out cr
9 char-out tab

--
Charles

Other related posts: