Hacker News new | past | comments | ask | show | jobs | submit login

> Lisp is the fact that there's no concept of "compile time".

The first Lisp compiler was finished in 1960.

Naturally Lisp has the idea of 'compile-time'.

> Declaring classes, methods, even entire language concepts like promises happens entirely in runtime

Let's see. I have a file with these contents:

    (defclass foo () (a b c))

    (defmethod bar ((a foo) (b foo))
      (+ (slot-value a 'a)
         (slot-value b 'b)))
Now let's use a Lisp compiler (!), here SBCL:

    $ sbcl
    This is SBCL , an implementation of ANSI Common Lisp.
    More information about SBCL is available at <http://www.sbcl.org/>.

    SBCL is free software, provided as is, with absolutely no warranty.
    It is mostly in the public domain; some portions are provided under
    BSD-style licenses.  See the CREDITS and COPYING files in the
    distribution for more information.
compiling the file:

    * (compile-file "compile-test.lisp")

    ; compiling file "compile-test.lisp" (written 16 MAR 2016 07:34:51 PM):
    ; compiling (DEFCLASS FOO ...)
    ; compiling (DEFMETHOD BAR ...)

    ; compile-test.fasl written
    ; compilation finished in 0:00:00.020
    #P"compile-test.fasl"
    NIL
    NIL
Wow, the sbcl Lisp compiler just compiled the file and generated the code for a class and a method using that class.

Let's see if sbcl knows about the class:

    * (find-class 'foo)

    debugger invoked on a SIMPLE-ERROR:
      There is no class named COMMON-LISP-USER::FOO.

    Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

    restarts (invokable by number or by possibly-abbreviated name):
      0: [ABORT] Exit debugger, returning to top level.

    (SB-PCL::FIND-CLASS-FROM-CELL FOO NIL T)
    0] 0
Oh, it doesn't know about the class. We are no longer in 'compile time'. The class was only known during 'compile time', a concept you said Lisp does not have. sbcl seems to have it. Funky.

But we can load the generated machine code:

    * (load "compile-test")
    STYLE-WARNING: Implicitly creating new generic function COMMON-LISP-USER::BAR.

    T
    * (find-class 'foo)

    #<STANDARD-CLASS FOO>
    * 
Now it knows about the class.

> Would anyone expect anything else from language with such capabilities?

Lisp has a lot of code bases which are large and maintained for 2 or more decades. Common Lisp has especially been designed to support compilation in various forms and to support the development of complex/large systems. One gets a lot of support from compilers like sbcl for doing so.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: