[REBOL] Re: [REBOL.org] Recent changes
From: lmecir:mbox:vol:cz at: 30-Nov-2005 7:09
Tim Johnson napsal(a):
>* Ladislav Mecir <lmecir-mbox.vol.cz> [051128 19:57]:
>>>[REBOL] [REBOL.org] Recent changes
>>>This is an automatic email from REBOL.org, the REBOL Script Library to notify you
of recent changes to the Library.
>>>--change: new script
>>>--title: CASE multiple conditional function
>>>--author: Christopher M. Dicely
>>>--purpose: Provide a generalized multiple conditional function for situations that
would otherwise call for
>>>deeply nested EITHER blocks. CASE is more general than SWITCH because the conditions
can be any
>>>DO-able block rather than being based on a single value. This [...]
>>CASE is already present in the official REBOL, BTW, and my
>>implementation, (known as PIF), which was around for quite some time is
>>pretty compatible with it not using blocks as conditions as in the above
>>implementation. (I am still using it renamed to CASE for backwards
>>compatibility in older interpreter versions.
> Hmm! I have 18.104.22.168.2 (for linux) and there is no native or mezzanine
> 'case that I can find.
> I've been using Marco's 'case for some time now.
My version is around since 2000 I think, and was published on this ML.
Here it is renamed to CASE:
unless value? 'case [
case: func [
args [block!] /local res
either unset? first res: do/next args [
if not empty? args [
; invalid guard
throw make error! [script no-arg case condition]
either first res [
either block? first res: do/next second res [
do first res
; not a block
throw make error! [
script expect-arg case block [block!]
case second do/next second res