Re: Any macro for inserting math "normally"



On Apr 8, 5:19 am, "Tamas" <tkp...@xxxxxxxxx> wrote:

Hi Juan,

I don't think that anybody questions the usefulness of infix notation
in general. It is certainly great for science and math, even though
most of the time the precise notation is not completely defined, but
context helps people cope with that. For example, if you check the
Comprehensive LaTeX Symbol List, you will see zillions of symbols,
most of them with multiple meanings in different fields, precedence
rules are certainly not defined for all of them etc. But that's OK:
most science and math papers provide the context where users can
figure it out. Only most. Recently I have seen a paper where the
author thought it would be clever to use ab/cd for (ab)/(cd), and it
took me quite a bit of frustration to figure out what he meant (it is
not usual for people to use this notation in economics). Or, in
probability theory, some people like to use the expectations operator
without parentheses, and the precedence is often unclear: is Efg=E(fg)
or fEg? People write the latter to avoid the ambiguity. but again,
with more complicated formulas it is not so obvious what to do. Some
measure theory books get into the "I'm gonna clean up the notation
once and for all" mindset, and a few even manage to do this
consistently _inside the book_ (where they only have to deal with a
subset of math) but cease to be applicable outside it.

Hi,

I think that one would not mix concepts of infix with those of
precedence and grouping. The LISP (* (+ 2 8) 3) is infix [[2 + 8] * 3]
whereas being (2 + 8 * 3) for a language with L2R precedence rules.

When we program computers, it is up to the machine to interpret the
code so it can't figure out what the notation means by using context.
Of course it is perfectly possible to define unambiguous infix
notation, the trouble is, that with many symbols one has to remember
the rules are.

No trouble when the syntax is infix without using precedence rules (or
using only those you predefined and are familiar with).

Personally, when I program C, I just follow the advice
of Practical C Programming by Steve Oualline: remember that * binds
tighter than +, and use parentheses for everything else. And I really
hate it when people rely on precedence for anything else, because I
have to look it up, I just simply can't make myself memorize the
rules. The alternative is using a lot of parentheses, but then I
would prefer my parentheses to be intelligible at a glance. Lisp
helps with that (C-M-q rocks ;-).

About parentheses, an infix notation can help to reduce needed number
of parentheses a lot of under certain circumstances. This could be
used for avoiding one of common criticism to LISP/Scheme.

In knowledge representation, one gets a reduction from 10 to 4
brackets using infix for a very common formal construct on science and
engineering:

[[A B / A D] = C B]

(= (/ (A B) (A D)) (C B))

Notice that the optimisation on number of parentheses (LISP needs more
than double) is based in topological properties of the infix position.
No precedence rules or assumptions were used!

Of course, if you like precedence you could define your own syntax
with precedence rules you like. Some people would like something as

A B / A D = C B

Others would hate it!

For stuff like (+ 2 (- 5 4)) there is no gain: [2 + [5 - 4]].

.



Relevant Pages

  • Re: Reason for operator precedence
    ... Having multiple levels of precedence obviously adds complexity, ... I meant to make it work without needing parentheses, ... convention of your choice. ... Polish or Reverse Polish notation. ...
    (sci.math)
  • Re: refactoring - the BIG picture ?
    ... people wanted their code to look like mathematics. ... I think you are conflating infix notation with operator overloading ... I've worked in enough languages and math ...
    (comp.lang.forth)
  • Re: [QUIZ] Postfix to Infix (#148)
    ... It minimizes the use of parentheses, ... portion of the infix expr being built. ... This week's quiz is to write a script that translates postfix expressions ...
    (comp.lang.ruby)
  • Re: cdr with dotted pair
    ... >> notation can be used for infix expressions. ... I generally prefer prefix notation, and I doubt that infix is ... so the dots don't obscure the infix operator. ...
    (comp.lang.scheme)
  • Re: Why is LISP syntax superior?
    ... and is suspect reason for infix macros and special editors. ... Which language is easier to communicate in: ... Macros could be done with infix notation, ...
    (comp.lang.lisp)

Loading