3 ms·
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
by alexisread 3y ago
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?
- adrian_b 3y agoThis 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.
- lispm 3y ago> 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.
- joseluis 3y agoRust macros can be used like that: let hello = dbg!{ dbg![ dbg!("world") ] };
- IanCal 3y agoWe 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?
- Gibbon1 3y agoYou could have three slightly different brackets, one for each level of nesting. And when you get to four that's it. More than three is illegal. Edit: Or you could use markup to make the text size smaller and smaller.
- mikhayahu 3y agoRacket works this way.