Hello Matthias,

Matthias Trute <mtr...@web.de> writes:
> What about the following (real) session log
>
>  > forward: foo
>  ok
>  > : bar foo ;
>  ok
>  > bar
>  found only forward declaration.
>  > : foo ." Hey" ;
>  ok
>  > bar
>  Hey ok
>  >

IMO this is indeed the correct approach i.e., there's no need for the
previously suggested resolve-to word.

> ? It declares a forward symbol named foo which is used
> in bar. There is a runtime check, whether foo has been
> redefined or not. If it hasn't, the first error message
> is printed (when calling bar). If foo got re-defined (or
> defined, depends on the view point) it will be called.
> Furthermore the forwardly declared call to foo in bar
> will be replaced with the newly defined foo so the runtime
> check will occur only once. And it will erase the flash
> only once for every occurance of foo (there is a !i operation)
>
>
> Another example?
>
>  > forward: foo
>
>    ok
>
>  > : bar foo ;
>
>    ok
>
>  > : baz foo ;
>
>    ok
>
>  > bar
>
>   found only forward declaration.
>
>  > : foo ." I'm number 1" ;
>
>    ok
>
>  > bar
>
>   I'm number 1 ok
>
>  > : foo ." I'm number 2" ;
>
>    ok
>
>  > baz
>
>   I'm number 2 ok
>
>  > bar
>
>   I'm number 1 ok
>
>  > baz
>
>   I'm number 2 ok
>
>  >
>
> The definition of forward: is small (5 lines of forth code), but digs
> very deep into internals and is by no means portable to other systems.
> Most of the forward:code can be used to implement late binding, with
> potentially heavy runtime costs (unless a special wordlist is used).

Mitch Bradely forward implementation (in openfirmware) is no trivial
either. Thoughts:

+ Let this "found only forward declaration" throw an exception instead
that can be dealt with programmatically, for example, to say "foo is a
missing feature, please send a $2 donation to the developer to complete"
:-)

+ There should be no runtime penalty after forward "name" is defined.

I am ready to help in this development/testing. 

Thanks, Enoch.


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to