[fpc-devel] Ability to handle instance pointers as ordinal type.

Martin fpc at mfriebe.de
Sun Feb 21 16:09:35 CET 2016

On 21/02/2016 11:15, Sven Barth wrote:
> Would it be possible to implement? Yes
> Would that mean that instance pointers would be handled as ordinal 
> values? No, because "case" is merely a parser construct. In principle 
> the condition and the case labels could be anything. String constants 
> aren't ordinal values after all either.
> It might look logical but it would be a complete paradigm shift for 
> case-statements, because the case labels are supposed to be constant 
> values (ordinal, including enums and string constants) while variables 
> (local, global, fields) are not constants however.
And there lies the problem.

Case labels do not allow duplicates. But if they are variables, then 
this can not be checked at compile time.
So this must either throw an exception, or add/change the evaluation of 
the "case" to have a precedence between the "labels", and decide if only 
the first or all matches are executed.

> 1.
>     procedure TFrame00.ComboBoxChanged(Sender: TObject);
> 2.
>     begin
> 3.
>     If Sender Is TComboBox Then
> 4.
>     case TCombobox(sender) of
> 5.
>     Combobox1:;
> 6.
>     ComboBox2:;
> 7.
>     ComboBox3:;
> 8.
>     end;
> 9.
>     end;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160221/60b50dec/attachment.html>

More information about the fpc-devel mailing list