On Sun, 28 Dec 2008 21:48:25 -0600
"David Nolen" <dnolen.li...@gmail.com> wrote:

> >
> > Yes, but I think maybe there is a bug in Clojure that causes the
> > first case to "work" when it should give a syntax error.  If it is
> > not a bug I do not understand why it ignores the expression.
> >
> 
> It's not a "bug" in Clojure because Clojure doesn't really have
> syntax in the way that you seem to be referring to, and I assume that
> you mean this in the sense that Python has list comprehensions as a
> syntactical feature of the language.  A list comprehension in Clojure
> is just a macro not any part of the "core" language so to speak.
> Much of Clojure is like this.
> 
> The macro could do some sort of syntactical checking.  But in this
> case it doesn't really seem like it's worth it.  You could of course
> re-implement your own version of list comprehension that does
> incorporate this.  Unlike Python where this is probably not realistic
> (you can't easily implement new Python syntax for yourself), Clojure
> being a Lisp makes this quite easy.
> 

I don't think the "Lisps have no syntax" card should be played to excuse
silent failures of the sort that create mysterious and difficult to
find/understand bugs. The "you can roll your own version" thing doesn't
really hold up for me, not even in a Lisp: people who reimplement custom
versions of basic language/library features in their app code are a
regular staple on The Daily WTF, for good reason :)

If this had happened to me I know *I* would be disappointed that it
wasn't caught automatically, since A) I would guess without immediate
proof that it isn't terribly difficult to do so, and B) this kind of
behavior tends to cause me hours of frustrating debugging. If it is
otherwise customary and expected that Clojure code throws exceptions
when called incorrectly, my intuition would be that silently generating
[incorrect] output for a malformed argument list is broken behavior.

"It is not blowing up," I would reason, "and thus it must be a logical
error in the structure of my algorithm, not something piddly like
accidentally omitting a keyword."

If you don't want to throw a syntax error (since you're right in the
sense that it *isn't* a syntax error) it should at least throw
something, for example Python tends to use a TypeError for malformed
argument lists.

Of course if someone can explain how this behavior gives list comps
useful properties and (perhaps more importantly) could have been
expected, then I'll happily retract this!

> David

-Kyle

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to