|
|
Up |
|
|
  |
Author: Brad EckertBrad Eckert Date: Jan 11, 2008 10:19
I notice that colorForth doesn't hide the name of the definition
currently being defined. That means you can't do something like:
: foo ." Hello" ;
: foo foo ." World" ;
I'm not sure, but I think if you use the name of the word being
compiled, it compiles as a jump to the beginning of the word, not a
call to itself (like RECURSE).
It seems that Chuck may have thought the ability to restart a word
from the middle of any control structure was more valuable than the
ability to chain functions together by retaining visibility of the old
word until ;. I assume that the XT of an old version of the word can
be placed on the stack before the definition, then compiled into the
definition with COMPILE so as to have the same chaining functionality.
Does anyone have some example code showing the benefits of the
colorForth way, or thoughts on the subject?
Brad
|
| |
|
| | 26 Comments |
|
  |
Author: Matthias TruteMatthias Trute Date: Jan 11, 2008 11:10
Brad Eckert schrieb:
> I notice that colorForth doesn't hide the name of the definition
> currently being defined. That means you can't do something like:
...
> Does anyone have some example code showing the benefits of the
> colorForth way, or thoughts on the subject?
In my amforth I've implemented the : in a similiar way as colorforth
(without knowing it however). It was simpler to finish the dictionary
entry in : rather that to delay it until ; . Using
a flag like smudge seemed to bee a an outdated way to handle that
problem as well (and could do harm to my dictionary in the flash too)
The question that came to me, was, why does one need a redefinition
of an existing word? Since I re-started my forth life after a long break
I have the benefit of not having any old code. And I can deploy
recent additions to forth like DEFER/IS as well. And doing it that way
is more elegant IMHO. Maybe that this approach breaks old code, but
I did not found any useful code in the net so I does not worry me much.
Just my 2 cents
Matthias
|
| |
|
| | no comments |
|
  |
Author: Brad EckertBrad Eckert Date: Jan 11, 2008 11:42
On Jan 11, 12:10 pm, Matthias Trute googlemail.com>
wrote:
> In my amforth I've implemented the : in a similiar way as colorforth
> (without knowing it however). It was simpler to finish the dictionary
> entry in : rather that to delay it until ; . Using
> a flag like smudge seemed to bee a an outdated way to handle that
> problem as well (and could do harm to my dictionary in the flash too)
>
Me too, in F-. I think I can redefine : to not hide itself in my PC's
Forth, for testing. Ideally it would complain about the use of a words
reference to itself. So in my own personal standard, : is more
restrictive than ANS specifies.
|
| |
| no comments |
|
  |
Author: foxchipfoxchip Date: Jan 11, 2008 12:14
On Jan 11, 10:19 am, Brad Eckert tinyboot.com> wrote:
> I notice that colorForth doesn't hide the name of the definition
> currently being defined. That means you can't do something like:
>
> : foo ." Hello" ;
> : foo foo ." World" ;
Correct. Chuck said that the "automatic recursion" came at the
cost of having to say
: foo ." Hello" ;
: fo1 foo ." World" ;
He said there was alot a debate about what name to use for SMUDGE
in the ANS work for years after he had abandoned it.
> I'm not sure, but I think if you use the name of the word being
> compiled, it compiles as a jump to the beginning of the word, not a
> call to itself (like RECURSE).
No. Green use of a word defined in red (equivalent to a colon def)
compiles a subroutine call. Yellow use makes a subroutine call.
Macros may inline code when compiled as they are like immediate words.
|
| Show full article (2.73Kb) |
| no comments |
|
  |
Author: Mark W. HumphriesMark W. Humphries Date: Jan 11, 2008 19:39
On Jan 12, 2:19 am, Brad Eckert tinyboot.com> wrote:
> I notice that colorForth doesn't hide the name of the definition
> currently being defined. That means you can't do something like:
>
> : foo ." Hello" ;
> : foo foo ." World" ;
>
> I'm not sure, but I think if you use the name of the word being
> compiled, it compiles as a jump to the beginning of the word, not a
> call to itself (like RECURSE).
>
> It seems that Chuck may have thought the ability to restart a word
> from the middle of any control structure was more valuable than the
> ability to chain functions together by retaining visibility of the old
> word until ;. I assume that the XT of an old version of the word can
> be placed on the stack before the definition, then compiled into the
> definition with COMPILE so as to have the same chaining functionality.
>
> Does anyone have some example code showing the benefits of the
> colorForth way, or thoughts on the subject? ...
|
| Show full article (1.60Kb) |
| no comments |
|
  |
Author: helmwohelmwo Date: Jan 12, 2008 03:47
On Jan 11, 6:19 pm, Brad Eckert tinyboot.com> wrote:
> I notice that colorForth doesn't hide the name of the definition
> currently being defined. That means you can't do something like:
>
> : foo ." Hello" ;
> : foo foo ." World" ;
>
> I'm not sure, but I think if you use the name of the word being
> compiled, it compiles as a jump to the beginning of the word, not a
> call to itself (like RECURSE).
Does not RECURSE also compiles a call? I think so.
|
| Show full article (3.15Kb) |
| no comments |
|
  |
Author: helmwohelmwo Date: Jan 12, 2008 04:11
> On Jan 11, 6:19 pm, Brad Eckert tinyboot.com> wrote:
>
>> I notice that colorForth doesn't hide the name of the definition
>> currently being defined. That means you can't do something like:
>
>> : foo ." Hello" ;
>> : foo foo ." World" ;
>
>> I'm not sure, but I think if you use the name of the word being
>> compiled, it compiles as a jump to the beginning of the word, not a
>> call to itself (like RECURSE).
>
> Does not RECURSE also compiles a call? I think so.
>
>> It seems that Chuck may have thought the ability to restart a word
>> from the middle of any control structure was more valuable than the
>> ability to chain functions together by retaining visibility of the old
>> word until ;. I assume that the XT of an old version of the word can
>> be placed on the stack before the definition, then compiled into the ...
|
| Show full article (3.43Kb) |
| no comments |
|
  |
Author: Coos HaakCoos Haak Date: Jan 12, 2008 06:59
Op Sat, 12 Jan 2008 03:47:07 -0800 (PST) schreef helmwo@ gmail.com:
So a
> word like SMUDGE (which you obviously and hiddenly need for ANS and a
> correctly working RECURSE) or even RECURSE would have a strange task.
Why do you think that ISO Forth has a word called SMUDGE ?
That word is nowhere defined. Perhaps you are thinking of FIGFORTH or some
standards before ISO. There are other ways to hide and unhide the name of
the current definition.
|
| |
| no comments |
|
  |
Author: helmwohelmwo Date: Jan 12, 2008 09:22
On Jan 12, 2:59 pm, Coos Haak wrote:
> Op Sat, 12 Jan 2008 03:47:07 -0800 (PST) schreef hel...@ gmail.com:
>
> So a
>
>> word like SMUDGE (which you obviously and hiddenly need for ANS and a
>> correctly working RECURSE) or even RECURSE would have a strange task.
>
> Why do you think that ISO Forth has a word called SMUDGE ?
> That word is nowhere defined. Perhaps you are thinking of FIGFORTH or some
> standards before ISO. There are other ways to hide and unhide the name of
> the current definition.
You need some equivalent of it. The need to "hide a word" says it.
Sorry this is completely something I would call "crap". The case that
ANS leaves it up to the systems implementor how to call this word does
not mean it's function is not needed anymore ;)
Regards,
-Helmar
|
| |
| no comments |
|
  |
|
|
  |
Author: Anton ErtlAnton Ertl Date: Jan 12, 2008 09:44
>The need to "hide a word" says it.
There is no need to hide a word. In Gforth a word is not visible
until it is REVEALed. A word is REVEALed by adding to the CURRENT
wordlist; a Forth system has to do this anyway, so there is no
additional overhead because of that.
In Gforth there is a bit of additional overhead, because it adds the
word to the wordlist that was CURRENT at the start of the definition,
but that is not required by the standard.
The advantage of the standard way is that colon definitions that have
not been completed because of an error are not visible; in contrast,
if they become visible right from the start, the user could
accidentially call it, with unpleasant results (OTOH, not worse that
other things that Forth users are not protected from, either). The
ability to call old words with the same name is a side benefit.
|
| Show full article (1.16Kb) |
| no comments |
|
RELATED THREADS |
  |
|
|
|
|
|