Just to stipulate from the outset, this is all “IMO”, and should be read that way. I’m not suggesting anything is intrinsically right or wrong, I am only sharing my thoughts. Which, also, can be right or wrong
Continuing the discussion from Input gathering: Syntax for Ordered Struct Literals:
This is not on topic for your thread (part of why I separated it out here), but I think the notion of “linked” might stand a revisit. I had not looked at these for a while, and initially went “linked… erm… what did these do again? Ah I think they preserve the order of the keys, using a linked list or something” (I did not notice your note above, which explained this). But this demonstrates the point: it needed explanation. The name here is taken from the implementation, not the actual purpose / intent of the construct. It should be:
ordredStruct = StructNew("ordered");
It’s the fact that it’s ordered we care about. Not that the way of implementing that is via a linked list. That is irrelevant by the time the code is used in CFML.
Possibly.
Elsewhere in CFML where a type is specified, it’s a prefix though, so this seems at-odds with CFML’s general approach to such things.
string function f(numeric x){
// etc
}
OK, I’m now confused. Does Lucee have both linked and ordered structs? What’s the difference?
You’re asking about syntax for a literal. This is not a literal, so invalid in this conversation. You are not solving the problem here either, as the argument to your constructor is what needs the special literal syntax here.
Bleah.
This will give you problems if you’re using a third-party lib like FW/1 or *box stuff, won’t it? You can’t unilaterally make settings like this which alters the behaviour of code, because it cannot be guaranteed to be appropriate for all code running under the auspices of the application.
This is the best option. It’s slick, minimal, and the meaning can be inferred easily as the {}
suggest struct and []
suggest ordering, coming from the array metaphor.
Cheers. Interesting topic.
–
Adam