object/map/array unified .len() method

Propose new features and changes
azure
Posts: 4
Joined: 26 Jun 2023, 03:14

object/map/array unified .len() method

16 Oct 2023, 05:57

In other languages, both hashmap/vec/array seem to have a consistent .len() method for getting the capacity, but in AutoHotkey, the method for getting the capacity of a variable is:
[].length/map.count/ObjOwnPropCount({})

Do we need to implement a unified method?


[Mod action: Moved topic from “AutoHotkey Development”.]
azure
Posts: 4
Joined: 26 Jun 2023, 03:14

Re: object/map/array unified .len() method

16 Oct 2023, 06:37

I am skeptical of the rationale for the move. I am not expressing a wish, I am simply trying to discuss whether we need this change.
User avatar
boiler
Posts: 17327
Joined: 21 Dec 2014, 02:44

Re: object/map/array unified .len() method

16 Oct 2023, 06:46

So you’re not saying you would prefer it but rather are asking if it’s necessary that AHK be unified with other languages in this respect? Why would it be necessary?
geek
Posts: 1055
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: object/map/array unified .len() method

16 Oct 2023, 11:02

It is not sensible to have a single method that returns both the length of an array and the count of properties owned by an object, because Arrays and objects descending from Arrays have own properties so two methods are needed to get each individually, whereas combining them method creates ambiguous behavior -- which would be returned?

It would be possible to have a single method name that both describes the count of key/value pairs in a map and the length of an array, but the two operations are not very semantically similar. Do you think there's some kind of polymorphic code that would be facilitated by that overlap?

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 7 guests