4 ms·
For a challenge: Try a lazy language next. See http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ http://research.microsoft.com/en-us
by eru 16y ago
For a challenge: Try a lazy language next.
See http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ http://research.microsoft.com/en-us/um/people/simonpj/papers... for some hints on writing a compiler for those (or just general amusement).
- jacquesm 16y agoLisp is enough of a challenge for me at the moment. For instance, it seems to be like travelling back to the 80's just to have to live with the 'third element in the list containing the data about a person' instead of simply using person->name , I've gotten used to thinking in terms of symbols so much that I find it hard to go back to the kind of trickery that was 'normal' in say microsoft basic in the 80's because it lacked named elements in something akin to a struct. There is a certain kind of elegance in something so minimal but it also comes with considerable mental overhead and opportunity for mistakes.
- mahmud 16y agoYou're still in the pedagogy sandbox; every real Lisp worth using has structures and objects: (defstruct person name age occupation) => PERSON (make-person :name "Kris Kringle" :age 71 :occupation "Santa") => #S(PERSON-1) (person-name *) ==> "Kris Kringle"
- jacquesm 16y ago> You're still in the pedagogy sandbox; Don't worry, I realize that :) > very real Lisp worth using has structures and objects: That's a tricky and somewhat circular definition. If it is worth using it is probably real and vv, but most lisp tutorials that teach 'pure' lisp do not have structures and / or objects, they rely on lists alone as their major data structure. That also defines all lisps that do not have these items as somehow not real and there seem to be a lot of lisp people that somehow consider this 'impure'. Or is my reading material that dated ?
- jules 16y agoIf your reading material Lisp doesn't have some form of defstruct then it certainly is dated, or they are avoiding it on purpose. Every non-toy Lisp has it.
- jacquesm 16y agoOk, thanks. That helps. I started 'from the ground up', I figured that the best way to study a language is by looking at the way it was in the beginning since that's the most pure form of it. If 'lists' are as great as they are said to be you'd expect that things like structs and classes are optimizations, not essentials.
- mahmud 16y agoRestricting yourself to Pure Lisp is like insisting on only dating virgins.
- jules 16y agoYeah, you can view it as an optimization: you can build defstruct & co on top of lists with macros. However, using ca(d)*r by hand is not advisable in any case... Usually it goes the other way around: you implement lists on top of defstruct.
- eru 16y agoDon't do that for Lisp. You will be stuck with the dynamic scoping that Lisp used to be plagued with in the beginning. Go far a modern Lisp like Scheme. (You can ignore the syntax you don't want to deal with, yet.)
- gruseom 16y agothird element in the list containing the data about a person Most people don't do that, except in throwaway code. In CL you can use an alist, a plist, a struct, or CLOS. I've gotten used to thinking in terms of symbols so much that I find it hard to go back Given that Lisp's history with symbolic computing goes back to the beginning, something about that doesn't sound right. Your person->name comment reminds me of something, by the way. Portions of our app run in both CL and JS (via the Parenscript library). This is relatively easy, although there are a few disagreements between the two that you have to watch out for (such as how they handle null). Anyway, there are lots of CL features we've "ported" to JS via macros, but there is also one JS feature I found myself envying so much that I finally wrote a partial implementation of it in CL. That is JS's willingness to allow you to stick any property on any object just by setting it. It's a rather Lispy feature since it's maximally dynamic and maximally flexible. I find it handy for incremental development. When you have some data about a thing that you want to associate with it, but only some of the time, it's a real pain to have to make a separate data structure to hold it and then make sure it gets passed alongside the original thing to all the appropriate places. Our CL implementation of this is pretty crude but it allows the important thing, which is that you can write (@ something :some-data) and (setf (@ something :some-data) "blah") pretty much wherever you want. So we can be said to have Greenspunned a bit of JS in Lisp!
- KirinDave 16y agoInstead we all just use associative arrays. But there is a danger in overusing structs and classes, too. You end up with these hugely complex ontologies for every little program, and frequently when you try to reuse code you end up with conflicts.