[fpc-devel] Ability to handle instance pointers as ordinal type.
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.
> procedure TFrame00.ComboBoxChanged(Sender: TObject);
> If Sender Is TComboBox Then
> case TCombobox(sender) of
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel