[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tail call elimination

From: Daniel Herring
Subject: Re: Tail call elimination
Date: Wed, 20 May 2020 14:12:27 -0400
User-agent: Alpine 2.21 (DEB 202 2017-01-01)

On Wed, 20 May 2020, Paul Smith wrote:

Grouping: do we try to implement expression grouping with () (e.g.,
$(expr (1 + 1) * 4) or is it good enough to just say people need to
nest expr functions: $(expr $(expr 1 + 1) * 4)?

I think nesting `expr` is too noisy.

We need to find a good balance between implementation complexity and
"noisy use".

Both a Lisp-like prefix syntax and a Forth/RPN-like postfix syntax are concise and easy to implement. Infix semantics are messy, because they require special "order of operations" logic to resolve ambiguities, and there is no universal standard for that.

The above example would look something like the following.

Prefix:  $(* $(+ 1 1) 4)

Postfix: $(rpn 1 1 + 4 *)

If you do choose to use infix with a function named expr, then I recommend following the expr man page exactly. Since expr is part of GNU coreutils, you might even be able to re-use much of the code.

- Daniel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]