# Support additional brackets

**URL:** <https://discourse.julialang.org/t/support-additional-brackets/11817>\
**Category:** Internals & Design\
**Tags:** question\
**Created:** [June 20, 2018, 11:06am UTC](https://discourse.julialang.org/t/support-additional-brackets/11817 "2018-06-20T11:06:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![innerlee](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@innerlee](https://discourse.julialang.org/u/innerlee)\
**Post date:** [June 20, 2018, 11:06am UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/1 "2018-06-20T11:06:02Z")

</div>

Is it possible to support extra braces? Like, convert `⟨a, b⟩` to `angle(a, b)`, `⌊x⌋` to `floor(Int, x)`, and `⌈x⌉` to `ceil(Int, x)`.

If the change is not difficult, I can make a pr 😛

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 20, 2018, 11:39am UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/2 "2018-06-20T11:39:09Z")

</div>

It’s certainly possible, and there was a draft PR at one point, but the implementation didn’t get a consensus at that time for various reasons: [https://github.com/JuliaLang/julia/issues/7128](https://github.com/JuliaLang/julia/issues/7128)

---

<div class="post-metadata">

**Author:** ![innerlee](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@innerlee](https://discourse.julialang.org/u/innerlee)\
**Post date:** [June 20, 2018, 1:02pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/3 "2018-06-20T13:02:45Z")

</div>

There were too much things in that pr. I want to modify it into a simpler version. Just convert `⟨⟩`, `⌊⌋` and `⌈⌉` into function calls.

Here is the plan:

- `f⟨bla, blah⟩` is not considered because I only want brackets.
- `⟦ ⟧` is not implemented because it has the potential to support `f⟦bla, blah⟧`.
- `❮❯` and `⟪⟫` are not implemented because I cannot find their LaTeX names.
- `⟨⟩`, `⌊⌋` and `⌈⌉` are not translated into macro calls for simplicity.

link to pr: [https://github.com/JuliaLang/julia/pull/8892](https://github.com/JuliaLang/julia/pull/8892)

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 20, 2018, 3:23pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/4 "2018-06-20T15:23:34Z")

</div>

While you’re at it, is it completely impossible to have `|x|` as `abs(x)`?

---

<div class="post-metadata">

**Author:** ![innerlee](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@innerlee](https://discourse.julialang.org/u/innerlee)\
**Post date:** [June 20, 2018, 3:59pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/5 "2018-06-20T15:59:51Z")

</div>

`|` is bitwise or

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 20, 2018, 4:12pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/6 "2018-06-20T16:12:22Z")

</div>

You could have `‖x‖` for `norm(x)`, which gives `abs(x)` for scalars, where `‖` is U+2016 (`\Vert`).

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 20, 2018, 4:31pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/7 "2018-06-20T16:31:17Z")

</div>

(for julia 0.7?)

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [June 20, 2018, 4:33pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/8 "2018-06-20T16:33:08Z")

</div>

I definitely agree it would be really nice to have more brackets.

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [June 20, 2018, 4:36pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/9 "2018-06-20T16:36:20Z")

</div>

Welcome to cryptic Julia!! I was never impressed by using unicode in Julia, nothing is more readable than plain text. If I say `alpha`, why should I write `α`? It just adds to line noise. [See how people criticize this on Quora](https://www.quora.com/Will-Julia-eventually-replace-Python/answer/Max-Fischer-10), for example. IMHO, `angle(a, b)` is way more readable than `⟨a, b⟩`.

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [June 20, 2018, 4:45pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/10 "2018-06-20T16:45:00Z")

</div>

> [@Seif\_Shebl](#):
>
> nothing is more readable than plain text

I absolutely, emphatically disagree with this. If this were true, math and physics papers would be entirely in plain text. They [evolved to look the way they do in order to be readable](https://en.wikipedia.org/wiki/History_of_mathematical_notation).

> [@Seif\_Shebl](#):
>
> If I say `alpha` , why should I write `α` ? It just adds to line noise.

So, 5 characters is less line noise than 1 character?

---

<div class="post-metadata">

**Author:** ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)\
**Post date:** [June 20, 2018, 5:11pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/11 "2018-06-20T17:11:37Z")

</div>

> [@Seif\_Shebl](#):
>
> nothing is more readable than plain text.

Thankfully, Julia doesn’t force you to use unicode.

> [@Seif\_Shebl](#):
>
> If I say `alpha` , why should I write `α` ?

I say “tee”, but write “t”, what’s the difference?

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [June 20, 2018, 5:23pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/12 "2018-06-20T17:23:19Z")

</div>

Math and physics papers are written like this because we, humans, understand the following formula at a glance:

\zeta = \frac{\left|\ln\left(\frac{P\_0}{100}\right)\right|}{\sqrt{\pi^2+\ln^2\left(\frac{P\_0}{100}\right)}}

If a whole formula like this can be parsed and executed correctly, that’s a dream!

To write `α`, you actually need 7 strokes `\alpha+tab` instead of 5, and on a low resolution screen one may find `α` not very distinct from `a`. Besides, we don’t expect people to hold a PhD in Mathematics to decipher our code (think about weird symbols sometimes used in math). Julia deserves a universal place as a general purpose language, and not only a language for mathematicians and the like. Of course you can choose your own style and no one forces you otherwise, but IMHO, this is not the recommended style of writing code.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 20, 2018, 5:41pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/13 "2018-06-20T17:41:46Z")

</div>

I see your point, but consider that only a fraction of the variables in any chunk of code are going to be `α`s. Most of them will always be your good old `a`s and `x`s… What’s freaking awesome is that the part of the code that represents actual formulas can be coded exactly like that. That surly makes it more readable.

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [June 20, 2018, 5:43pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/14 "2018-06-20T17:43:38Z")

</div>

> [@Seif\_Shebl](#):
>
> Math and physics papers are written like this because we, humans, understand the following formula at a glance:

Ok, so isn’t it nice to be able to do

```julia
ζ = abs(log(P₀/100))/√(π^2 + log(P₀/100)^2)

```

Are you really arguing that this is a perfectly understandable formula, but that you’d be better off using all ASCII for the code? Is it hard to get this to parse correctly?

> [@Seif\_Shebl](#):
>
> To write `α` , you actually need 7 strokes `\alpha+tab` instead of 5

If that really bothers you so much that you don’t find it worth it, than don’t do it. (By the way, on many editors you don’t need the tab, so it’s only 6 strokes in addition to the usual space.)

> [@Seif\_Shebl](#):
>
> Besides, we don’t expect people to hold a PhD in Mathematics to decipher our code

I pray that it doesn’t require a PhD in mathematics to read a Greek letter. If that’s the case, we’re going to be in very big trouble indeed.

Anyway, this is getting quite off point. Having a few extra delimiters, while they probably shouldn’t be abused, might really common in handy in some cases where you need to repeat a function very often. I agree that, for example, it might be dangerous to have tons of different variations on `\langle` brackets, because it may be hard to distinguish them, but picking the most common ones and going with them seems like a safe approach.

---

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [June 20, 2018, 5:43pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/15 "2018-06-20T17:43:45Z")

</div>

Its still 5 strokes. \alp hold tab.

---

<div class="post-metadata">

**Author:** ![innerlee](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@innerlee](https://discourse.julialang.org/u/innerlee)\
**Post date:** [June 20, 2018, 7:29pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/16 "2018-06-20T19:29:51Z")

</div>

Okay, pr submitted. [https://github.com/JuliaLang/julia/pull/27697](https://github.com/JuliaLang/julia/pull/27697)

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [June 20, 2018, 9:42pm UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/17 "2018-06-20T21:42:49Z")

</div>

> [@ExpandingMan](#):
>
> If this were true, math and physics papers would be entirely in plain text. They [evolved to look the way they do in order to be readable](https://en.wikipedia.org/wiki/History_of_mathematical_notation)

It’s basically a symbolic jargon, which also evolves in specialized fields to make things easier to express _within_ the field, but which do the opposite outside of that targeted audience.

One only has to look at how the same operator can be used for entirely different things in math papers vs. physics papers vs. engineering to see how many times using those operators can be problematic when there is any overlap in the audiences.

---

<div class="post-metadata">

**Author:** ![innerlee](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@innerlee](https://discourse.julialang.org/u/innerlee)\
**Post date:** [June 21, 2018, 1:18am UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/18 "2018-06-21T01:18:54Z")

</div>

I will play around the bra and kets (ref [A Qubit DSL? - #26 by ExpandingMan](https://discourse.julialang.org/t/a-qubit-dsl/8599/26)) a little bit to see if it is feasible.

---

<div class="post-metadata">

**Author:** ![Liso](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@Liso](https://discourse.julialang.org/u/Liso)\
**Post date:** [June 21, 2018, 2:59am UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/19 "2018-06-21T02:59:14Z")

</div>

> [@ScottPJones](#):
>
> It’s basically a symbolic jargon, which also evolves in specialized fields to make things easier to express _within_ the field, but which do the opposite outside of that targeted auSdience.

What I see as good point for Julia! 🙂 (to be able to work better in specialized fields)

> [@ScottPJones](#):
>
> One only has to look at how the same operator can be used for entirely different things in math papers vs. physics papers vs. engineering to see how many times using those operators can be problematic when there is any overlap in the audiences.

Using words instead of symbols would bring same confusion, wouldn’t it?

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [June 21, 2018, 3:09am UTC](https://discourse.julialang.org/t/support-additional-brackets/11817/20 "2018-06-21T03:09:32Z")

</div>

> [@Liso](#):
>
> Using words instead of symbols would bring same confusion, wouldn’t it?

When somebody from outside a particular field sees a symbol which means something specific in that field, how easy is it for them to discover the meaning?  
It’s not easy to Google some funny Unicode character or sequence, or to get help at the REPL.

If I see `inner_product(a, b)`, I’d have a good idea what that means, but with some obscure symbol?

While there is some overlap with words, I think it’s less than with some of the symbols.

[Next page](https://discourse.julialang.org/t/support-additional-brackets/11817.md?page=2)
