I have to disagree with your assertion that isDefined() is doing a lot more
work.
This returns true on my machine:
<cfset form.test = structNew()>
<cfset form.test.foo = "bar">
<cfoutput>#structKeyExists(test,'foo')#</cfoutput>
Which indicates that structKeyExists() is using the exact same implicit
lookup as isDefined().
The only absolute advantage that structKeyExists() confers is that it
validates that the first part is a structure rather than a variable with a
'.' in the middle of it, but I don't think it provides the performance
benefits you are alluding to.
Unless I'm missing something here of course.
Spike
--------------------------------------------
Stephen Milligan
Code poet for hire
http://www.spike.org.uk
Do you cfeclipse? http://cfeclipse.tigris.org
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Barney Boisvert
>Sent: Monday, July 12, 2004 12:27 PM
>To: CF-Talk
>Subject: RE: StructKeyExists() vs IsDefined()
>
>If variables.myField doesn't exist, then it'll search
>form.variables.myField, or possibly form["variables.myField"],
>maybe even
>both. Same goes for url, and maybe even variables
>(variables.variables.myField). You'd have to write a little test to be
>sure, but isDefined is definitely doing a LOT more work than
>structKeyExists().
>
>Cheers,
>barneyb
>
>> -----Original Message-----
>> From: Matt Robertson [mailto:[EMAIL PROTECTED]
>> Sent: Monday, July 12, 2004 1:03 PM
>> To: CF-Talk
>> Subject: Re: StructKeyExists() vs IsDefined()
>>
>> Barney wrote:
>> >isDefined(), on the other hand, looks in all the potential places
>> > that the variable can exist. So it'll check the variable
>> as named, and then
>> > for a variable with that name in all the implicit scopes.
>>
>> What if you define the var explicitly?
>>
>> if (isdefined("variables.myField")) { variables.yadda=yaddayadda; }
>>
>
>
>
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]
- StructKeyExists() vs IsDefined() Damien McKenna
- RE: StructKeyExists() vs IsDefined() Barney Boisvert
- Re: StructKeyExists() vs IsDefined() Matt Robertson
- RE: StructKeyExists() vs IsDefined() Barney Boisvert
- RE: StructKeyExists() vs IsDefined() Spike
- RE: StructKeyExists() vs IsDefined() Barney Boisvert
- RE: StructKeyExists() vs IsDefin... Spike
- RE: StructKeyExists() vs IsD... Barney Boisvert
- RE: StructKeyExists() vs IsD... Spike
- Re: StructKeyExists() vs IsD... Sean Corfield
- RE: StructKeyExists() vs IsD... Spike
- Re: StructKeyExists() vs IsD... Sean Corfield
- Re: StructKeyExists() vs IsD... Simon Horwith
- RE: StructKeyExists() vs IsD... Barney Boisvert
- RE: StructKeyExists() vs IsD... Spike