News for hackers. Stuff that matters.
Re:This Old Lisp by junke on Friday October 19, 2018 @11:42AM (#18257508)
Every value in CL is an instance of class. Some of those classes are built-in classes, which are restricted for performance reason. You do not inherit from Int in Scala either, since it is marked as "final", as far as I know.
Re:This Old Lisp by throwaway487548 on Friday October 19, 2018 @12:05PM (#18257687)
In Scala an integer has methods, like everything else, unlike it is in Java and C++, and this is the point and the big deal.

    3 + 2 is actually 3.+(2) which is the right thing.
Re:This Old Lisp by kbp on Friday October 19, 2018 @07:21PM (#18260781)
You can specialise generic functions on built-in classes in standard CL. Lisp methods are specialisations of generic functions; they don't belong to a class in the way methods do in eg C++. The issue you're talking about is that not all functions are generic functions in Common Lisp, and you can't specialise ordinary functions.

There's nothing stopping you from doing

    (defmethod add ((x number) (y number)) (+ x y))
    (defmethod add ((x string) (y string)) (concatenate 'string x y))
or whatever (multiple dispatch, too), and you could even call it + instead of ADD if you wanted (but not COMMON-LISP:+, so other code would continue to work; your packages could import your + instead of the standard one).
Re:This Old Lisp by junke on Friday October 19, 2018 @12:20PM (#18257776)
"+" is a function, what makes it "right" to be a method?
Re:This Old Lisp by pfdietz on Monday October 22, 2018 @09:41PM (#18280149)
You mean, what makes it right to be a generic function that has methods?

First, + does dynamic dispatch based on the types of its arguments. It does different things when adding fixnums, vs. integers, vs. rationals, and so on, as well as a default method that signals a type error (in safe code). So it has methods, even if they aren't necessarily implemented as standard methods (but they could be).

Secondly, a user might want to make + work on other, user-defined classes (for example, if he user wanted it to work on a class representing quaterions). To make that work, the user would have to be able to add methods for those classes. One can imagine many CL builtins being implemented as generic functions to which users could add methods. This would be consistent with the standard.

Re:This Old Lisp by jhbadger on Saturday October 20, 2018 @07:29AM (#18262769)
a function is just a method that returns a value. Why make a special case for it? Of course you can go the other direction and allow functions to return nothing (or a representation of nothing like nil). That's fine too.