You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
casting something into a list returns unexpected behaviours:
list("few words");
returns an empty list instead of a list containing the string "few words" or the list of characters that compose it.
Even stranger is:
list([1::2]);
this expression returns [2], which to me is the least obvious result, it could be either [1,2] or [1::2] but a list containing only 2 makes no sense from the user's point of view (though I understand it's the pair's value).
What is even stranger is that:
list(pair(1::2));
returns [1::2], why do we have to explicitly cast the pair into a pair while it's declared with a literal ?
The text was updated successfully, but these errors were encountered:
I've addressed the issue with strings (it was a mistake on a tokenizer). It now correctly returns the list of characters (i.e. ["f", "e",...])
The problem comes from the fact that, by default, a map returns its list of values when casted to a list. And [1::2] is a map, not a pair. If you write list(1::2) instead, it will return: [1,2]. Better not to change this behavior, as iterations on maps values rely on it !
Ok, waiting for your commit to close then.
The second point makes me think that we may need to have stricter rules to define list/map (and others?) literals in GAMA 2 then, so [] would be strictly for list and {} strictly for maps for example. So as to avoid that kind of confusion (at least it would print a warning that it's going to be casted)
Describe the bug
casting something into a list returns unexpected behaviours:
returns an empty list instead of a list containing the string "few words" or the list of characters that compose it.
Even stranger is:
this expression returns
[2]
, which to me is the least obvious result, it could be either[1,2]
or[1::2]
but a list containing only 2 makes no sense from the user's point of view (though I understand it's the pair's value).What is even stranger is that:
returns
[1::2]
, why do we have to explicitly cast the pair into a pair while it's declared with a literal ?The text was updated successfully, but these errors were encountered: