tracker issue : CF-4010490

select a category, or use search below
(searches all categories and all time range)
Title:

Expose the interfaces that dictate built-in types

| View in Tracker

Status/Resolution/Reason: Needs Review//

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 06/22/2015

Components: Language

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Platforms All

Vote Count: 4

From http://blog.adamcameron.me/2015/06/what-id-like-to-see-in-coldfusion12.html

Currently a struct function can only take an actual struct (well: it's some underlying Java class, but you get my point). Publish and expose-for-use the interface so we can implement "structness" on our own classes so they will work as structs (or arrays, or [whatever]). I should be able to implement an ArrayAccess interface in my class, and then use it in a for (element in array) loop, for example. make sure to change all built-in functionality to expect the interface, not the type, obviously (perhaps not "obviously", because PHP forgot to do this in places).

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4010490

External Customer Info:
External Company:  
External Customer Name: Adam
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

This would definitely be useful!
Vote by External U.
7158 | June 29, 2015 04:16:03 AM GMT
Harmless is just the word: that's why I like it! Doesn't kill, doesn't wound, doesn't maim. But I'll tell you what it does do: it is very good at opening doors!
Vote by External U.
7159 | June 30, 2015 12:08:04 PM GMT
................................................................
Vote by External U.
7160 | July 01, 2015 02:56:51 AM GMT
test note
Comment by Vamseekrishna N.
7157 | July 17, 2015 12:53:00 AM GMT
You can get some of this functionality (concerning arrays) by implementing an "iterator" (and maybe size?) function and making your component return a dynamic proxy of "java.util.List" instead of it's actual type. If you implement a few other functions (get, size, and maybe sublist for slices), you can use array notation for access (but not for setting I don't think). Your component (if set up this way) will even work in cfscript for-in loops. The downside is iirc that your component loses the ability to expose any other functions (since you're just proxying List). Still, I used this to implement a list which lazily evaluates its members when they're actually accessed, and for that very specific usage it works pretty well. +1 to make this a real feature of ColdFusion and not some magic incantation I use to scare people =P
Comment by Justin L.
31035 | July 16, 2019 04:27:02 PM GMT