Anyone using Map() introduced in 6.49?

Anyone using Map() introduced in 6.49 ?

I am asking because some users apparently used map as variable identifier and I am wondering if it would be good idea to rename Map() to MapCreate() so chance for conflict with existing code is minimized.

Anyone using Map() already? Comments?

Chances of someone using map as their own variable name or function name is higher then those who would've began using the new map() structure as it is very recent.

Although i don't have either in my code to break anything, but mapCreate() or something is better. Bcos anyway, subsequent uses will be the variable name.

mymap = MapCreate();  // line used once

// rest of the time we're just using mymap[ key ]

Also, MapCreate() could have prefix like gfx or Str functions incase features are expanded in the future. They would all be grouped together.

I thought of writing because you asked for comments.
Is it possible someone exported AFL plugin function and could be causing conflict?

I only used it for a few tests, nothing significant and easily solvable if you change it; I agree with @nsm51 that using "map" as a prefix for potentially related functions in the future may be a good reason for the change.


Yes, that is the plan that MapXXX would be all map related functions, the same as Str and Mx prefixes.


I use Map in a limited capacity, changing to MapCreate would not be an issue for me. Please support static maps as well @Tomasz. Not being shareable via static is what's keeping me from using maps more. StaticVarSet simply returned 0 for Maps when I tried.

1 Like

We want to pass Map (DICT) from main code to CBT and want to get multiple Types of data in one pass by single variable like DICT.

DICT 			= Map();						//Map Initialiazation
DICT["PRICE"]	= Close;						//Store array in Key 'PRICE'
DICT["STRING"]	= "NIFTY25JUN209500PE.NFO";		//Store string in Key 'STRING'

StaticVarSet("MY_DICTIONARY"+ Name(), DICT);

//ERROR: 'Type unsupported for static variables!'

//We want to pass all as above (DICT) from main code to CBT and 
//want to get multiple types of data in one pass by single variable like DICT.
//While we can pass all these variables by different static variables which make my code heavy to process.
//Is there a way to pass map from main code to CBT, if not then is it possible to make this happen in future.

First "we want" is not appropriate way to ask somebody to do something for you.

Secondly, the map type already supports multiple data types for map elements.

What is NOT supported at the moment is passing maps to StaticVarSet because StaticVarSet function was NOT updated at the moment to accept maps.

Also please note that passing multiple values by StaticVarSet is NOT "heavy". StaticVarSet is fast.

If you imagine that packing everything into map and then calling StaticVarSet for that map would be any faster - you are mistaken.

It will likely to be slower (or at best the same) because of extra overhead caused by unpacking and serializing map is actually same or greater than storing same information in separate static variables. Map is essentially a set of variables inside because each key/value pair works like a single variable. There is no absolutely no performance benefit from map. In fact map is likely to be slower than multiple variables holding the same information due to the way how code optimization works. The only reason for existence for maps is not performance, but simplicity of expression and packaging/grouping variables referring to some single idea into some object-like entity for reasons of better readability/code simplicity.

Maps are NOT for performance. Maps are syntactic sugar. Don't offer any performance benefits.