On Friday 03 December 2010 10:30:27 Robert Berry wrote: > Macros. MACROS!
Yes, go off and use Excel why don't you. (Yes, I do know what Lisp Macros are) Actually that's an interesting thought - there are many more hundreds if not thousands or hundreds of thousands of Excel macros written in the world, used by people and in use by people, solving real problems than there are lisp macros making people's lives easier. (Much as I hate excel, that's one hell of a fly in the ointment in the "macros" argument) > That is all. Some people who are interested in Python might be interested > in Clojure though, so I don't think it's spam. Python is pretty Lispy in a > lot of ways (famous Norvig article - http://norvig.com/python-lisp.html). I'm aware of the claims, however most aspects of python that are lispy are IMO often mistakes to use because they lead to obscure code and obscure code leads to bugs which are difficult to find and fix. Unless you think that programmers aren't human and programming ability in any group doesn't follow a bell curve like any other field of human endevour. > That said, I'm not interested in Clojure, as I don't like the JVM or > Oracle. Here's a hint, MIT moved away from a lisp type language for a reason, investigate it. Where did they go to ? Python. I'm sorry, but computers are tools. They are here to make our lives better. If you can't see that this sort of godforsaken syntax ... (def animation-sleep-ms 100) (def ant-sleep-ms 40) (def evap-sleep-ms 1000) (def world (apply vector (map (fn [_] (apply vector (map (fn [_] (ref (struct cell 0 0))) (range dim)))) (range dim)))) (defn place [[x y]] (-> world (nth x) (nth y))) (defstruct ant :dir) ;may also have :food (defn create-ant "create an ant at the location, returning an ant agent on the location" [loc dir] (sync nil (let [p (place loc) a (struct ant dir)] (alter p assoc :ant a) (agent loc)))) (def home-off (/ dim 4)) (def home-range (range home-off (+ nants-sqrt home-off))) (defn setup "places initial food and ants, returns seq of ant agents" [] (sync nil (dotimes [i food-places] (let [p (place [(rand-int dim) (rand-int dim)])] (alter p assoc :food (rand-int food-range)))) (doall (for [x home-range y home-range] (do (alter (place [x y]) assoc :home true) (create-ant [x y] (rand-int 8))))))) # Taken from one othe clojure examples written by the language author ... belongs in the 60s then you're sadly missing the fact that the language was a theoretical construct and a syntax was never intended to be implemented. I personally absolutely and categorically hate any language which refuses to bother with a decent parser, and expects the programmer to bend to the will of the machine rather than the machine to the will of the programmer. Take that final example, there's no reason it couldn't be written something like this: (nb, I do not expect this to look vaguely correct since the clojure code is almost as much line noise as perl can be) defn setup: "places initial food and ants, returns seq of ant agents" [ ] sync nil: dotimes i food_places: let: p = place([rand_int (dim), rand_int (dim)]) in: k = rand_int(food_range) alter: p = assoc('food',k) endalter endlet enddotimes doall: for (x,y) in zip([home-range,home-range]): do: alter: place[x,y] = assoc('home',true) endalter create_ant((x,y), rand_int(8)) enddo endfor enddo endsync enddefn IMO better. This might perhaps be better, but requires a slightly more complex parser: defn setup: "places initial food and ants, returns seq of ant agents" [ ] sync nil: dotimes i food_places: let: p = place([rand_int (dim), rand_int (dim)]) in: k = rand_int(food_range) alter: p = assoc('food',k) doall: for (x,y) in zip([home-range,home-range]): do: alter: place[x,y] = assoc('home',true) create_ant((x,y), rand_int(8)) Indeed, someone designing a language for *humans* would start from that code and think "how can I parse that", and build a language around that. This is despite the fact than languages are for people, not for machines. If you think clojure is very similar to python you're missing something very important. In python, the syntax _matters_ - it's designed to be human readable. The syntax of a lisp type language is an exercise in human and programmer hostility. Incidentally, the first fragment I wrote above (which is a bit ruby-esque) code fragment is parsable using the following LL(1) grammar: program -> block block -> BLOCKSTART statement_list BLOCKEND | BLOCKSTART BLOCKEND statement_list -> statement statement_list | statement statement -> EOL | expression EOL | expression ASSIGNMENT expression EOL expression -> oldexpression COMMA expression | BRA2 expression? KET2 | oldexpression oldexpression -> factor INFIXOPERATOR expression | factor COLON expression | factorlist factorlist -> factor factorlist | factor factoid -> factoid | factoid dotexpression | bracketedexpression | constructorexpression | NUMBER | STRING | ID \ | (factor trailer) | (factor trailertoo) dotexpression -> DOT factor bracketedexpression -> BRA expression? KET constructorexpression -> BRA3 expression? KET3 trailer -> BRA2 expression? KET2 trailertoo -> COLON EOL block (code: http://code.google.com/p/kamaelian/source/browse/sketches/SWP/swp/ ) So when I say that there's no excuse for lisp to look the way it does I really mean it. Especially since lisp programmers try to act like they're better than anyone else, you'd have to wonder really why they put up with such a shitty syntax. (The reality is they're just bracket blind) (The above grammar is keyword free, based upon indentation and end tags, and was generated in a test first fashion over the course of a weekend a few years ago :-) Other people's opinions may well vary, but to me, clojure fanatics would be best setting up their own google group. Or if that's too clear: (possible (opinion-owned (Other people) vary) (suggest me (fanatics clojure) (googlegroup setup own) nil)) In case it's not clear, it *is* possible to build a non-hideous keyword free language. I've tried, and the results are quite nice. Yours-emphatically-but-respectfully, (and nowhere near as harshly as text comes over ! :-) Michael -- To post: [email protected] To unsubscribe: [email protected] Feeds: http://groups.google.com/group/python-north-west/feeds More options: http://groups.google.com/group/python-north-west
