Among far more than 80% of object literals, we will probably give it
base property everytime we write the literal
{}. They will almost certainly look like this:
{base:x,...}. Therefore, as
base: is occurred so frequently when object lieral occur, why not just omit
base: just for a small simplification of the codes? How about this idea below?
g1:=gui(),t:=g1{prpt1:'cc'}. It would equal to
g1:=gui(),t:={base:g1,prpt1:'cc'}.
For example, these three lines below would be equal to each other.
Code: Select all
;These three lines will be equal to each other.
m:=Map('key1',3,'key2',5,'key3',7) ;it is the current code.
m:=Map{key1:3,key2:5,key3:7}() ;it's actually shorter than the current
m:={base:Map,key1:3,key2:5,key3:7}()
;By the way, it is not exactly right, as a key string starting with any number can not completely be suppported by object literal. I use Map just for a example.
Another important reason to encourage this new syntax is that the old syntax is actually "not right". Because
{base:GUI} is originally based on GUI, but
{base:GUI} in reality doesn't have the
base "property" which is only owned by
Any instead. So, object literal had better not contain
base as if a property. It's easy to mistake. It never owns
base at the beginning.
base is just something special which just produces inconsistency with other else normal properties within an object literal. A special syntax handle to a special
base like
baseX{prptX:...} will look much better in my opinion.
- image.png (35.35 KiB) Viewed 1485 times
As we see, Even
zero-plusplus, which is the famous ahk debug plugin in VSCode, does show every AHK object just exactly like this for a long time.
It would not break the existing codes.
More interestingly, the three of them:
a(),
a[],
a{}, would keep consistency with each other. Perhaps this would occur in V2.x if you could consider the Grammar Pond.