DWIM && )))

Phred on 2006-08-29T06:37:53

Sometimes I wish that when I typed:

my $foo = warn(sum(length($obj->attrs);

that it would just do the right thing with the parentheses and terminate the command at the semi-colon, like if I typed:

my $foo = warn(sum(length($obj->attrs)));

Call me Lazy but it makes sense to me.


The Serious End Brace

chromatic on 2006-08-29T08:36:10

I don't hate:

my $foo = warn(sum(length($obj->attrs];

Re:The Serious End Brace

VSarkiss on 2006-08-29T14:57:09

I guess it's true that language designers end up reinventing Lisp :-). The square "superbracket" was introduced in Interlisp in the mid-60's. You can take a look at Steele and Gabriel's "The Evolution of Lisp" paper.

Re:The Serious End Brace

chromatic on 2006-08-31T09:01:06

I'm a mature poet. I completely and knowingly stole that idea from Lisp.

(Of course, mentioning "poet" in the same context as Dick Gabriel is a good trick for other reasons.)

Use an intelligent editor

Aristotle on 2006-09-03T22:41:46

Shouldn’t be hard to script a reasonably malleable editor to trigger “look for unclosed opening parens within the statement and add the right number of closing ones” whenever you type a paren and semicolon. (Or some other shortcut of your choosing; I like Ctrl-Space and Alt-Space as choices for context-sensitively binding “do some magic here” macros.)

A language-level feature would be nice too, but it would require lots of special little syntax rules for how many parens to close in order to be really useful, and I’m not sure this is a corner of the language that’s worth devoting so much brainspace to. Doing it in the editor has the advantage that you can easily undo some of the fix-up by matching things up visually. (I presuppose that an editor which gives you sufficient programmability for this will also easily highlight matching parens for you.)