News for hackers. Stuff that matters.
Re:We need to talk about parentheses by alexisread on Monday February 12, 2024 @03:14PM (#39349824)
I've often wondered if it was worth a language having interchangeable brackets that you could use similar to 4-colour problems eg. ([1 2] 3) is the same as {[1 2] 3} or ((1 2) 3) semantically, just visually easier to read.

Any takers?

Re:We need to talk about parentheses by adrian_b on Monday February 12, 2024 @03:32PM (#39350072)
This is more or less like the traditional use of parentheses, square brackets and curly brackets in English texts, where they had the same meaning but they were used for different levels of nested brackets.

IIRC, I have seen once an experimental language which worked exactly like in your proposal, but it was long ago and I do not remember which was it.

One LISP system that I have used long ago had a different approach. In it, one closing square bracket could be used to close all non-closed parentheses preceding it.

Re:We need to talk about parentheses by lispm on Tuesday February 13, 2024 @02:01AM (#39355297)
> One LISP system that I have used long ago had a different approach. In it, one closing square bracket could be used to close all non-closed parentheses preceding it.

That was Interlisp, originally making handling of punch cards easier. Nowadays it's not necessary, since the 70s/80s text editors on terminals support handling nested expressions.

Re:We need to talk about parentheses by joseluis on Tuesday February 13, 2024 @09:21AM (#39357843)
Rust macros can be used like that:

let hello = dbg!{ dbg![ dbg!("world") ] };

Re:We need to talk about parentheses by IanCal on Monday February 12, 2024 @03:34PM (#39350097)
We have ides with different colours for different layers of brackets, and we have them with rendering different characters (>= etc).

So it feels like this could be a reasonable plugin?

Re:We need to talk about parentheses by Gibbon1 on Monday February 12, 2024 @03:58PM (#39350400)
You could have three slightly different brackets, one for each level of nesting. And when you get to four that's it. More than that is illegal.
Re:We need to talk about parentheses by mikhayahu on Monday February 12, 2024 @05:30PM (#39351420)
Racket works this way.