| Re: More fun with Miser's CASE |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.forth · Group Profile
Author: EdEd Date: Jul 4, 2008 23:30
> On 4 Jul, 03:39, "Ed" invalid.com> wrote:
>
> [...]
>
>>
>> Schemes involving a count are unlikely to work. Miser uses (and
>> encourages) existing conditionals to effect the case construct.
>> That's its simplicity and flexibility. You can use *any* conditional
>> as long as there's an orig left to resolve.
>>
>
> Yes solution 1 is flawed with the redefinition of ELSE. But have
> you looked at solution 2 which also uses a count. I posted a
> working solution 2 the morning after the post you responded to.
> The orig counts are saved in a safe place and don't interfere
> with the orig list at all. What is non-portable with solution 2?
> ...
It's limited to conditionals which bump the count. Should one
encounter Miser code like:
CASE
( any test ) IF ( DROP) ... ELSE
ENDCASE
it will fail.
In the above example I used IF but any conditional or sequence
that left an 'orig' may be used in Miser. All these would fail in
solution 2 because they don't bump the count.
--
The classic way to resolve an arbitrary number of conditionals
has been to put a marker (typically 0) on the control stack and
then test for it. There's no portable equivalent so I've suggested:
CS-MARK ( C:
-- marker )
CS-MARK? ( C: marker -- ) ( -- true )
( C: orig|dest -- orig|dest ) ( -- false )
With this, things like Baden's COND WHENS (used in Miser)
can then readily be defined.
|