[Tinymux] Case(), Windows

Stephen Dennis sdennis at tinymux.org
Sat Sep 11 00:06:17 EDT 2004


From: Robby Griffin
Sent: Thursday, September 09, 2004 6:27 PM
Subject: Re: [Tinymux] Case(), Windows

> On Sep 9, 2004, at 20:40, Stephen Brewer wrote:
> 
> I've noticed an odd behaviour with the case() function. The following
> > yield the same result ("Success!") using switch(), but with case()
> > the first yields the string and the second returns nothing:
> >
> > think case(lt(0,1),1,Success!)
> > think case(1,lt(0,1),Success!)
> >
> > Is this a bug or does case not evaluate positions past the first
> > for efficiency purposes?
> 
> Well, I don't know what the purpose was, but yeah, that's the
> historical behavior of case():
> 
>    - the first argument is always evaluated
>    - patterns are not evaluated, but are matched literally
>    - results (including the default) are evaluated only if
>      they are actually being returned.
> 
> Somewhere in the TinyMUSH 3.0 betas four years ago, somebody
> decided the documentation was right and actually made case()
> work like switch(). So current versions of mux & mush are
> probably incompatible. YMMV.

There was another historical behavior of case(): One and only one
character was significant in the comparison -- the first character.

At the time, TM3.0 chose to make case() behave like switch() minus
regular-expression matching.  For backwards compatibility, MUX2 chose
to turn the character comparision into a string comparison.

If existing softcode used characters, it would behave as before. If
existing softcode contained strings, the hardcode change would either
improve the behavior, or the odds were that the code was broken in
any case.  The whole point of case() appeared to be that it was an
attempt to be a weaker form of switch().

Since both PennMUSH and TinyMUSH 3.x evaluate all the patterns, I am
changing case() in MUX 2.4 to behave the same way.  And, it will do the
#@ substitution, too.


Brazil



More information about the Tinymux mailing list