ACF2021 - Identity/Not Identity Operator

Description

The ACF implementation
https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/using-expressions-and-number-signs/expressions-developing-guide.ug.html#equality-inequality

differs from the Lucee implementation , in Lucee this is a identical operation,so it compare if the operand are the same object or not, the same way as PHP does. We should add a flag to Lucee for backward compatibility.

Activity

Show:

Adam Cameron 23 April 2022 at 23:02

This just came up for me again, and I looked into it further.

There’s two approaches to === out there:

  • o1 === o2 IFF o1 and o2 are references pointing to the same object. Lucee, Python, Groovy, Kotlin do this.

  • o1 === o2 IFF their values are “equal”, AND their types are equal. Which is CF, JS, PHP, Ruby do this.

Analogous example code for all languages mentioned above here: https://gist.github.com/adamcameron/c854236acc949bf739192d6afe8bc761

Make of that what you will. IMO irrespective of anything else, Lucee ought to be doing the same as CF. That trumps any parallels / similarities to other languages.


A side effect of Lucee’s behaviour that conflicts with idiomatic CFML a bit is that "ABC" === "abc" is false. If Lucee took the equality & type check approach, it’d be true (and this is CF’s behaviour).


DO NOT make yet another flag that changes language behaviour. That was never a good idea, and with Lucee 6 you are allowed to make breaking changes. And as pointed out on the other ticket… it ain’t gonna break anything anyhow.

Zac Spitzer 9 August 2021 at 21:23

+1000 for this being a breaking change for Lucee6

rather than a flag, I’d suggest we maybe offer a method or syntax to achieve the previous behaviour (searching === is an easy syntax to search for)

Adam Cameron 9 August 2021 at 20:02

Note that Lucee does not behave the same way as PHP.

Lucee:

<cfscript> s1 = "ABC" s2 = chr(65) & chr(66) & chr(67) writeOutput(s1 === s2) // false </cfscript>

(https://trycf.com/gist/0b06b5faf6309d3e57c47e21746d9916/lucee5?theme=monokai )

PHP:

<?php $s1 = "ABC"; $s2 = chr(65) . chr(66) . chr(67); echo $s1 === $s2; // true

(http://sandbox.onlinephpfunctions.com/code/558e0ab7dd2c7821deb343409af35ef11c527fc9 )

Duplicate

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Priority

Created 13 November 2020 at 08:40
Updated 2 May 2022 at 17:17
Resolved 2 May 2022 at 17:17