LWN.net Logo

Precedence

Precedence

Posted Dec 7, 2012 17:16 UTC (Fri) by david.a.wheeler (guest, #72896)
In reply to: It's a mistake to ignore the customer by etienne
Parent article: GNU Guile 2.0.7 released

Poster said:

Just to add that the main disadvantage of infix is that you have to introduce operator precedence

No you don't. Infix means the operator is between the operands, that's all.

Precedence can a lot of create problems, and the SRFI-105 has a very simple solution: No built-in precedence. You can still have precedence, though. If you use multiple operations that require precedence, the whole expression is changed to "($nfx$ ...)". You can then define "$nfx$" to do whatever you want.

SRFI-105 contains a detailed rationale about its approach to precedence.

In practice, {3 - {4 * 5}} isn't hard to read at all, and sure beats (- 3 (* 4 5)).


(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds