Why was IsDefined() deprecated? (and less performant alternatives not?)

Thanks, but that just notes that isDefined is depreciated but doesn’t offer a “[…] newer, more modern way(s) to achieve the same result.”

2 Likes

Thank you for confirming that IsDefined() is deprecated and its less performant alternatives are not, but I was hoping for actual answers to my questions, in depth group discussion, and maybe some kind of judgment by committee. :slightly_smiling_face:

alas, you’re more than several years late to the party, check the archives!

I did check the archives, rather thoroughly in fact, which is precisely why I posted this topic. So there’s no room for rethinking it?

Also in the archives I saw no discussion for why its less performant alternatives are also not deprecated.

They both always exist and are empty by default.

There may be other scopes that are worthy of checking their existence? Either way, what about my six issues?

1 Like

Maybe I misunderstood. Are you referring to the old Google Groups or something else other than this Lucee Dev Forum? Have all six of my issues been discussed before? My questions aren’t rhetorical nor is it my intention to be a rabble-rouser. I put some serious logic into all of this and I’d appreciate thoughtful responses point by point instead of dismissing it all outright. Just because it was decided two years ago, doesn’t necessarily mean it was the right decision if all the issues I’ve raised were not included in that discussion, nor is it documented here for others who have the same thoughts.

yes, see the forum archives here.

“performant”? this is all splitting hairs over perhaps a millisecond, the function was deprecated due to limitations in the function which makes it unreliable, which cannot be changed due to backwards compatibility with cfml

the function isn’t being removed, it’s just not recommended anymore

Yep, bad example, but you know what I mean.

That was 13 years ago? I’d ask myself how does it look today, specifically in most modern cfml applications? I doubt it is in the top 5 or top 10.

I need to use isdefined() only once when I have an application that dynamically activates session managment, but only because the session scope doesn’t exist when session managment is deactivated.

@Zackster, as I said twice already, I did see the forum archives here. I spent DAYS looking for answers, and my questions were in fact NOT answered here.

Finally the answer to my question. Thank you!

The reason why I thought performance was the sole reason is because that was your response to @Simon_Goldschmidt when he inquired about it last month:

At that time you did not mention anything about it being unreliable, nor was that previously stated by anyone else anywhere within this forum.

@andreas I doubt that, too, but what I actually said was: “Judging from the frequency of surprised responses within this forum about it being deprecated, its popularity probably hasn’t declined much.”

At the very least, the fact that people are still asking about it shows that people are still using it, which indicates the need for better communication about it being deprecated.

They both always exist and are empty by default.

… for what it’s worth, when Adobe ColdFusion is invoked as a WebService (?wsdl), the form scope is not defined. At least. this is how it worked a million years ago - not sure if htis is still the case today. I haven’t tried using a WebSerivce in at least a decade.

That said, using isDefined() was the only way I could figure out (at the time) how to check to see if ACF form scope existed. Of course, like I said, I basically never use WebServices. Not sure how Lucee even handles them since I have not had the need to test.

1 Like

As @ASKemp pointed out earlier, there should at least be some description and alternatives added to IsDefined() :: Lucee Documentation and the list of deprecations.

Sebastian

1 Like

Well, seeing how the last book on ColdFusion was written in the stoneage, maybe a modern guide would be in order.

1 Like

I use the following:
form.keyExist(“the_variable”)
url.keyExists(“the_variable”)

That format restricts the search to the scope you’ve indicated.

1 Like

Cool … cool … so how long will it be fully supported? Asking for my future self. :grimacing:

I’ve been watching this slow burning thread and decided I should see how many uses of it I have.

  • Searching “isDefined” (not case-sensitive) found 680 hits in ~200 files (~7% of my cf* files) :astonished:

The larger issue in converting will be the frameworks and other tools (WAF) where we don’t want to introduce an unintended bug and will need to make sure the updated code performs EXACTLY as intended.
Some uses were intentionally written in a way to check if a “password” (PII variable) was passed from ANY scope, handle it a certain way: (clear it, do not accept it, overwrite it when done, and/or sanitize logged output).

YMMV but it’s a handy (maybe overused) function IMHO. :sweat_smile:

1 Like

Ha well you piqued my curiosity as well, and turns out I have IsDefined() in 68 files.

Some of those are from cflib.org, another reminder of how it’s not deprecated in Adobe CF.

And now I’m thinking about how I’ve been using IsDefined() for a couple decades, including the half decade after I switched to Lucee, and yet apparently I’ve had no reliability issues with it.

@Zackster, what are the specific conditions that make it unreliable?

Sounds like knowing what to avoid could be useful to many, and if you can let us know, I’ll try to allocate some time towards updating the Lucee doc page for it (mostly for learning how to do that), if that’s okay with everyone?

1 Like

I ran a regex search for

\W(list|of|deprecated|functions)\(

2/3 appear to be “easy” replacement patterns.

It got me to thinking, has anyone attempted to put together a few basic re find/replace snippets (that they care to share with the community as examples for common replacements)?

More docs / examples would be nice either way.

Deprecated - doesn’t necessarily mean that it will “ever” be removed, rather;

  • It MAY never get any updates.
  • It MAY get removed entirely.

So, I always read “depcreated” as;

  • look for alternative methods / procedures to get what you want.
  • use those new alternatives, moving forward
  • when you have some spare time, backport those solutions to existing code.

Gavin

2 Likes