News for hackers. Stuff that matters.
Re:Why I still Lisp by lispm on Sunday January 31, 2021 @01:50PM (#25981371)
If one uses a Lisp interpreter, macro expansion may happen at runtime.

CLISP example:

  [2]> (defmacro add2 (place) (print 'add2) `(incf ,place 2)) 
  ADD2
  [3]> (let ((a 1)) (dotimes (i 4) (add2 a)))

  ADD2 
  ADD2 
  ADD2 
  ADD2 
  NIL
  [4]> 
As one can see the macro form is expanded four times at runtime.
Re:Why I still Lisp by dzsekijo on Sunday January 31, 2021 @05:36PM (#25983302)
This is a confusing example, because in a REPL steps of compilation and evaluation are interleaved.

Indeed, can you write a program for CLISP that works like this:

- takes one command line argument (a file name)

- reads in the given file, interprets it as Common Lisp code, expecting it to deliver a definition for the add2 macro

- then runs

   (let ((a 1)) (dotimes (i 4) (add2 a)))
Re:Why I still Lisp by lispm on Sunday January 31, 2021 @05:58PM (#25983458)
> This is a confusing example, because in a REPL steps of compilation and evaluation are interleaved.

The CLISP REPL does not compile, thus it can't be interleaved.

> then runs

It will still be interpreted and the macro will still be expanded at runtime.