> > Yes, but the one of the reasons used to in persuading people to scope
> > their variables properly other than good practice was so that
> > isDefined() only checked a specific variable in a specific scope
>
> Not sure who was saying that (as you say it was before my time) but
> scoping variables is worthwhile in general to control lookup. My
> recommendation is simply:
> - don't use isDefined()
> - always scope your variables
>
> > Sorry to bang on about this, but isDefined() appears not to be working
> > the way I have, perhaps mistakenly, understood in the past from the
> > various book writing luminaries of the mailing lists.
>
> I think this is just a corner case that most people tried to ignore ;)
> > Knowing that as CTO you will know better than me the inner workings of
> > CF, are you saying that CFMX does not do this?
>
> I'm not CTO (I'm not actually sure who is - it was Jer when he was
> still around and he was my boss).
Opps... No idea where I got that from, probably cos Jer was your boss
and senile dementia is setting in early.... According to the MM site the
CTO is apparent a chap by the name of Jonathon Gay.
> > So are you saying that every scope all ready exists in CFMX as a
> > structure, even if that scope is empty?
> Yes.
Interesting to know..... I'll store that one away
>
> > Does this hold true for previous versions of CF? I'm still mostly on
> > CF5. Don't fix what ain't broke, particularly if the client is happy.
>
> No, that's one of the big differences: CF5 treated scope names as sort
> of magic reserved words whereas CFMX treats them as real variables of
> type struct. I think that CF5 might return false for isDefined() on
> some of the scope names (haven't tried it... isDefined("server")
> anyone?).
You certainly can't cfdump some of the scopes.
> > What you're saying here is that not only does isDefined() not take into
> > account scopes (as argued above), it also has an added layer where
> > having checked for the structure foo and the key bar in all the scopes
> > and not found it, it now looks for the variable "foo.bar" in all the
> > scopes too?
>
> Whilst I will disagree with the first part of that, the second part is
> correct - isDefined() will go looking for "foo.bar" because - in CF5 -
> it could have been a valid variable name.
... in the name of backward compatibility.
> > Also as a mainly
> > CF5 developer I have to be sure that isDefined() is doing the right
> > thing and that structKeyExists is _only_ a CFMX short cut.
>
> It's true that you can't use structKeyExists() everywhere in CF5
> (since not all scopes behaved like structs). The "right thing" in CF5
> is debatable however since CF5 specifically allowed dots in variable
> names which is why isDefined() has such funky behavior! :)
What nutter let that one through?! Particular when we had structs in
CF4.x :-)
Its a shame that isDefined() doesn't say :
"you've given me a variable with a known scope - I'll look for that
variable in that scope only"
or
"you've given me a variable with no scope or no known scope, so I'll
scan all the scopes for it".
Really this is only an issue for me on CF5 and not even much of an issue
at that. In CFMX, now that I know that the scope structs are always
there, I can just use structKeyExists().
Mind you, why shouldn't isDefined() work like this on CFMX? It might
make it useful again.... hmmm now where did I put that url for the
feature request form??? ;)
Thanks for your time and putting up with me
Regards
Stephen Moretti
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

