Live data from Hacker News

(Ab)Using Language Features: The Common Lisp Condition System

dawnofthedata.com

11–20 of 25 posts

Re: (Ab)Using Language Features: The Common Lisp Condition System

#11
Here[0] is another example of extreme abuse of the condition system in order to construct "dynamic data pipelines" in Lisp. Roughly, it provides the ability of sending data to different parts of the call stack, and then returning back to continue processing. It can do all of this without any explicit use of variables, or without passing state around.

[0] PDF: https://bitbucket.org/tarballs_are_good/dynamic-collect/src/...

Re: (Ab)Using Language Features: The Common Lisp Condition System

#12
Interesting abuse of the Lisp Condition system.

If you'd like to read more, an excellent introduction to the Common Lisp condition system is given in Practical Common Lisp: http://www.gigamonkeys.com/book/beyond-exception-handling-co...

And I wrote a tutorial on Common Lisp restarts, using them in a non-trivial real world example: http://chaitanyagupta.com/lisp/restarts.html

Re: (Ab)Using Language Features: The Common Lisp Condition System

#13
This reminds me of using doesNotRecognizeToSelector:/methodForSelector: in Objective-C to do similar tricks. For example, you can wire up a color class to respond to any hexColor selector by catching the unimplemented ones:

    NSColor * color = [Colors h00FF00];
You can then parse the selector string when the runtime doesn't find an appropriate method for it. As with all these tricks, it is of course incredibly slower than just doing GetHexColor(char * hexString), but where's the fun in that right.

Re: (Ab)Using Language Features: The Common Lisp Condition System

#14
post #3

The post probably should've mentioned reader macros, since this is how you do this sort of stuff "normally".

For those wondering about reader macros in Common Lisp, I wrote a tutorial a couple of months back that allows the Lisp reader to understand JSON: https://gist.github.com/chaitanyagupta/9324402

Re: (Ab)Using Language Features: The Common Lisp Condition System

#15
post #4

This was something I really loved during my time in Common Lisp. This was a gem that I was hoping would make it into Clojure, but I think around version 1.3 they decided to abandon the idea and add a library to "make anything throwable" which totally missed the point in my opinion. Are there any other languages that allow the calling scope to specify how lower-level functions handle errors without unwinding the stack…

For conditions in Clojure check out Ribol: http://docs.caudate.me/ribol/

Re: (Ab)Using Language Features: The Common Lisp Condition System

#16
post #4

This was something I really loved during my time in Common Lisp. This was a gem that I was hoping would make it into Clojure, but I think around version 1.3 they decided to abandon the idea and add a library to "make anything throwable" which totally missed the point in my opinion. Are there any other languages that allow the calling scope to specify how lower-level functions handle errors without unwinding the stack…

> Are there any other languages that allow the calling scope to specify how lower-level functions handle errors without unwinding the stack?

Any language with continuations can have it added as a library. Of course, not a lot of popular, non-Lisp languages these days have continuations... (Ruby kinda does -- it was a language-level feature in 1.8 but has been sidelined since as non-MRI implementations generally don't support them.)

Re: (Ab)Using Language Features: The Common Lisp Condition System

#17
post #4

This was something I really loved during my time in Common Lisp. This was a gem that I was hoping would make it into Clojure, but I think around version 1.3 they decided to abandon the idea and add a library to "make anything throwable" which totally missed the point in my opinion. Are there any other languages that allow the calling scope to specify how lower-level functions handle errors without unwinding the stack…

For conditions in Clojure check out Ribol: http://docs.caudate.me/ribol/

also here: https://github.com/bwo/conditions

though honestly Ribol is probably a better bet---just wanted to show that this kind of thing can be done as a library without too much complication.

Re: (Ab)Using Language Features: The Common Lisp Condition System

#19
post #8
post #4

This was something I really loved during my time in Common Lisp. This was a gem that I was hoping would make it into Clojure, but I think around version 1.3 they decided to abandon the idea and add a library to "make anything throwable" which totally missed the point in my opinion. Are there any other languages that allow the calling scope to specify how lower-level functions handle errors without unwinding the stack…

Perl 6 allows for handling exception in a same-scope CATCH block, so you can try to recover. It can probably be mixed with their phasers[1] in interesting ways. Also of interest might be control exceptions[2]. 1: http://perlcabal.org/syn/S04.html#Phasers 2: http://perlcabal.org/syn/S04.html#Control_Exceptions

perl6: super hyperdimensional prototype future programming language

"It's not Lisp!"

Re: (Ab)Using Language Features: The Common Lisp Condition System

#20
post #6
post #2

It's nice seeing Common Lisp posts on the front page.

Yes, even if the industry usage is not big, learning about other languages is always a good way to improve our skills.

If anything we tend to hear more about Scheme(s) on HN than Common Lisp, which is even less associated with 'industry' (to my knowledge).
Post reply on HN