[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.programming

Eliding parens

luserXtrog

1/9/2015 5:35:00 PM

My investigations of the roots of algebraic/polish syntaxes
has led me to two papers from the 60s which describe three
systems of parenthesizing algebraic expressions.
http://www.mt-archive.info/Oettinge...
http://mt-archive.info/IFIP-1965-Oet...

The one we know and love is the "fully-parenthesized" form.
But apparently you can also just ignore half of them and
only consider the left- or right- hand braces.

Which leads me to imagine a hybrid system where certain
redundant parens may be omitted, particularly ones on the
edge of the expression.

eg.
(x+y)*z+(w/t)
could be
x+y)*z+(w/t

For lisp-type languages, this would mean never having to
count parens in order to close everything. It's just extra
redundant book-keeping.

amiright?
3 Answers

Mark Carroll

1/9/2015 5:40:00 PM

0

luser droog <mijoryx@yahoo.com> writes:

> For lisp-type languages, this would mean never having to
> count parens in order to close everything. It's just extra
> redundant book-keeping.

True, but with a decent IDE one doesn't really have to count them
anyway: closing one makes it clear which opening one is thus being
closed, and auto-indent is extra help / confirmation. This is very
much why one doesn't write Lisp using Notepad. (-:

-- Mark

Kaz Kylheku

1/9/2015 6:51:00 PM

0

On 2015-01-09, luser droog <mijoryx@yahoo.com> wrote:
> For lisp-type languages, this would mean never having to
> count parens in order to close everything.

Historically, there existed in some Lisp dialects a "super bracket".

That is to say, you can have a hierarchy of parentheses with different powers.

We can illustrate this with two levels: the regular parentheses () and
the super parentheses []:

[defun foo (x)
(if (> x 1) "greater than one"]

The ] parenthesis closes all the open ( parentheses up to the previous matching
[ parenthesis. There is no counting of outstanding ( parentheses required on
the part of the coder.

Now you could make it so that you only have one kind of parenthesis, and the
language simply doesn't care about unbalanced parentheses. But that makes it
difficult to find errors in programs.

If you write a function and do not close it, then subsequent functions are
being defined inside that function. The source file then ends and there is no
diagnostic.

Sjouke Burry

1/9/2015 9:04:00 PM

0

On 09.01.15 18:35, luser droog wrote:
> My investigations of the roots of algebraic/polish syntaxes
> has led me to two papers from the 60s which describe three
> systems of parenthesizing algebraic expressions.
> http://www.mt-archive.info/Oettinge...
> http://mt-archive.info/IFIP-1965-Oet...
>
> The one we know and love is the "fully-parenthesized" form.
> But apparently you can also just ignore half of them and
> only consider the left- or right- hand braces.
>
> Which leads me to imagine a hybrid system where certain
> redundant parens may be omitted, particularly ones on the
> edge of the expression.
>
> eg.
> (x+y)*z+(w/t)
> could be
> x+y)*z+(w/t
>
> For lisp-type languages, this would mean never having to
> count parens in order to close everything. It's just extra
> redundant book-keeping.
>
> amiright?
>
No.
Just lazy.