Fwd: [Tutor] using exceptions to implement case/switch?

Bill Campbell bill at celestial.net
Fri Oct 15 23:32:05 CEST 2004


On Fri, Oct 15, 2004, Max Noel wrote:
>(sigh... Forgot to click "reply to all". It'd be more practical if that 
>list set a reply-to header IMO...)

Funny, my archaic mailer works just fine replying to lists by
pressing ``L''.

>Begin forwarded message:
>
>>From: Max Noel <maxnoel_fr at yahoo.fr>
>>Date: October 15, 2004 21:42:37 BST
>>To: Bill Mill <bill.mill at gmail.com>
>>Subject: Re: [Tutor] using exceptions to implement case/switch?
>>
>>
>>On Oct 15, 2004, at 21:36, Bill Mill wrote:
>>
>>>Bill,
>>>
>>>I think you've misunderstood the example; pardon me if I've
>>>misunderstood you in turn, but Kent's dispatcher will run the
>>>functions in the current namespace. No new processes or namespaces
>>>will be created, making your lambda method redundant.
>>>
>>>Peace
>>>Bill Mill
>>>bill.mill at gmail.com
>>
>>	I think he meant scope, not namespace. However IIRC lambda functions 
>>have their own scope, like normal functions (not 100% sure of that, I 
>>never use lambdas), thus the method is redundant either way.

My main goal had little to do with lamdas or function calls, but the desire
to implement a construct that closely resembles C switch or other
language's case statements.  How the exceptions are raised isn't important.
The important thing is using multiple ``except'' sections after a ``try''
instead of using conditional tests.

Bill
--
INTERNET:   bill at Celestial.COM  Bill Campbell; Celestial Software LLC
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

With Congress, every time they make a joke it's a law; and every time
they make a law it's a joke.
		-- Will Rogers


More information about the Tutor mailing list