Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add proposal to codify rules on matching brackets
All matched delimiters to should be determined by their
Unicode properties. I propose two simple rules to adopt
for uniformity, elegance and clarity.
  • Loading branch information
samcv committed Dec 17, 2016
1 parent 556410a commit 61e3e6c
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions v6d.pod
Expand Up @@ -8,8 +8,8 @@ Plans for Perl 6 version 6.d

Created: 09 Aug 2016

Last Modified: 09 Aug 2016
Version: 2
Last Modified: 16 Dec 2016
Version: 3

This documents contains planned changes for v6.d, and who wants to do them.

Expand Down Expand Up @@ -70,5 +70,54 @@ Examples of this happening have showed up in the past.

Jonathan Worthington

=head1 Formal Rules for Defining Matched Delimiters/Brackets

In v6.d we should formalize which brackets we support.
How do we decide which delimiters should be added on future updates
to the Unicode standard? We should look to the Unicode standard to help
us define matching delimiters and brackets for Perl 6.

All delimiters we support should conform to two simple rules for the sake of
uniformity, elegance and clairity.

=head2 Rules

B<1.> Delimiter's Unicode General_Category must match one of these:
+ Pi -> Pf ( Punctuation, initial quote -> Punctuation, final quote)
+ Ps -> Pe (Punctuation, start -> Punctuation, end)

B<2.> Are matched as either BidiBrackets or as BidiMirroring characters.

Bidirectional brackets are specified
L<here|http://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt>

Non brackets have their matching glyph specified in this
L<file|http://www.unicode.org/Public/UCD/latest/ucd/BidiMirroring.txt>

=head2 Possible issues

The only possible issue, is what to do with ornate parens.

B<BidiBrackets.txt> states:

“For legacy reasons, the characters U+FD3E ORNATE LEFT PARENTHESIS and
U+FD3F ORNATE RIGHT PARENTHESIS do not mirror in bidirectional display
and therefore B<do not form a bracket pair.>”

In v6.c, roast includes tests for 'ornate left parens' and 'ornate right parens'
for doing things like q[ ] type contructs and such. I think that we should not
allow these parenthesis because firstly, Unicode states they do not form a matching pair
of brackets. Secondly, the ornate parenthesis also do not have mirror glyphs.
To make matters even worse, their Unicode general categories are the opposite of every
matched bracket we support, the opening brackets tested for in v6.c open with
"Pe"(End) and close with is "Ps"(Start).
They break both of these proposed rules.

In practice this is already implement with the exception of the ornate parenthesis,
but I propose this be made an official part of the Perl 6 standard.

=head2 Stakeholder

Samantha McVey (samcv)

=cut

0 comments on commit 61e3e6c

Please sign in to comment.