In the case of an "un-typed" language (or pseudo-typed as CF tends to be), you are correct. I was speaking more from a conceptual standpoint . . . I've generally found it better to declare variables up front, even in languages that support late-binding or just-in-time declaration. Underneath the hood, I doubt it really matters today, with most compilers performing the same optimizations regardless of where you put your declarations. It does however enforce a discipline to coding that I believe provides a benefit in terms of code clarity, and it forces developers to think through a function from start to finish instead of the "code as you go" method of programming.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matt Liotta Sent: Tuesday, February 10, 2004 10:18 PM To: [EMAIL PROTECTED] Subject: Re: [CFCDev] How should I define variable in a CFC? I don't really see how that is an "acquire early" method of memory allocation as the suggestion is to "var" an empty string and then later turn it into a struct, which means the memory for the struct is still allocated at the same time. I'm not really worried about memory allocation though. I just find it messy to declare variables that I might not use at runtime. Maybe it is a holdover from my C days, but nevertheless that is how I feel. -Matt On Feb 10, 2004, at 10:09 PM, Roland Collins wrote: > I've always been a proponent of the "acquire early" method of memory > allocation, which is essentially what the up-front "var" requirements > are > enforcing. For one, it greatly helps with code-readability and forces > you > to think through what really needs to be in a given function. If > you're > getting into logic that sometimes requires a large memory segment (or > complex variable) and sometimes doesn't, then the argument could be > made > that the code could use some refactoring. Most of the time, however, > a temp > variable is so small as to be insignificant if it's not used, so it's > not > worth worrying about. > > > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf > Of Matt Liotta > Sent: Tuesday, February 10, 2004 9:35 PM > To: [EMAIL PROTECTED] > Subject: Re: [CFCDev] How should I define variable in a CFC? > >> What am I missing about why it's a problem? >> > Again, its messy since you have to define all these different names > upfront for branch logic that might not ever require them. I never said > it couldn't be dealt with; I just don't like how you have to deal with > it. > > -Matt > > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at > www.mail-archive.com/[EMAIL PROTECTED] > > > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at > www.mail-archive.com/[EMAIL PROTECTED] > ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED] ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
