http://coldfusion.com logo
#lucee
Title
# lucee
r

ryan

03/11/2022, 5:29 PM
Is there a future plan for
isValid
to be allowed as a member function?
b

bdw429s

03/11/2022, 5:30 PM
Search the issue tracker. If you don't see any tickets, the answer is "no" 🙂
The you ca add a ticket for it! 😆
r

ryan

03/11/2022, 5:33 PM
just did a search for lucee issue tracker... is this the right place? https://luceeserver.atlassian.net/jira
b

bdw429s

03/11/2022, 5:34 PM
Yup, that's the place
Does Adobe support it at all?
If not, put in a ticket for them and link the two. Not that either engine cares about the other, but it's easier for the community to keep track
r

ryan

03/11/2022, 5:35 PM
https://luceeserver.atlassian.net/browse/LDEV-63 Thanks for entering this in @Adam Cameron.... BACK IN 2015! 🤣
At least the ticket says it is in "Development", but who knows how long (years?) it has been sitting with this status.
isvalid
, as a member function, does not work in CF 2021, either.
Would you happen to have the link for the adobe coldfusion support tickets?
b

bdw429s

03/11/2022, 6:09 PM
I could give it to you, but I literally just google "adobe ticket tracker" every time I want to find it.
You can save me the step by just putting that into Google yourself 🙂
r

ryan

03/11/2022, 6:11 PM
well, I did search first, which is why I asked afterwards, because I'm not finding it, or at least nothing in the list or what I have clicked on in the search looks legitimate. Not trying to be lazy here by asking, but I didn't imagine this would need so much searching to find the the correct one.
b

bdw429s

03/11/2022, 6:12 PM
It's the third result on Google for me
ah, third after the damn ads
I did actually go to that link, but it didn't look right
It doesn't say anything about ColdFusion, so I figured it was not correct
Thanks for the help.
b

bdw429s

03/11/2022, 6:16 PM
It's a shared ticket tracker
You have to select coldfusion from the list of products when you create the ticket
r

ryan

03/11/2022, 6:17 PM
I see
Thanks
I added it. Probably could have listed more string functions to be included with this, but don't have time to check remaining functions that are not member functions to be included, at the moment. https://tracker.adobe.com/#/view/CF-4212873
👍 2
Let's hope that maybe if ACF considers this, then they consider looking at others to be a part of a bigger rollout as member functions.
b

bdw429s

03/11/2022, 6:27 PM
Good luck, lol
The biggest issue with member functions is they are only available on specific types of objects
So while you can safely do
Copy code
isvalid( anyRandomVariable, 'number' )
you CAN'T do
Copy code
anyRandomVariable.isvalid( 'number' )
r

ryan

03/11/2022, 6:28 PM
correct
b

bdw429s

03/11/2022, 6:28 PM
anyRandomVariable
must first be a type that the CF engine has defined to have that member function. Which makes them fairly useless in any sort of libraries or frameworks which need to dynamically handle diverse inputs
I am always leery of even doing stuff like
Copy code
simpleValue.len()
because it works fine until the simple value is a boolean eye roll
And it doesn't matter if it's in a UDF that appears to check the type like so
Copy code
function myFunc( required STRING foo ) {
  return foo.len();
}
That will still blow up with
Copy code
myFunc( true )
Just pissed me off thinking about how useless it is 😠
r

ryan

03/11/2022, 6:32 PM
just tested your example. interesting that it works as a regular function and not as a member function. Totally different behavior
I'm sure you probably put in a ticket for that as well, eh?
b

bdw429s

03/11/2022, 6:33 PM
oh gosh yes
I have wasted hours of my life arguing with Adobe and Lucee engineers alike about this
For years
It makes sense why it works the way it does, but the way it works is stupid, lol
It took years just to get some of the basic string member functions added to numbers. They have had the same issues as booleans have now
Copy code
myFunc( 45 )
Adobe has made progress on this. Both true and
4
return an actual len in the later versions of CF
Lucee, not so much. It's a "feature" not a bug, per micha
r

ryan

03/11/2022, 6:36 PM
Right, how is it acceptable to have totally different behavior when, in theory, the functions are to expected be exactly the same when the function name is the same name.
b

bdw429s

03/11/2022, 6:37 PM
It's not really that
len()
"behaves" different. it's that it doesn't exist on those data types.
Which, from an OO perspective, makes sense. But it also makes it fairly useless in a loosely typed language.
All of the decision functions like
isArray()
,
isStruct()
, or
isSimpleValue()
as well as UDF arg types all ask the question, "Can this variable be cast INTO this type if we wanted".
Which is a different question than, "Is this an actual CFML array, struct, or string right now?
r

ryan

03/11/2022, 6:39 PM
that makes sense
b

bdw429s

03/11/2022, 6:42 PM
You have the same issue when you do this
Copy code
myMap = createObject( 'java', 'java.util.HashMap' );

structInsert( myMap, 'foo', 'bar' );
writeDump( myMap.keyArray() )
You have an object which can be used as a struct, but doesn't actually have struct member functions in it
r

ryan

03/11/2022, 6:43 PM
but I would argue then that if it doesn't do what it should compared to it's regular function, then the behavior is different. The result is not as expected. If ACF is looking at this member function to decide if it is an array, struct, or string, and the regular function is not doing that, then isn't it considered a change in behavior?
b

bdw429s

03/11/2022, 6:44 PM
It's a behavior change of the language
Or, at best an inconsistency of the language
r

ryan

03/11/2022, 6:45 PM
🤘🏼
b

bdw429s

03/11/2022, 6:46 PM
The engineers for both engines have always claimed it would be a hit to performance to detect what the type is at runtime. I'm not entirely sure how that differs from the checks/casting that already happens inside the headless forms of the functions
I'm not entirely sure what the bytecode looks like for both options
z

zackster

03/11/2022, 6:49 PM
when checking for member functions, lucee doesn't cast, it checks the type https://github.com/lucee/Lucee/blob/6.0/core/src/main/java/lucee/runtime/util/VariableUtilImpl.java#L788
👍🏼 1
adding support for that is looooooooooooow priority and not worth it IMHO
structKeyList()
is great candidate,
st.keyList()
is nice
we would have to add that all over the place for mulitple types
x.isValid("email")
vs
isValid("Email",x)
just saves one character
(ignoring chaining for a moment)
not that a return value of true or false is that useful in that context
r

ryan

03/11/2022, 7:04 PM
It would be great for devs not to have to be in this constant state for so many years of wondering what function is or is not a member function. It would be great if every function is usable as a regular or member function. I would assume that this idea would make it a very time consuming task, but it is just one of those annoyances that has been hanging around for years. I get that there is only so many of you and capacity work load is limited and I appreciate what Lucee has done and its current efforts for the CFML community. I just wish there were some of these loose things that devs grapple with on a daily basis to get tied up.
z

zackster

03/11/2022, 7:05 PM
my usual internal dialogue is, does this BIF start with (struct, list, query, array) then there's a member function
👏 1
r

ryan

03/11/2022, 7:16 PM
Understood. Are you having this internal dialogue based on limitations by having to pick and choose based on projects that have a higher priority or is this idea of these pre-fixed BIFs what it should be permanently? In a previous life, I coded in RoR. I am not attempting to say that I want everything like RoR or Python, but the door opened with the first member function available in CFML. I loved the fact that, in my limited time in RoR (many years ago), it was a great feeling knowing that I could write everything as a member function. There wasn't any guessing and/or testing, discussing, etc. In CFML, I just wonder how much wasted time we spend as devs in all of these companies around the world checking to see what is and is not a member function. I am definitely willing to be enlightened, if my premise (which is very basic in the Java world) is totally incorrect.
I do appreciate your previous response as I can move on with remembering your tip about struct, list, query, array as member functions, so thank you for that. 🙂
❤️ 1
a

Adam Cameron

03/13/2022, 5:33 PM
I see no reason why there's not a notion of
isValid
that can be a method of at least some of CFML's data types. eg:
myString.isValid("date")
has sensible meaning.
myArray.isValid("uuid")
... not so much 😉 However, as @bdw429s points out, that's not as useful as it could be, in generic situations; and also not as flexible as the top level functions can be given the "flexibility" CFML shows in its type handling. There's also something to be said that type checking (or "type interpretability", which is all
isValid
is doing) is perhaps better left to a level outside the type system itself. --- I think this discussion comes back my frequent observation here: it's just a misunderstanding of "how things work" in OOP that leads to the expectation that
someFunction(somethingUsableHere)
should have a direct mapping as
someConcreteThing.function()
. It's easy to confuse one's self when there are identical words in play:
ArrayMap()
and
Array.map()
, but one needs to understand the usage of
array
in the first one does not mean the same thing as in the second one: same word, two different (and legitimate) usages.
ArrayMap
does not take an array as a first argument in the same sense that there is an
Array
type in the second one. The function signature of
ArrayMap
would be something like:
Array ArrayMap(SomeVagueArrayInterface a, function f)
, whereas when we talk about
Array.map
it is a specific method on that specific Array class. That's just how OOP works. There is no confusion in the reasoning for the implementation, there is just confusion on the part of CFML devs migrating from procedural to OOP CFML.