News for hackers. Stuff that matters.
Re:Creating a Swift syntax extension: the Lisp 'cond' function by SeanLuke on Sunday June 08, 2014 @10:57PM (#7866800)
> In Lisp, cond works as follows:

> ...

> Much like a switch statement,

No. cond is nothing like a switch statement. cond is Lisp's version of if..else if...else if..else.

The distinction being, of course, that if you have a contiguous range of cases in your switch statement, a proper C compiler will compile it to an O(1) jump table, rather than an O(n) set of tests like an extended if-statement. This is so crucial and basic a distinction that I am astounded every time I find another person claiming that cond==switch.

The closest thing that Lisp has to a switch statement (and this is a significant failing in the language) is CASE. And that's only if you are careful and have a very smart compiler -- not sure if SBCL will jump-table it for you, for example.

There are no comments on this comment yet.