Live data from Hacker News

Reader Macros in Common Lisp (2014)

lisper.in

1–10 of 37 posts

Re: Reader Macros in Common Lisp (2014)

#3
Great timing. It's my turn to write a Lisp, and I was just thinking about implementing reader macros this morning :-)

My goal is to create the barest-metal Lisp OS (basically Lisp REPL with full ring-0 access, the OS) with an asm reader macro to write low level assembly opcodes you can jmp into.

    (defn add1 (x)
      (declare x int64)
      #asm(
        mov rax, %x
        add rax, 1
      ))
(Just thought of this syntax on the spot, I'm a few dozen hours away from that still.)

Re: Reader Macros in Common Lisp (2014)

#4
post #3

Great timing. It's my turn to write a Lisp, and I was just thinking about implementing reader macros this morning :-) My goal is to create the barest-metal Lisp OS (basically Lisp REPL with full ring-0 access, the OS) with an asm reader macro to write low level assembly opcodes you can jmp into. (defn add1 (x) (declare x int64) #asm( mov rax, %x add rax, 1 )) (Just thought of this syntax on the spot, I'm a few dozen…

1970's calling. Been there. Done that: https://news.ycombinator.com/item?id=33517092#33517797

Re: Reader Macros in Common Lisp (2014)

#5
post #2

Apropos. Is there reader macro definitions for "(" and ")" ? Or is Gödel rolling in his grave for such insolent heresy?

It would be a noop. A reader macro that takes a s-expr bounded by parentheses, and returns a s-expr, literally is just the identity function^Hmacro.

Re: Reader Macros in Common Lisp (2014)

#6
post #4
post #3

Great timing. It's my turn to write a Lisp, and I was just thinking about implementing reader macros this morning :-) My goal is to create the barest-metal Lisp OS (basically Lisp REPL with full ring-0 access, the OS) with an asm reader macro to write low level assembly opcodes you can jmp into. (defn add1 (x) (declare x int64) #asm( mov rax, %x add rax, 1 )) (Just thought of this syntax on the spot, I'm a few dozen…

1970's calling. Been there. Done that: https://news.ycombinator.com/item?id=33517092#33517797

Thanks for the inspiration. The fact that you've already done it won't stop me.

Got more details/links to study?

Re: Reader Macros in Common Lisp (2014)

#7
post #2

Apropos. Is there reader macro definitions for "(" and ")" ? Or is Gödel rolling in his grave for such insolent heresy?

Sure, what's so special about it?

(get-macro-character #\() => SB-IMPL::READ-LIST

(get-macro-character #\)) => SB-IMPL::READ-RIGHT-PAREN (that one just signals an error, the read-list one picks up the closing #\))

Re: Reader Macros in Common Lisp (2014)

#8
post #3

Great timing. It's my turn to write a Lisp, and I was just thinking about implementing reader macros this morning :-) My goal is to create the barest-metal Lisp OS (basically Lisp REPL with full ring-0 access, the OS) with an asm reader macro to write low level assembly opcodes you can jmp into. (defn add1 (x) (declare x int64) #asm( mov rax, %x add rax, 1 )) (Just thought of this syntax on the spot, I'm a few dozen…

https://movitz.common-lisp.dev/

Re: Reader Macros in Common Lisp (2014)

#9
post #6
post #4

Earlier quoted context omitted.

1970's calling. Been there. Done that: https://news.ycombinator.com/item?id=33517092#33517797

Thanks for the inspiration. The fact that you've already done it won't stop me. Got more details/links to study?

https://github.com/timonoko/nokolisp_addons/blob/master/asse...

Keyword is the line

     (dos-eval '(debug  NUL))

("mapc" and "map" had their parameters in wrong order, which annoys me even today)

Re: Reader Macros in Common Lisp (2014)

#10
post #5
post #2

Apropos. Is there reader macro definitions for "(" and ")" ? Or is Gödel rolling in his grave for such insolent heresy?

It would be a noop. A reader macro that takes a s-expr bounded by parentheses, and returns a s-expr, literally is just the identity function^Hmacro.

It's not. Reader macros don't take s-expressions, they take characters.
Post reply on HN