Status/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Abram Adams / Abram Adams (Abram Adams)
Created: 03/09/2016
Components: Language
Versions: 2016
Failure Type: Unspecified
Found In Build/Fixed In Build: Alpha3_v12 /
Priority/Frequency: Normal / Unknown
Locale/System: English / Linux All
Vote Count: 1
Now that we have ordered/sorted structs structNew("sorted/ordered") we need to also have literal syntax support. This was discussed in the PR forums, but no consensus was made on what the best syntax would be. However, I don't think that the feature should ship without it as it makes it very cumbersome to use the feature and is a step backwards in language modernization.
Consider the following possible options (and please propose your own)
Maybe optional types (which would have other benefits)
Add optional type system (see also https://bugbase.adobe.com/index.cfm?event=bug&id=3687548):
SortedStruct s = {};
or annotations:
@Ordered
o = {};
@Sorted({ type: "asc" })
s = {}
s = @Sorted({ type: "asc" }) {}
or
s = {} AS sorted;
or
s = {}::sorted
or
s = sorted{}
There are obviously many other ways one could express this, and I'm not sure any of the above (besides the optional type system) would make sense when looking at other language implementations, but it's a starting point. One should not have to revert back to 2005 and do:
<cfset departments=StructNew(“Ordered”)>
<cfset val=StructInsert(departments, "John", "Sales")>
<cfset val=StructInsert(departments, "Tom", "Finance")>
<cfset val=StructInsert(departments, "Mike", "Education")>
when we could instead have:
Ordered departments = {
"John": "Sales",
"Tom": "Finance",
"Mike": "Education"
}
(BTW, what a terrible code example)
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 4126544
External Customer Info:
External Company: CFXchange.com
External Customer Name: Abram Adams
External Customer Email: AADAMS@CFXCHANGE.COM
External Test Config:
Attachments:
Comments: