Re: The power difference between a macro and a function



Jon Harrop wrote:
anamax@xxxxxxxxxxxxx wrote:

A 7 year old learning maths can understand a lot of precedence and
associativity.

When concentrating on precedence, most people can get 7-8 levels right consistently. However, "concentrating on precedence" is not a goal. In fact, said concentration is actually an obstacle. To put it another way, "understanding precedence" isn't the goal or a good thing, it is a cost/overhead/a bad thing.

You must concede that the vast majority of people choose to use associativity and precedence.

A majority uses indeed associativity and precedence. That doesn't necessarily mean that they choose to use them. It seems to me that a considerably large number of people doesn't know about prefix or postfix languages. So they can't make a choice. Another group of people reject the notion of prefix or postfix languages without having tried them, out of a gut feeling to stick with what they are used to. Of course, there are also people who tried both and indeed choose infix languages, but others make the switch.


We could all maximally bracket our
mathematics to remove ambiguity but we don't because we know the
expressions are much more comprehensible when written in conventional
style.

I always had a tendency to maximally bracket mathematical expressions in the various infix languages I encountered because I never really understood all the precedence rules. It always seemed to me that there were strange unintuitive exceptions in those rules, and I never bothered to understand the full rules. Using parentheses always seemed to me to be the better solution that is guaranteed to be unambiguous. I think I am by far not the only one to think that way.


Admittedly there seems to be value in infix notation for mathematical expressions even if they are fully parenthesized. At least I regularly catch myself to want to use infix notation for mathematical stuff when I program in Lisp. Maybe it's just a bad habit from the old days, who knows... ;)

One can see the same thing in natural language utterances.  There are
many syntactically and semantically correct sentences that are too
convoluted to use if one's goal is communication/understanding with
people.  With NL, we can't choose different rules.  With computer
languages we can.

Mathematics is a better analogy.

I don't think so. Lots of code I haven seen and that I write doesn't contain a lot of mathematics. What is neat about Lisp is that it allows me to write code that is closer to "natural" language than in other programming languages. (Consider the LOOP macro, for example.)


That's another reason why I think that the ray tracer code is not very representative of what is typically done in programs, at least in my experience...


Pascal

--
My website: http://p-cos.net
Closer to MOP & ContextL:
http://common-lisp.net/project/closer/
.



Relevant Pages

  • Re: Inconsistent formulas
    ... languages, I think you will find this to be very unusual operator precedence. ... In mathematics, exponentiation is represented by a superscripted ... to the Excel interpretation. ...
    (microsoft.public.excel)
  • PLMMS 2009: First Call for Paper
    ... The ACM SIGSAM 2009 International Workshop on Programming Languages ... for Mechanized Mathematics Systems will be co-located with TPHOLs 2009. ... Final Papers Due: July 10, ...
    (comp.lang.lisp)
  • PLMMS 2009: First Call for Paper
    ... The ACM SIGSAM 2009 International Workshop on Programming Languages ... for Mechanized Mathematics Systems will be co-located with TPHOLs 2009. ... Final Papers Due: July 10, ...
    (sci.math.symbolic)
  • Re: Oh Boy...More Brower Weirdness!!!
    ... Javascript is a "functional" programming language, which means that functions are first-class entities: they can be created and manipulated in various ways while the program runs. ... But even non-functional languages usually offer support for variables that refer to functions and can be used to evaluate functions. ... Treating code as data goes back to Goedel, Turing, and Church, all of whom developed mathematics that could manipulate mathematical expressions. ...
    (comp.lang.javascript)
  • Re: Why an inconsistent ZF may be desirable, and should be welcome.
    ... > under their intuitive interpretation. ... > the foundations of mathematics, ... > mathematical languages of effective, and unambiguous, communication. ... recursive functions having the same representation. ...
    (sci.logic)