News for hackers. Stuff that matters.
Re:Designing a Language Without a Parser by lispm on Wednesday July 05, 2023 @12:11PM (#36602489)
> Eg no modern Lisp stores a function as an S-Expr of its syntax

Many Common Lisp implementations do that, especially those with an interpreter: SBCL (yes, SBCL has an interpreter, too -> one can tell SBCL to use an interpreter), LispWorks, a Lisp Machine, Allegro CL, CLISP, ...

LispWorks:

  CL-USER 18 > (defun foo (a b) (* a (let ((a (* a a))) (break) (+ b (expt a b)))))
  FOO

  CL-USER 19 > (foo 1 2)

  Break.
    1 (continue) Return from break.
    2 (abort) Return to top loop level 0.

  Type :b for backtrace or :c <option number> to proceed.
  Type :bug-form "<subject>" for a bug report template or :? for other options.

  CL-USER 20 : 1 > :n
  Call to INVOKE-DEBUGGER

  CL-USER 21 : 1 > :n
  Call to BREAK

  CL-USER 22 : 1 > :n
  Interpreted call to FOO
You'll see that LispWorks says that FOO is running using the s-expression interpreter. Next we'll have a look at this s-expression:

  CL-USER 23 : 1 > :lambda
  (LAMBDA (A B) (DECLARE (SYSTEM::SOURCE-LEVEL #<EQ Hash Table{0} 82200D6A93>)) (DECLARE (LAMBDA-NAME FOO)) (* A (LET (#) (BREAK) (+ B #))))
The list is a value, which we can pretty print:

  CL-USER 24 : 1 > (pprint *)

   (LAMBDA (A B)
    (DECLARE (SYSTEM::SOURCE-LEVEL #<EQ Hash Table{0} 82200D6A93>))
    (DECLARE (LAMBDA-NAME FOO))
    (* A (LET (#) (BREAK) (+ B #))))
If you would modify this s-expression in the debugger, the program is directly changed.

There are no comments on this comment yet.