Editing and saving code directly in uLisp


#1

I’d like to be able to edit lisp programs in uLisp (and there’s edit, which works well enough), and then save them to the SD card. There’s more work to be done there (like trimming old copies of functions), but I can’t figure out how to write functions to the SD card such that they can be loaded again later. I can write a function for this, but I’m curious if I’m missing something. For example, I’d like to be able to do

> (defun sqr (x)
  "(sqr x)
Return x^2."
  (* x x))

> (with-sd-card (str "tools.lsp" 1)
   (pprint sqr str))

> (load "tools.lsp")
sqr
nil

Ideally, it would preserve indentation but that’s not strictly necessary. Am I missing a function here?


#2

This might answer your question:

Loading uLisp programs from an SD card


#3

You might also want to look at this thread, though I haven’t tried that solution myself


#4

It was close enough to start working on what I want. I basically wrote the same thing for load (except I return a list of the loaded functions). I still have issues with formatting, e.g.

> (defun sqr (x)
  "(sqr x)
Returns x^2."
  (* x 2)
> (symbol-def 'sqr)
(defun sqr (x) "(sqr x)
Returns x^2." (* x x))

which is more or less what the function I’ve been writing (basically the approach as symbol-def but I called it print-form) does. I’ll do some more exploration, there’s a few other issues with the platform I want to work through first.