--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
Am 10.02.2011 um 16:27 schrieb jkrueger:
> a) This is essential to writing understandable code, so it would be
> nice if the language supported it out of the box
Is that so? I'd rather say that this a personal opinion of yours. There are different ways to organise code and neither is superior to the other. Just different.
> b) A namespace feels to me like a set of functions (ns-publics
> actually returns a map). That Clojure enforces a particular ordering
> (if we forget about the "declare" kludge) while writing a namespace
> seems arbitrary from a programmers point of view.
But Clojure's model of evaluation of a namespace also has a simple elegance. Defining a function is treated equally to adding two numbers. Everything is consistent. It is easy to determine what happens when. There are no special cases. This should seem quite logic from a programmers point of view.
Sincerely
Meikel
As a user coming from Haskell, I've always been disturbed by Clojure's
C-like behavior at this point, so I'd agree with the OP. And of course
the solution is not just reverse, as any order should be possible.
The question is how one could implement this without raising more
problems. Maybe a strategy could be like the following:
- Start the old compiler
- For each "symbol undefined" exception:
- add a declare on top of the namespace
- add a (when-not (bound? sym) (error "symbol undefined")) on the
bottom of the namespace.
So all undefined symbols will get declared first, but after compiling
the namespace, make sure they really have been bound somewhere.
Are there any edge cases where this strategy wouldn't work out?
Just my 2 cents,
Benjamin
>Who?
'uncle' bob martin:
http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882
Also, it's pretty easy to just reverse the level of abstraction
ordering from bottom-to-top is it not? I usually jump to the bottom of
the file to start with when editing Clojure code...