From bc78a0a892ddaf6845e9f3615eefa62cc95a4b6d Mon Sep 17 00:00:00 2001 From: able Date: Fri, 3 May 2024 14:45:58 -0500 Subject: [PATCH] refining the examples --- examples/log.lisp | 24 ++++++++++++++---------- examples/repl.lisp | 13 +++++++++---- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/examples/log.lisp b/examples/log.lisp index 4df968f..e70c389 100644 --- a/examples/log.lisp +++ b/examples/log.lisp @@ -1,15 +1,19 @@ +(define send-message + (lambda (ptr-to-message length-of-message) + (asm + (li64 r1 3) + (li64 r2 1) + (li64 r3 ptr-to-message) + (li64 r4 length-of-message) + (eca)))) + (define log - (lambda (level message) + (lambda (level string) ( - (append (message level)) - (define ptr-to-message (ptr-to message)) - (define length-of-message (length message)) - (asm - (li64 r1 3) - (li64 r2 1) - (li64 r3 ptr-to-message) - (li64 r4 length-of-message) - (eca))))) + (append (string level)) + (define ptr-to-message (ptr-to string)) + (define length-of-message (length string)) + (send-message ptr-to-message length-of-message)))) (define error (lambda (message) (log 0 message))) (define warn (lambda (message) (log 1 message))) diff --git a/examples/repl.lisp b/examples/repl.lisp index a0c3a2d..058119b 100644 --- a/examples/repl.lisp +++ b/examples/repl.lisp @@ -1,9 +1,14 @@ +(define println + (lambda (s) + (print + (append s "\n")))) + (define repl (lambda () ( (print "λ -> ") - (print - (eval - (read))) - (print "\n") + (println + (append + ("val -> " + (eval (read))))) (repl)))) (repl)