frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Inverse Parentheses

https://kellett.im/a/inverse-parentheses
40•mighty-fine•2h ago

Comments

tromp•1h ago
Using Brave on MacOS, I cannot scroll the page to see the entire text. On Firefox, it scrolls fine.
guessmyname•1h ago
Same in Safari. It has something to do with the

  :root {
    […]
    overflow: hidden scroll;
    container-type: size;
    […]
  }
in the main CSS file: https://kellett.im/theme/main.css
auggierose•1h ago
Cannot scroll on Safari on macOS, either. What also doesn't work is making the font smaller / larger.
TerraHertz•1h ago
Splendid. Someone found a way to break Browser Scrolling. (Firefox 115.16 for Win7)

Well done.

bananaflag•1h ago
> Have you ever noticed that lots of programming languages let you use parentheses to group operands, but none use them to ungroup them?

Since this doesn't exist in practice, shouldn't the article author first explain what they mean by that?

Smaug123•1h ago
The examples at the end show that it's syntax for "parse such that this expression is not grouped". Essentially I guess this could be modelled as an operator `(_+_)` for every existing operator `_+_`, which has its binding precedence negated.
pxeger1•1h ago
I don't understand
carderne•1h ago
I was hoping the parentheses themselves would be flipped. Like this:

> 1 + )2 * 3(

(1 + 2) * 3

dgoldstein0•1h ago
Same.

That said if you try to use that with ordinary parentheses usage it would get ambiguous as soon as you nest them

AmbroseBierce•1h ago
I think surrounding the operand would make slightly more sense, as in 1 + 2 (*) 3 as if it's a "delayed form" of the operation that it represents.
SyzygyRhythm•7m ago
If you do both (use flipped parentheses around the operators), it makes even more sense, and makes the parsing trivial to boot: just surround the entire expression with parentheses and parse normally. For instance: 1 + 2 )( 3 Becomes (1 + 2 )( 3) Which is actually just what the author wants. You might even want multiple, or an arbitrary numbers of external parentheses. Say we want to give the divide the least precedence, the multiply the middle, and the add the most. We could do that like: 1 + 2 )/( 3 ))(( 4 Surround it with two sets of parens and you have: ((1 + 2 )/( 3 ))(( 4)) I haven't just proved to myself this always does what you expect, though...
louthy•1h ago
I'm all for terseness in blog writing, but I think the author forgot to add the content. I know nothing more than I did when I opened it.
brabel•31m ago
And yet, this is the top entry on HN right now?! How does that happen??
TeodorDyakov•1h ago
Where do stars live? Thats what I wonder.
HansP958•1h ago
The concept of "inverse parentheses" that unbundle operators is brilliant! The tokenizer hack (friendliness score by parenthesis depth, inspired by Python INDENT/DEDENT) + precedence climbing for infinite levels is elegant – parsing solved without convoluted recursive grammar. kellett

I love the twist: reversing the friendly levels gives you a classic parser, and it opens up crazy experiments like whitespace weakening. Have you tested it on non-arithmetic ops (logical/bitwise) or more complex expressions like ((()))?

istjohn•1h ago
It's not just brilliant, it's earth-shattering.
Philpax•1h ago
Echoing the sentiment that I'm not really sure what I'm meant to be looking at here. A motivating example at the start would have helped, I think.
ChanderG•1h ago
Opened this excitedly, thinking I was going to get something related to S-expressions/Lisp, was disappointed...
qsort•1h ago
Am I stupid if I don't get it? What is the intended end state? What does "ungroup operands" mean?
jojobas•1h ago
I'm not sure I'm following but I think what he means is that if normal parenthesis around an addition mean this addition must precede multiplication, these anti-parenthesis around a multiplication have to make addition take place before it.
ofalkaed•1h ago
Parenthesis used to decrease precedence? Everything outside of the parenthesis will be done before what is in the parenthesis?
TrianguloY•1h ago
Based on this comment (https://news.ycombinator.com/item?id=46352389), I think I understood the missing first paragraph:

If you have the expression 1+2*3 you have three elements with two operands. You need to choose a rule to pick one of them first.

In mathematics, the rule is "*/ then +-" and then from left to right. This means that usually first you do 2*3, then 1+.

But what if you do want to make 1+2 first?

There is another alternative, parenthesis. Those mean "do the thing inside first" so (1+2)*3 changes the precedence and now you do 1+2 first, then *3

The post is asking: with parenthesis you can increase the precedence of operations. What if you could decrease it?

Let's use «» as another operand (the blog uses parenthesis, but that makes it really confusing) this operand means "do the thing inside last". So the expression 1+«2*3» means "do 1+ first, then 2*3.

The issue is...this doesn't make sense, what the blog is really saying is to reduce the precedence of operators. Think the expression 1+2«*»3 or 1+2(*)3 and now the rule is "the parenthesized operators have one precedence less" so 1+2(*)3=(1+2)*3

integricho•59m ago
Thanks, this makes more sense, the blog post was written in a really confusing way.
yccs27•50m ago
Thanks, writing it as 1+2(*)3 made it click for me.

Reminds me of the '$' operator in Haskell - it lowers the precedence of function application, basically being an opening parenthesis that's implicitly closed at the end of the line.

sebtron•49m ago
This seems to be the best guess so far. But then I am wondering, how is

    a (*) b + c
Parsed then? The precedence of '* is bumped down, but does that mean it has now strictly lower precedence of '+', or the same? In the first case the operation is parsed as

    a * (b + c)
In the second case, the "left to right" rule takes over and we get

    (a * b) + c
And what happens when there are more than 2 priority groups Taking C has an example, we have that '' has higher precedence than '+' which has higher precedence than '<<' [1]. So

    a + b * c << d
Means

    (a + (b * c)) << d
Now I could use the "decrease precedence" operator you proposed (possibly proposed by the author?) and write

    a + b (*) c << d
Which then bumps down the precedence of '
' to... One level lower? Which means the same level of '+', or a level lower, i.e. a new precedence level between '+' and '<<'? Or maybe this operator should end up at the bottom of the precedence rank, i.e. lower than ','?

The more I think about this, the less sense it makes...

[1] https://en.cppreference.com/w/c/language/operator_precedence...

qsort•48m ago
I don't think that's even well-defined if you have arbitrary infix operators with arbitrary precedence and arbitrary associativity (think Haskell). If $, & and @ are operators in that order of precedence, all right-associatve. Using your notation, what is:

  a & << b $ c >> @ d
If $ is reduced below & but above @ then it's the same as:

((a & b) $ c) @ d

If it's reduced below both & and @ then it becomes:

(a & b) $ (c @ d)

I think conceptualizing parentheses as "increase priority" is fundamentally not the correct abstraction, it's school brain in a way. They are a way to specify an arbitrary tree of expressions, and in that sense they're complete.

Smalltalker-80•38m ago
Thanks indeed. Using a simple left-to-right evaluation is the most logical solution. You can reorder expressions to use less parentheses and make them easier to read. E.g.: Smalltalk :-). But this requires everyone un-learning their primary school maths of e.g. multiply-before-add, so it's not popular. Having hand-picked operator precedences complicates things further when you allow operator overloading and user defined operators. E.g. Swift has special keywords to specify precedence for these. Ick...
cubefox•1h ago
Slightly unrelated:

Instead of ordinary brackets, one can also use the dot notation. I think it was used in Principia Mathematica or slightly later:

  (A (B (C D)))
would be

  A . B : C .: D
Essentially, the more dots you add, the stronger the grouping operator is binding. The precedence increases with the number of dots.

However, this is only a replacement for ordinary parentheses, not for these "reverse" ones discussed here. Maybe for reverse, one could use groups of little circles instead of dots: °, °°, °°°, etc.

wvbdmp•54m ago
Regarding the first two footnotes, I’m pretty sure that originally the singular form “parenthesis” just refers to the aside inserted (by use of brackets, like this) into a sentence. Because it sounds like a plural and because of the expression “in parenthesis”, people probably mistakenly applied the word to the pair of symbols, and when that became common, started using the real plural “parentheses”. This has staying power because it’s fancy and “brackets” is way overloaded, but historically it’s probably just wrong and especially nonsensical in math and programming, where we don’t use them to insert little sidenotes.
randyrand•15m ago
The core idea: normally, parentheses strengthen grouping:

1 + (2 * 3) forces 2 * 3 to happen first.

Without them, operator precedence decides. The post asks a deliberately strange question:

What if parentheses did the opposite — instead of grouping things tighter, they made them bind less tightly?

Nevermark•15m ago
I am in the middle of developing a parser for a new language with original representation vs. syntax issues to resolve.

Clearly, this was the worst possible time for me to come across this brain damaging essay.

I really can’t afford it! My mathematical heart can’t help taking symmetrical precedence control seriously. But my gut is experiencing an unpleasant form of vertigo.

cousin_it•15m ago
Is it the same as flipping every parenthesis to the other side of the number it's adjacent to, and then adding enough parentheses at the start and end?

For example,

    (1 + 2) * (3 + 4)
becomes

    1) + (2 * 3) + (4
and then we add the missing parentheses and it becomes

    (1) + (2 * 3) + (4)
which seems to achieve a similar goal and is pretty unambiguous.

Building Formtok to fill up form with voice, need your review please

1•nilooy•4m ago•0 comments

iRobot bankruptcy revealed a new kind of competitor: 'the Chinese fast follower'

https://www.businessinsider.com/irobot-ceo-bankruptcy-china-fast-followers-competition-2025-12
1•mywacaday•5m ago•0 comments

Costco gained a cult following – by breaking every rule of retail (2019)

https://thehustle.co/costco-membership-economics
1•ksec•5m ago•0 comments

Constvector: Log-structured std:vector alternative – 30-40% faster push/pop

https://github.com/tendulkar
1•birdculture•5m ago•0 comments

Books I Enjoyed in 2025

https://borretti.me/article/books-i-enjoyed-in-2025
1•swah•9m ago•0 comments

Systemabsturz – a data protection Electropunk band

https://systemabsturz.band/
1•tcfhgj•10m ago•0 comments

Iatrogenic Slavery

https://unbekoming.substack.com/p/iatrogenic-slavery
1•SanjayMehta•11m ago•0 comments

If You Don't Design Your Career, Someone Else Will

https://gregmckeown.com/if-you-dont-design-your-career-someone-else-will/
1•TheAlchemist•12m ago•0 comments

Plugins case study: mdBook preprocessors

https://eli.thegreenplace.net/2025/plugins-case-study-mdbook-preprocessors/
1•ingve•13m ago•0 comments

N-Queens in Python Packaging

https://github.com/jessekv/nqueens-in-python-packaging
2•jessekv•14m ago•0 comments

Korea develops core tech for 2nd-fastest 370 kph high-speed train

https://www.koreatimes.co.kr/business/tech-science/20251222/korea-develops-core-tech-for-worlds-2...
1•01-_-•18m ago•0 comments

Do you think a browser-extension version of StackShare would be useful?

1•Mr-Mosh•18m ago•0 comments

How to Reclaim Your Mind

https://www.newyorker.com/culture/open-questions/can-you-reclaim-your-mind
2•rbanffy•18m ago•0 comments

Nodebugger: CLI to inspect running Node.js processes via V8 Inspector Protocol

https://github.com/huksley/nodebugger
1•freetonik•19m ago•0 comments

45 quotations for my birthday

https://blog.dougbelshaw.com/45-quotations/
1•dajbelshaw•19m ago•0 comments

Can AI understand design intent, not just aesthetics?

https://picxstudio.com
2•V_Shukla•19m ago•1 comments

Ask HN: Does XML still have any value in creating APIs?

3•01-_-•20m ago•0 comments

A Year of Vibes

https://lucumr.pocoo.org/2025/12/22/a-year-of-vibes/
1•lumpa•20m ago•0 comments

trivium 21dec2025

https://leahneukirchen.org/trivium/2025-12-21
1•swah•21m ago•0 comments

MIT professor Nuno F.G. Loureiro shot and killed in his home

https://fortune.com/2025/12/16/mit-professor-nuno-loureiro-shot-killed-home-brookline-massachusetts/
1•handfuloflight•28m ago•0 comments

Take your disk space back on macOS

https://appsformacs.eu/products/macspaceback
1•simasscores•30m ago•2 comments

Bayesian SSH – New release (1.2.0)

https://github.com/abdoufermat5/bayesian-ssh
1•abdoufermat•31m ago•0 comments

Show HN: Make your own Danish Julehjerter (Braided hearts)

https://juleflet.dk
2•thomasahle•34m ago•0 comments

First Compelling Evidence of "Monster Stars" in the Early Universe

https://www.universetoday.com/articles/astronomers-find-the-first-compelling-evidence-of-monster-...
1•belter•37m ago•0 comments

Mandelbrot, Conway, Pajitnov had success – and I?

https://number-garden.netlify.app/?m
1•cpuXguy•40m ago•1 comments

Well Being in Times of Algorithms

https://www.ssp.sh/blog/well-being-algorithms/
7•articsputnik•41m ago•0 comments

Show HN: I built an AI Christmas photo generator in 24 hours

https://aichristmasphoto.com
1•illyism•44m ago•0 comments

Show HN: Create a custom AI agent from a name and public links in seconds

https://art-of-x.com
1•artofalex•47m ago•0 comments

The Roomba failed because it just kind of sucked

https://www.theregister.com/2025/12/22/irobot_opinion/
1•jjgreen•47m ago•0 comments

Show HN: Request Hunt – Aggregates feature requests from Reddit, GitHub, and X

https://requesthunt.com
1•Zephyr0x•49m ago•1 comments