CF gets enough criticism about being slow.  Adding functionality doesn't
mean that developers will understand the consequenses of using it.  They'll
just complain that it's slow, even if the docs explicitly state that using
such code is not recommended in most circuimstances because of performance
issues.

I know I've never read the docs on the CFSWITCH..CFCASE tags, and I know I
never will, I'll just end up trying a dynamic case by accident one time, not
get a syntax error, and then wonder why my app is running slow all of a
sudden.

However, adding an attribute to the CFSWITCH tag that allows for dynamic
cases might be an option.  Just make sure it's documented as slow, because
it manually converts the switch into a set of if..elseif..else statements
during compilation to save typing.  Then you wouldn't have as much problem
with unexpected slowdowns.

---
Barney Boisvert, Senior Development Engineer
AudienceCentral (formerly PIER System, Inc.)
[EMAIL PROTECTED]
voice : 360.756.8080 x12
fax   : 360.647.5351

www.audiencecentral.com

> -----Original Message-----
> From: Matt Robertson [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 26, 2003 3:26 PM
> To: CF-Talk
> Subject: RE: Using variables in a Switch case?
>
>
> James wrote:
> >Uhm.. If..elseif..elseif..elseif..etc..else..endif
> and
> >CFMX has the same "problem".
>
> And rest assured it is a problem that is not afflicted on every
> language.  I posted a feature request for this functionality and
> some others to Macromedia and it didn't get anywhere.  My
> impression was the speed of the tag would have been degraded in
> this environment if such a feature had been added.  Shame because
> it is incredibly powerful.
>
> Lets say, for example, you have a chunk of code that has to
> branch in one of 50 directions, and those directions are variable
> depending on stuff that happened further up the pipe.
>
> Compare the exercution time of hobbling thru 50 elseifs versus
> one case statement where the only code that gets executed is the
> case you need at the moment.
>
> Or wouldn't it be nice to be able to code this:
>
> select case zipcode%
>   case 93701:territory%=1
>   case is 93702 to 93750:territory%=2
>   case is 93751, 93752, 93754, 93755 to 94900:territory%=3
>   case > 94901:territory%=4
>   case else:territory%=5
> end case
>
> Can you write this some other way?  Yes.  As elegantly?  I had to
> translate an insurance company's entire rating system into CF and
> I sorely missed the ability to use variables and ranges in case
> statements.  So would you if you had the opportunity to use them.
>
> I'd like to see something like this in CF still.  Never mind the
> speed.  Look at the functionality.
>
> -------------------------------------------
>  Matt Robertson,     [EMAIL PROTECTED]
>  MSB Designs, Inc. http://mysecretbase.com
> -------------------------------------------
>
>
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to