|ID||Project||Category||View Status||Date Submitted||Last Update|
|0035824||FPC||Compiler||public||2019-07-10 22:26||2019-07-10 22:46|
|Product Version||3.3.1||Product Build||Trunk|
|Target Version||Fixed in Version|
|Summary||0035824: [Feature Request] Extend "for Variable in [Value, Value, Value]" to imply an array when a set would be impossible.|
|Description||FPC has recently seen some very nice extensions to the syntax surroundings arrays, e.g. being able to do things like:|
ArrayVariable := [Value, Value, Value];
However, it still remains that case that when you write:
for Variable in [Value, Value, Value] do Whatever;
"[Value, Value, Value]" is never interpreted as anything other than a set, which restricts it to byte-sized types.
var I: LongInt;
// Works fine.
for I in [2, 12, 16, 17, 255] do WriteLn(I);
// Range check error, as this syntax *always* implies a set,
// and sets are restricted to byte-sized types in all cases.
for I in [2, 12, 16, 17, 259] do WriteLn(I);
If feasible, it would be nice if in any case where a set could not validly represent the given values, that this would essentially amount to an "anonymous array".
This could mean making it basically syntactic sugar for:
"for Variable in ArrayOfType.Create(Value, Value Value)"
or (preferably I suppose) by making it amount instead to a static array constant (since the length is known) if / where possible.
|Tags||No tags attached.|
|Fixed in Revision|