> So what would happen in the following in code?
> <cfoutput>#structKeyExists(remote_host,'blah')#</cfoutput>
CF would lookup up remote_host and find it in CGI scope. It would then
pass the value of CGI.remote_host to structKeyExists().
> Does it need to go off to the web connector, or does it already know that
> the CGI scope can't contain a struct?
I don't know whether CGI.remote_host causes a web connector lookup -
probably not since that's a 'standard' CGI variable. Whether it can be
a struct or not is irrelevant at that point. The sequence is:
- CF evaluates the _expression_ which is the first argument
- CF evaluates the _expression_ which is the second argument
- CF calls structKeyExists() and passes those values
- structKeyExists() checks the first arg is a struct and then looks
for the key specified by the second argument
> <cfoutput>#structKeyExists(foo,'bar')#</cfoutput>
> If foo doesn't exist in the variables scope, structKeyExists() definitely
> looks in the form scope, and presumably the other implicit scopes.
No, structKeyExists() does *not* look in those scopes - CF does.
structKeyExists() only gets executed once CF has evaluated the
_expression_ foo and retrieved whatever value it has (or not).
> What is the performance benefit of using structKeyExists() in that scenario?
Because CF looks up foo and then structKeyExists() only checks the
value of foo for a key called bar.
isDefined('foo.bar') by constrast will perform all sorts of searches -
if it finds a foo but that doesn't contain bar it will look for a
variable called foo.bar and start the search all over again.
Do <cfset variables['foo.bar'] = 42 /> and then try
isDefined('foo.bar') vs structKeyExists(foo,'bar') (the latter will
fail *before* calling structKeyExists() because foo is not defined as
a variable).
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]
- RE: StructKeyExists()... Barney Boisvert
- Re: StructKeyExists()... Sean Corfield
- Re: StructKeyExists()... Stephen Moretti (cfmaster)
- Re: StructKeyExists()... Sean Corfield
- Re: StructKeyExists()... Stephen Moretti (cfmaster)
- Re: StructKeyExists()... Matt Robertson
- Re: StructKeyExists()... Sean Corfield
- Re: StructKeyExists()... Sean Corfield
- Re: StructKeyExists()... Sean Corfield
- RE: StructKeyExists()... Spike
- Re: StructKeyExists()... Sean Corfield
- Re: StructKeyExists() vs IsDefined... Matt Robertson
- Adding to dates using CreateTimeSp... Jordan Michaels
- Re: Adding to dates using Crea... Bruce Sorge
- Re: Adding to dates using... Jordan Michaels
- Re: StructKeyExists() vs IsDefined() Jordan Michaels
- RE: StructKeyExists() vs IsDefined() Dawson, Michael
- RE: StructKeyExists() vs IsDefined() Barney Boisvert
- RE: StructKeyExists() vs IsDefined() Spike
- RE: StructKeyExists() vs IsDefined() Hugo Ahlenius
- Re: StructKeyExists() vs IsDefined() Mike Chabot