My feedback on the "struct literal" thread

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 :wink:

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.


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.


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.


1 Like

I created a new thread for the topic of revisiting StructNew( ‘linked’ ). Had previously commented here but figured a more focused topic might be useful.

I like that this conversation is not on the original thread. all of these comments were discussed at length in an old thread.

as a matter of fact, when I posted the original one a couple of days ago, I went over the old thread and summarized it into those 9 options.

in the old thread @adam_cameron also brought up the “ordered” vs. “linked”, and that was when we decided that he was right and we added “ordered”. also, in the old thread there was a wide positive reception to option #9, as there is now in the new thread.

going over the whole thing in detail again would just make drawing conclusions from the new thread harder, so while I must admit that I did not understand completely why @dom_watson posted the guidelines at first – I like that he did that as it keeps the other thread clean and concise.

Given that. Let’s close this one (or just let it be). And we can start a detailed critique of option 9 so that next time the TAG meet, they can make an advisory decision on that specific proposal.

Apologies for acting hastily on this, missed the context of previous discussions.