Hacker News new | past | comments | ask | show | jobs | submit login

> But the point isn't standard vs. non-standard, the point is macro vs. non-macro.

But why?

Imagine an alternate world in which all the things in the Common Lisp standard that are currently defined to be macros are special forms instead. I claim that (1) in that world, the criticism you're making would not apply, and (2) that world's Common Lisp is (a) not better in any way than our world's and (b) actually slightly worse, because code-walking macros would be more painful to write. Doesn't that indicate that there's something wrong with your criticism?

What I'm not seeing is how the fact that some standard features of Common Lisp are defined to be implemented via macros is a weakness, which you seem to be arguing it is.

On LOOP: Sure, you can use a C for loop to build a list of squares (but, note, it doesn't in fact do the same thing as the Lisp code and couldn't possibly, because (1) the Lisp code is an expression and a for loop is a statement but not an expression, and (2) that invocation of LOOP makes a new list and returns its final value rather than appending to some specific list that's already been created as your kinda-sorta-parallel code does). But that's what I meant about goto. You can use goto to do what a C for loop does. If you wouldn't say "Does for do more than goto? I doubt it" then you shouldn't say "Does LOOP do more than for? I doubt it".

> But in non-macro Lisp, loops are really painful to write

But "non-macro Lisp", if by that you mean something like "Common Lisp, with all the features defined to be implemented as macros taken out", is a thing that doesn't exist and that never would exist. (If for some reason you were implementing a Lisp without macros, and if you actually intended it to be a good general-purpose language, then of course you would include some decent looping facilities.)

So this is not an example of something that Lisp doesn't let you do "out of the box"; LOOP is right there in the box. As you say, LOOP is part of the standard for a reason.




Well, my initial claim was that Lisp needs macros in a way that C/C++ doesn't. You are now stating that Lisp could have been written in a way that it didn't need macros to be usable. And you're right, it could have been. But I don't think that that's the point.

The point is not that implementing things as macros is a weakness. It's that the language (as written) needs those macros. And C, as written, does not.

But I suppose from your point of view, my argument is a distinction without a difference...


I understand what you are saying. Its more of a claim that C/C++ does not need this project, as macros are not a necessity of the language.

I think the one thing that this project could provide (though due to the lack of function call access inside of macros that IS provided in Lisp macros maybe not) is to take that 10% of functionality that C/C++ does not provide and make it much more easily accessible. Of course this is always the difficult situation to discuss when first learning about Lisp macros because so much "standard" functionality already exists but I assume the old trusty could be applied here.

In many tutorials for learning Lisp macros the idea of "Lets say you wanted a statement (when <test> <expression>)." Its something that doesn't exist and the developer can add it in during development. You do not have to wait for someone else to implement this into your compiler.

This is a case where Lisp _needs_ macros to implement and where C/C++...can't do anything. Yes you can make a function that is similar to the format required but that is kind of the point. Its a hack to get the functionality and not something that looks natural.


I agree, there's that 10% in C/C++. And, you're stuck. But working around that 10% is an annoyance, not crippling. (In over 20 years as a professional C/C++ developer, I have never hit something that I couldn't write. "when <test> <expression>", for example. Yes, I can't write that exact syntax, but I don't care. I can get the same result, though perhaps slightly more clumsily.)

But Lisp without macros is crippled.

But, as lispm and gjm11 pointed out, Lisp could have been implemented with those macros as special forms instead, so Lisp wouldn't have to be crippled without macros.

My main point: I think the Lisp crowd overestimates how limiting it is for other languages not to have macros.


Well, yes, it is. You can turn Common Lisp (as it is) into a "language that doesn't need those macros" simply by going through the spec and changing everything that says, e.g., "macro DEFUN" to "special form DEFUN". The result would be a language that's no more powerful, no easier to implement, and marginally less convenient to use.

So how can "needing those macros" be a weakness, if the minimal change that makes the language not "need those weakness" improves nothing and actually makes the language a little worse?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: