+1Helgef wrote:Code: Select all
[name : "Tedd", age : 37]
+1lexikos wrote:It is unlikely that any "shorthand" syntax I add for Map will allow quote marks to be omitted.
This is very important for me over shortness. I hadn't been able to comprehend the rules of DllCall() parameters for a long time. When I finally understood that type-value pairs are passed in series, instead of a pleasant feeling of Eureka, I got a bit confused as to "why this is designed so?"; type-value pair relationships cannot be grasped at first glance. I concluded there was no choice but to do so within the already designed syntax when it was supported. But for Map(), there seems to be a room for dedicated syntax.lexikos wrote:the main advantage of dedicated syntax (comparing the original Object() to {}) is the visual pairing.
I'm unable to grasp the logic in this part. Is it saying "[] and {} are already used so the suggested syntax, [ "foo": "bar" ] for Map( "foo", "bar" ), won't work"?lexikos wrote:One problem is that [] creates an empty Array and {} creates an empty Object, so overloading based on whether there are key-value pairs vs. just values would not completely work.
lexikos wrote:Associative arrays most often start out empty, so new syntax for an "associative array literal" seems unnecessary.
I often encounter a need to do this for function or class method parameter values. For example,lexikos wrote:Do you regularly create associative arrays and need to populate them with a fixed list of key-value pairs at the point of creation?
Code: Select all
msgbox GetStringReplaced( "The quick-brown fox jumps over the lazy dog.", Map( "quick-brown", "slow-yellow", "lazy", "energetic" ), true )
GetStringReplaced( sHaystack, mReplacaments:=Map(), bCaseSense:=false, &iReplaced:=0, &iLimit:=-1 ) {
for _sNeedle, _sReplacement in mReplacaments {
sHaystack := StrReplace( sHaystack, _sNeedle, _sReplacement, bCaseSense, &_iReplacedNow, iLimit )
iReplaced += _iReplacedNow
}
return sHaystack
}
This must be a repeated request but I couldn't comprehend the reasoning of the addressed problem.lexikos wrote:2. That syntax was suggested by Helgef in the second post of this topic, and I already brought up one problem with it.