23
$\begingroup$

My esolang involves the use of balanced brackets (){}[]<> to denote different scopes. However, unlike practical languages, all pairs of identical brackets denote the same scope:

(a=1,b=2)
<a=10,b=20>
{j=5,k=6}
(c=a+b) # c=3, because in the () scope, a=1 and b=2

I want to give users more than 4 scopes, through Unicode bracket characters.

What Unicode bracket characters are there that are mirrors of each other, like (){}[]<>?

$\endgroup$
2
  • $\begingroup$ Off-topic: out of curiosity, how do scopes connect? If not, aren't they just different code/functions/programs interwoven? $\endgroup$
    – Pablo H
    Jul 18 at 11:51
  • $\begingroup$ @PabloH The esolang was made as a 5-minute example for this question, but if it were ever implemented there'd probably be some mechanism to interface between scopes. $\endgroup$
    – bigyihsuan
    Jul 18 at 13:06

5 Answers 5

15
$\begingroup$

Matching delimiters in Unicode are defined according to their general category:

GC General Category Number of Code Points
Ps punctuation, open 79†
Pe punctuation, close 77
Pi punctuation, initial quote 12‡
Pf punctuation, final quote 10

 † 77 plus low-9 quotation marks ‡ 10 plus high-9 quotation marks

Conveniently, Unicode handles matching brackets explicitly, because the Unicode Bidirectional Algorithm needs to ensure they work properly in different script orientations. The official listings are in the Unicode database; BidiBrackets.txt lists the bracket characters, and BidiMirroring.txt gives the mirrored pairs:

This data file lists characters that have the Bidi_Mirrored=Yes property value, for which there is another Unicode character that typically has a glyph that is the mirror image of the original character's glyph.

Vertical presentation forms can be cross-referenced in VerticalOrientation.txt if you want to exclude those. The quotation marks (Pi & Pf) are also paired nearly 1:1; in normal text, it depends on locale whether they should be considered opening or closing, although programming languages are usually locale-insensitive.

$\endgroup$
24
$\begingroup$

Xah Lee has a comprehensive list:

Western quotation “ ” ‘ ’ ‹ › « »
Low-9 quotation „ ‚
Full width brackets ( ) [ ] { } ⦅ ⦆
White variants ⦅ ⦆ 〚 〛 ⦃ ⦄
Asian 「 」 〈 〉 《 》 【 】 〔 〕 ⦗ ⦘
Asian white variant 『 』 〖 〗 〘 〙
Half width variant 「 」
Math ⟦ ⟧ ⟨ ⟩ ⟪ ⟫ ⟮ ⟯ ⟬ ⟭ ⌈ ⌉ ⌊ ⌋ ⦇ ⦈ ⦉ ⦊
Decorative ❛ ❜ ❝ ❞ ❨ ❩ ❪ ❫ ❴ ❵ ❬ ❭ ❮ ❯ ❰ ❱ ❲ ❳
Arabic ornate parenthesis. (You need Arabic font) ﴾ ﴿
More angle brackets 〈 〉 ⦑ ⦒ ⧼ ⧽
Small variants ﹙ ﹚ ﹛ ﹜ ﹝ ﹞
superscript, subscript variants ⁽ ⁾ ₍ ₎
Square bracket variants ⦋ ⦌ ⦍ ⦎ ⦏ ⦐ ⁅ ⁆
⸢ ⸣ ⸤ ⸥
Misc brackets ⟅ ⟆ ⦓ ⦔ ⦕ ⦖ ⸦ ⸧ ⸨ ⸩ ⧘ ⧙ ⧚ ⧛
Paraphrase ⸜ ⸝ Omission ⸌ ⸍ Substitution ⸂ ⸃ ⸄ ⸅ Transposition ⸉ ⸊
᚛ ᚜ ༺ ༻ ༼ ༽
Vertical Brackets
Vertical ⏜ ⏝ ⎴ ⎵ ⏞ ⏟ ⏠ ⏡
Vertical representation form ﹁ ﹂ ﹃ ﹄ ︹ ︺ ︻ ︼ ︗ ︘ ︿ ﹀ ︽ ︾ ﹇ ﹈ ︷ ︸

$\endgroup$
0
11
$\begingroup$

Also you can use double brackets.

Like this (like HTML/XML comments):

<- ... ->

Or this (like in Jinja):

{{ ... }}

Or this (in Jinja too):

{% ... %}
$\endgroup$
2
$\begingroup$

Here are a few (not a complete list):

  • Single angled brackets: ‹› (U+2039, U+203A)
  • Double angled brackets: «» (U+00AB, U+00BB)
  • Superscript parentheses: ⁽⁾ (U+207D, U+207E)
  • Subscript parentheses: ₍₎ (U+208D, U+208E)
  • Angled bracket: 〈〉 (U+2329, U+232A)
  • Bold parentheses: ❪❫ (U+276A, U+276B)
  • Bold angled brackets: ❮❯ (U+276E, U+276F)
  • Bold curly brackets: ❴❵ (U+2774, U+2775)
  • Full width parentheses: () (U+FF08, U+FF09)
  • Full width square brackets: [] (U+FF3B, U+FF3D)
  • Full width curly brackets: {} (U+FF5B, U+FF5D)

Feel free to edit in more.

$\endgroup$
1
$\begingroup$

Triple-brackets for GPU computing with CUDA

The webpages provided in the answer by Jon Purdy and in the answer by Adám together provide a huge list of single-character delimiters, but after seeing the answer by nchistov which gives examples of "two-character delimiters" like <- [...] -> in HTML and {% [...] %} in Jinja, I'll go one step further and give an example of a "three-character delimiter" which is used a lot when programming for GPUs.

In CUDA, the "triple angle brackets" are used to make a call from a "host" (such as the main computer) to a "device" (such as one of the computer's GPUs). An example of this can be seen in line 2 of the following "Hello World" code:

int main( void ) {
    kernel<<< 1, 1 >>>();
    printf( "Hello, World!\n" );
    return 0;
}

The numbers beween the triple angle brackets are the number of blocks per grid, and the number of threads per block (in that order), so in the above code, since all we were doing was "Hello World", it was a "single-threaded" operation with 1 thread per block and 1 block per grid, but if we wanted to make full use of the GPU by doing a "multi-threaded" operation, for example if we have the following:

add<<< 256, 1>>>() 

instead of running the add() function once, on a single-thread, we will have 256 copies of the kernel running in parallel.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .