News for hackers. Stuff that matters.
Re:Go makes it easier to write correct, clear and efficient ... by lispm on Friday May 10, 2019 @08:41AM (#19877155)
CLOS code:

   (defclass foo (superfoo1 superfoo2)
      ((some-slot :type bar)))

   (defmethod baz ((some-foo foo) (some-bar bar))
     ...)

   (defmethod foobar ((some-foo foo))
     (baz foo (make-bar)))
What would you need to do refactoring operations on such code? Given that there are classes, arguments are specialized over classes, slots have types, ...
Re:Go makes it easier to write correct, clear and efficient ... by marcosdumay on Friday May 10, 2019 @10:40AM (#19878180)
> What would you need to do refactoring operations on such code?

Some tool that can point where in a 1M lines of code project those classes are being used, and if they would need to change.

Re:Go makes it easier to write correct, clear and efficient ... by lispm on Friday May 10, 2019 @10:44AM (#19878222)
sure, go ahead. The type information is there.
Re:Go makes it easier to write correct, clear and efficient ... by bsaul on Friday May 10, 2019 @12:28PM (#19879335)
Didn't know about those type annotations in lisp, but i suppose what you mean is that an ide could parse all the code, infer the type of all the function / variables etc (just like the lisp interpreter would) and provide you with refactoring facilities ?

That's a good thing. But then comes the git merge (or any other automatic code altering tool). How do you know something hasn't been messed up in the process ? (unless you wrote unit test for every argument of every function)

Re:Go makes it easier to write correct, clear and efficient ... by lispm on Friday May 10, 2019 @12:50PM (#19879632)
> lisp interpreter

Lisp has compilers.

Some do also some type checking, here SBCL 1.5.2:

  (declaim (ftype (function (fixnum) fixnum) foo))
  (defun foo (a)
    (+ a 1))

  (declaim (ftype (function (fixnum) string) bar))
  (defun bar (a)
    (if (zerop a)
        "zero"
        "not-zero"))

  (defun baz (a)
    (foo (bar a)))
Then:

  * (compile-file "/tmp/test.lisp")
  ; in: DEFUN BAZ                                                                                                                                                                      
  ;     (FOO (BAR A))                                                                                                                                                                  
  ;                                                                                                                                                                                    
  ; note: deleting unreachable code                                                                                                                                                    
  ;                                                                                                                                                                                    
  ; caught WARNING:                                                                                                                                                                    
  ;   Derived type of (BAR A) is                                                                                                                                                       
  ;     (VALUES STRING &REST T),                                                                                                                                                       
  ;   conflicting with its asserted type                                                                                                                                               
  ;     FIXNUM.
Re:Go makes it easier to write correct, clear and efficient ... by marcosdumay on Friday May 10, 2019 @12:17PM (#19879214)
Indeed.

I had convinced myself I was reading Clisp, instead of CLOS.

Re:Go makes it easier to write correct, clear and efficient ... by lispm on Friday May 10, 2019 @12:40PM (#19879503)
CLOS is a part of Common Lisp. Fully integrated.
Re:Go makes it easier to write correct, clear and efficient ... by marcosdumay on Friday May 10, 2019 @12:42PM (#19879525)
Those type annotations are on clisp? I probably should get a project to test them :)
Re:Go makes it easier to write correct, clear and efficient ... by lispm on Friday May 10, 2019 @12:56PM (#19879700)
CLISP is an implementation of Common Lisp. The language is called Common Lisp.

Common Lisp has an object system with classes since the early 90s. In fact it was the first standardized object-oriented language.

Common Lisp also has optional type declarations. Not very sophisticated, but they are there.

Check out the SBCL implementation, which has a compiler which does some static type checking/inferencing.

http://www.sbcl.org

But one usually can use types/classes at runtime, too.

Re:Go makes it easier to write correct, clear and efficient ... by marcosdumay on Friday May 10, 2019 @02:17PM (#19880633)
Bookmarked for my next project. Thanks.