Ada-Rapporteur-Group / User-Community-Input

Ada User Community Input Working Group - Github Mirror Prototype
26 stars 1 forks source link

Pattern Matching comments. #56

Closed Blady-Com closed 1 year ago

Blady-Com commented 1 year ago

Here are some comments on Rigorous Pattern Matching as a Language Feature: 2.2 Proposed Pattern Matching Syntax

simple_pattern ::=
[identifier :] unlabeled_pattern
| <identifier>

might be

simple_pattern ::=
[<identifier> :] unlabeled_pattern
| <identifier>

in oder to have a same syntaxe in both cases, for instance : <Val>:(0 .. 100 with mod 2 => 0, mod 3 => 1)

unlabeled_pattern ::=
<>
| static_expression
| static_range
| subtype_mark
| property_pattern
| sequence_pattern
| map_pattern

might be

unlabeled_pattern ::=
<>
| static_expression
| static_range
| subtype_mark
| property_pattern
| sequence_pattern
| map_pattern
| [not] null

in order to match accesses for instance:

case Panel, Button is
  when not null, not null => Panel.Toggle (Button);
  when not null, null => Panel.Create (Button);
  when others => raise GUI_Error;
end case;
sequence_pattern ::=
[ pattern [*|+]{,
pattern [*|+]} [, others => pattern] ]

might be

sequence_pattern ::=
[ pattern [*|+]{,
pattern [*|+]} [, others => pattern [+]] ]

in order to specify that the others part shall match at least once for instance: [’0’, ’x’ | ’X’, others => ’0’..’9’ | ’a’ .. ’f’ | ’A’ .. ’F’ +]

sttaft commented 1 year ago

Thank you for the comments! I have copied your comment to Issue #34 on Pattern Matching as an Ada Language Feature to avoid splitting the discussion on pattern matching between two issues. Please continue the discussion there.

ARG-Editor commented 1 year ago

I've closed this issue to further discourage commenting on it, as well as marked it as a duplicate.