That's true Bob, maybe we should call it clazz (class is reserved)
instead of ctor.
Cheers,
Ralf.
Bob Ippolito wrote:
> That's not equivalent. == on the ctor and instanceof on the instance
> are not the same operation.
>
> -bob
>
> On Feb 16, 2006, at 9:02 AM, Ralf Bokelberg wrote:
>
>
>>Here is another, more standard version:
>>
>>switch(model.ctor){
>> case DivideSentenceStep1:
>> case DivideSentenceStep2:
>>
>>}
>>
>>All you need to do is setting ctor to the real constructor of your
>>class. But on the other hand case by type is bad smell anyway, maybe
>>your classes should implement what's in the case.
>>
>>Cheers,
>>Ralf.
>>
>>
>>
>>Dan Shryock wrote:
>>
>>>Nope, you're not missing anything, that was exactly my point because
>>>that's all people are getting by using the switch statement in the
>>>way
>>>that they are. The syntax that I suggested is actually the only
>>>way of
>>>doing that sort of logic in xsl and jstl (using xml format of
>>>course).
>>>
>>>Dan
>>>
>>>On 2/16/06, *Scott Hyndman* <[EMAIL PROTECTED]
>>><mailto:[EMAIL PROTECTED]>>
>>>wrote:
>>>
>>> That appears to be an "if, else if, else" statement with
>>>different
>>> words...and a seemingly unnecessary outer block (the choose).
>>>
>>> Am I missing something?
>>>
>>> Scott
>>>
>>> -----Original Message-----
>>> From: [EMAIL PROTECTED]
>>> <mailto:[EMAIL PROTECTED]> on behalf of Dan Shryock
>>> Sent: Thu 2/16/2006 11:01 AM
>>> To: Open Source Flash Mailing List
>>> Cc:
>>> Subject: Re: [osflash] switch - case
>>>
>>> IMHO it is an abuse simply because the syntax isn't necessarily
>>> obvious for
>>> someone who expects a case inside of a switch to match the
>>>param to the
>>> switch. Maybe we should all start lobbying the major c based
>>> languages to
>>> support a syntax like this ;)
>>>
>>> choose{
>>> when(bla){
>>> //...
>>> }
>>> when(bla2){
>>> //...
>>> }
>>> otherwise{
>>> //...
>>> }
>>> }
>>>
>>> Dan
>>>
>>> On 2/16/06, Evan < [EMAIL PROTECTED]
>>> <mailto:[EMAIL PROTECTED]>> wrote:
>>>
>>>>I'm confused about you think that's an abuse of switch? That's a
>>>
>>> valid use
>>>
>>>>that's been used for YEARS in C programming, it's nothing new.
>>>>
>>>>-Evan
>>>>
>>>>On 2/15/06, Bob Ippolito <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>>>
>>> wrote:
>>>
>>>>>
>>>>>On Feb 15, 2006, at 8:59 AM, Jos Yule wrote:
>>>>>
>>>>>
>>>>>>Ralf Bokelberg wrote:
>>>>>>
>>>>>>>You can do it like this
>>>>>>>
>>>>>>>switch( true){
>>>>>>> case (model instanceof DivideSentenceStep1):
>>>>>>> //...
>>>>>>> case (model instanceof DivideSentenceStep2):
>>>>>>> //...
>>>>>>> default:
>>>>>>> //...
>>>>>>>}
>>>>>>
>>>>>>That is very clever.
>>>>>
>>>>>Why the heck would you want to abuse switch like that?
>>>>>
>>>>>if (mode instanceof ...) {
>>>>> // ...
>>>>>} else if (mode instanceof ...) {
>>>>> // ...
>>>>>} else if (mode instanceof ...) {
>>>>> // ...
>>>>>} else {
>>>>> // ...
>>>>>}
>>>>>
>>>>>-bob
>>>>>
>>>>>
>>>>>_______________________________________________
>>>>>osflash mailing list
>>>>>[email protected] <mailto:[email protected]>
>>>>>http://osflash.org/mailman/listinfo/osflash_osflash.org
>>>>>
>>>>
>>>>
>>>>_______________________________________________
>>>>osflash mailing list
>>>>[email protected] <mailto:[email protected]>
>>>>http://osflash.org/mailman/listinfo/osflash_osflash.org
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> osflash mailing list
>>> [email protected] <mailto:[email protected]>
>>> http://osflash.org/mailman/listinfo/osflash_osflash.org
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>---
>>>
>>>_______________________________________________
>>>osflash mailing list
>>>[email protected]
>>>http://osflash.org/mailman/listinfo/osflash_osflash.org
>>
>>_______________________________________________
>>osflash mailing list
>>[email protected]
>>http://osflash.org/mailman/listinfo/osflash_osflash.org
>
>
>
> _______________________________________________
> osflash mailing list
> [email protected]
> http://osflash.org/mailman/listinfo/osflash_osflash.org
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org