News for hackers. Stuff that matters.
Re:State of the Common Lisp ecosystem, 2020 by Blackthorn on Monday February 08, 2021 @01:13PM (#26068000)
> Common Lisp's worst feature is that it feels like just about everything imaginable has a catch.

You've put into words something I've struggled with saying for a while, and the exact reason I could never really enjoy working with Common Lisp.

The example I always return to is the lack of pervasive use of CLOS throughout the standard. Something like generic-cl[0] feels like it should be a baseline part of the language. As it is, it's a great library. But people are hesitant to even use it, because the result of making everything generic is a loss in performance!

Of course, [0] talks about optimizations they've done. I don't know how it compares to using the methods in the standard as opposed to the lib. Regardless, these libs only help when writing code, not reading it. Though don't get me wrong, that's a big deal! It's very helpful! But you wish everyone would play by those rules.

[0] https://github.com/alex-gutev/generic-cl

Re:State of the Common Lisp ecosystem, 2020 by Jtsummers on Monday February 08, 2021 @01:24PM (#26068138)
This seems like a consequence of the language never getting another standard. If it did, and given the way Common Lisp systems work, I think there could've been something like cl2 and cl2-user packages which could've pushed more towards that generic style that CLOS promotes, and maybe eliminated some of the elements that were redundant or didn't quite fit with everything else (is it `(function sequence index)` or `(function index sequence)`?). Those conflicts make sense given the history of the language (it was created to help connect several branches of the lisp family). And the older standard would've been easily preserved in the cl and cl-user packages.

But the language is essentially frozen in the existing standard, and can only be extended by community consensus right now.

Re:State of the Common Lisp ecosystem, 2020 by vindarel on Monday February 08, 2021 @01:21PM (#26068097)
If you want to regain performance, add-in type declarations, cl-generic will inline its functions: https://github.com/alex-gutev/generic-cl/#optimization
Re:State of the Common Lisp ecosystem, 2020 by admax88q on Monday February 08, 2021 @11:22PM (#26073824)
If I knew the types beforehand at compile time then I don't really _need_ the generic functions per say.

Is there a CLOS implementation with inline caches for generic method dispatch?

Re:State of the Common Lisp ecosystem, 2020 by fiddlerwoaroof on Tuesday February 09, 2021 @02:01AM (#26074693)
Almost all of them have something like that: Robert Strandh has a technique that looks promising[1] and is being implemented as a library, I believe. CLOS’s customization hooks allow you to switch out the implementation of “generic function” on a case-by-case basis which can be used to implement this sort of optimization.

[1]: http://metamodular.com/SICL/generic-dispatch.pdf

Re:State of the Common Lisp ecosystem, 2020 by reikonomusha on Tuesday February 09, 2021 @01:42AM (#26074606)
Do you mean something like this? https://github.com/guicho271828/inlined-generic-function

Even if you know all the types, you still have polymorphism that can’t be efficiently monomorphized without an exponential space penalty.

Re:State of the Common Lisp ecosystem, 2020 by admax88q on Tuesday February 09, 2021 @11:38AM (#26079494)
I don't think that's what I was looking for. That talks about dispatching generic functions at compile time.

> you still have polymorphism that can’t be efficiently monomorphized without an exponential space penalty.

Wouldn't it be linear at each call site only by the number of types that actually reach that call site? Plus you don't have to cache _all_ types at the call site, only the most frequent ones.

In Java and JS for instance, dynamic dispatch is JITed away at hot spots, and can be un-jitted later to reclaim space if the spot is no longer hot.

I generally don't care if a dynamic dispatch is slow if I'm only calling it a few times, but in a tight loop I want it to be inlined as much as possible.

Re:State of the Common Lisp ecosystem, 2020 by dTal on Monday February 08, 2021 @04:53PM (#26070694)
Perhaps one could write a type-inference macro. That would leave you with something like Julia, broadly speaking.