bhartsfield
02/28/2023, 3:56 PMbhartsfield
02/28/2023, 3:59 PMstring.format( string, ["1","2","3","4"] )Adam Cameron
format is a java.lang.String method, not a CFML function.
And your issue is nowt to do with format anyhow. It's how each engine internally stores integerish values:
https://trycf.com/gist/f5e8659a99eddd46a3afd5a2b0471549/acf2021?theme=monokai
n = 123;
writeDump([
class = n.getClass().getName(),
toString = n.toString()
])
Lucee:
CLASS java.lang.Double
TOSTRING 123.0
CF:
CLASS java.lang.Integer (String before CF2018)
TOSTRING 123Adam Cameron
toString) then you'll be getting the Java result.
If you used the CFML function toString instead, yer problem goes away.
Not a bug, just a misunderstanding of the code in question.bhartsfield
02/28/2023, 4:18 PMAdam Cameron
123 as a Double rather than an Integer, then... so be it. That's the start and the finish of anything to do with CFML in this.
Provided Lucee's CFML implementation then exposes that value uniformly according to how CFML is documented to behave, then there is no bug.
You are calling a Java method on the variable, and Java doesn't care about CFML, so when you say myDouble.toString(), you will get however Java is specified to handle that. And it won't be the same as how Java's spec mandates how myInteger.toString() behaves. Nothing to see here: move along. This is all as expected.
When you then call the Java method String.format (it is not a CFML method), then the rules of Java apply: again, CFML has nothing to do with it.Adam Cameron
Adam Cameron
123 as a java.lang.Integer, then so should Lucee. Sure. All Lucee's types should be the same as CF's. All of them.
Even when CF decides to change from storing them as `java.lang.String`s, Lucee should have already been using `java.lang.String`s, and then gone "oh FFS CF you changed it!", and then they should have changed that too.
However. Like I said there's no CFML spec, and really I can see how Lucee would focus their efforts on the "surface" of CFML, not the inner workings. There's enough of that they haven't quite nailed yet before worrying about the inner workings that automatically come with a "know what you're doing" before ppl ought to go use them.
Advice for the once bitten: when calling Java methods on an object in CFML... make sure you check what the type of the object is first. And also understand the difference between CFML member functions and Java methods. And... have units tests on everything so when porting across platforms you know when stuff fails before hand.Adam Cameron
Since the Lucee mantra is "backwards compatibility", then how is this not a bug?Oh and also be aware that they only apply this when it's convenient. They are more than happy to do whatever the hell they like that's different from CF's implementation under the guise of "well we felt like doing it different because we're clevererer than Adobe". Debatable. Especially if one looks at the bigger picture.
Evil Ware
02/28/2023, 9:30 PMzackster
03/01/2023, 9:20 AMbhartsfield
03/01/2023, 1:26 PMAdam Cameron
format and toString... aren't Lucee / CFML. This is a bit like me pointing at some broken code in front of me (which is PHP today, and it's def currently broken FFS!), and say "bloody bug in Python".
It's fine that you went "oh this is different, I didn't expect that". Absolutely right & on point, and indeed a bit curious on initial inspection. It's the bit about it being a Lucee bug that was off target. Which is what I was trying to explain. And look how well that's turned out.
I think I will move on now. I have that bloody bug in python to fix, after all ;-)