[fpc-pascal] For .. in .. loops with sets and valued enums
Bernd Oppolzer
bernd.oppolzer at t-online.de
Sat Jun 20 14:29:04 CEST 2015
Maybe types should be forbidden at this place completely.
Look at this:
1.) with subrg type - works ok !!
program testin;
type subrg = 1..10;
var i: integer;
begin
for i in subrg do begin
writeln (i)
end
end.
2.) with subrg type in in-expression - gives syntax error
program testin;
var i: integer;
begin
for i in 1.. 10 do begin
writeln (i)
end
end.
3.) with set constant in in-expression - works ok
program testin;
var i: integer;
begin
for i in [1.. 10] do begin
writeln (i)
end
end.
Only the 3rd example should be supported, IMO.
Kind regards
Bernd
Am 20.06.2015 um 14:03 schrieb Michael Van Canneyt:
>
>
> On Sat, 20 Jun 2015, Jonas Maebe wrote:
>
>> On 20/06/15 12:01, Michael Van Canneyt wrote:
>>>
>>>
>>> On Sat, 20 Jun 2015, Jonas Maebe wrote:
>>>
>>>> On 20/06/15 11:41, Michael Van Canneyt wrote:
>>>>> But it is a bug that the compiler does not give an error for the set
>>>>> type. Please report it.
>>>>
>>>> Should it work with any set types at all? (I don't mean set variables,
>>>> but set types) Or even with any type? It seems very much like
>>>> something
>>>> that was accidentally introduced, like what was reverted with
>>>> http://wiki.freepascal.org/User_Changes_2.6.0#.3COrdinal.3E_in_.3CSet_type.3E_is_now_forbidden
>>>>
>>>
>>> It should definitely work with sets, that was explicitly asked (I am
>>> sure, because I asked). I use it in my code.
>>
>> Again: set *variables* or set *types*?
>
> Ah sorry, I misunderstood your remark. Variables.
> I don't see the point of allowing it on a set type. You can just as
> well use the underlying enum.
>
> Michael.
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list