Hi 4tH-ers!
In FOOS, methods are defined like this:
:method meth ." Method" ;method
:virtual virt ." Virtual" ;method
:default def ." Default" ;method
:new ." New" ;method
:delete ." Delete" ;method
What it actually does is place a string on the string stack signalling which kind of method is being defined.
This string is picked up by ;method which selects through a kind of switch statement which code is to be executed. And that code was horrible.
All kinds of flags were being evaluated - and I wondered how I ever got it to work at all. Frankly, it was unmaintainable.
Bu during my ALLOT development, I found a perfectly acceptable structure. It works like this:
:macro word-top? @dup >>> top-word @while (..) ;
:macro word-1? word-top? @drop @dup >>> word-1 @while (..) ;
:macro word-2? word-1? @drop @dup >>> word-2 @while (..) ;
:macro caller word-2? @drop ;
In short, it climbs quickly to the top-word and then drops down. The DUP copies the string from the string stack, so it can be evaluated. The DROP drops the flag that WHILE leaves. Of course, per branch the stack diagram may differ. But that's the idea. Nice and clean.
However, this is a thing that can easily be maintained. I tested all FOOS programs in batch, no problems. I have no doubt, I will use this again. Code in SVN.
Hans Bezemer