Re: Very poor Lisp performance



Jon Harrop wrote:
Ulrich Hobelmann wrote:
Jon Harrop wrote:
Joe Marshall wrote:
Infix macros are *hard*.
Do you mean it is difficult to implement infix in Lisp?
No, others mentioned that *there are* infix parsers (reader macros) for
Lisp.  Most people don't use them I guess :D

Then why are they "hard"? Perhaps I misunderstood Joe. I thought he meant it was difficult to implement infix operators in Lisp. Now I'm thinking maybe he meant it is easy to implement infix operators but it is then difficult to write macros that use infix syntax?

It's difficult to integrate infix syntax into Lisp. Maybe the best possibility would be to keep the sexp form with its () and whitespace conventions, but keep them as lists to convert to prefix form. That way you could still use macros etc. But again: with n-ary operators prefix makes more sense, and even C, ML, Python ... use prefix for everything except math and iteration constructs (i.e. function calls). Lisp macros for converting infix-math to Lisp exist, but it's not fun to do normal programming that way.


Presumably that is a Lisp-specific problem because Mathematica has no
problem using infix notation...

Maybe because math is different. I don't know about Mathematica's macros either...


     You need to learn the prefix notation *anyway* (because code that
     operates on code needs to operate at the abstract syntax level,
     which in lisp is naturally prefix-notated lists).
So Lisp is rather tied to the built-in prefix notation.
Not at all.  Implement whatever syntax you want.  If you don't like Lisp
syntax at all use a complete, different syntax (and language) like Dylan.

So you disagree with Joe saying that "lisp is naturally prefix-notated lists". You believe that prefix/infix/postfix makes no difference in Lisp?

No, the language is prefix, but you can easily use (but not integrate) something else in it. Integrating infix with macros and functions in Lisp would be just as hard as integrating macros into other languages (see M4, CPP).


True, an experienced C coder probably doesn't make syntax mistakes, or
just ()s the code to be sure.  But I feel like in a straight-jacket when
coding C.  Not because of memory management, but because of syntax (like
the inability to use if and switch as an expression, the need to create
a named function in order to pass it as a parameter, the awkward syntax
for creating structures that I want to pass as arguments...).

Yes. To be fair, you are trying to do functional programming in an imperative language. Most people do the converse, trying to do imperative programming in a functional language. :-)

I'm not even good at FP, I'd say. I don't really use combinator functions, just a function as parameter once in a while, some recursion... But everything just when it's appropriate. It's sad that C gets in the way when you try to express compact, straightforward algorithms in it. Java is hardly better.


--
I believe in Karma.  That means I can do bad things to people
all day long and I assume they deserve it.
	Dogbert
.



Relevant Pages

  • Re: Any macro for inserting math "normally"
    ... in Lisp. ... syntax are both that it simplifies out the need to write gratuitous ... infix syntax, but it's also not something where I think the two ... I see no reason it couldn't be a hard requirement that both syntaxes ...
    (comp.lang.lisp)
  • Re: Very poor Lisp performance
    ... >>> Do you mean it is difficult to implement infix in Lisp? ... > to write macros that use infix syntax? ... your language is infix it's harder to write macros because the macros ...
    (comp.lang.lisp)
  • Re: Two questions together
    ... How powerful are the macros? ... > "programmable language" and as far as I know this feature is provided ... It is also said that one can hammer the Lisp so that ... I really love Lisp's syntax:) But I just want ...
    (comp.lang.lisp)
  • Re: macro for shorter array syntax
    ... This implies that OCaml macros can be easier which, in turn, justifies my ... Lisp manuals and tutorials say macros define new syntax, ...
    (comp.lang.lisp)
  • Re: Very poor Lisp performance
    ... >> Do you mean it is difficult to implement infix in Lisp? ... Perhaps I misunderstood Joe. ... >>> operates on code needs to operate at the abstract syntax level, ...
    (comp.lang.lisp)