Loading uLisp programs from an SD card


#1

This is probably obvious, but if you have a microcontroller board with an SD card interface, the SD card provides a convenient way to load uLisp sources.

  • Copy the source listing from your computer to the SD card.

Depending on the processor you’re using you may need to give it a name of no more than 8 characters, and a three-character extension, such as “PLOTTER.TXT”.

  • Put the SD card in your microcontroller board and run uLisp.

  • Enter the following program:

(defun load (filename)
  (with-sd-card (str filename)
    (loop
     (let ((form (read str)))
       (unless form (return))
       (print (second form))
       (eval form)))))
  • Give the load command followed by the filename; for example:
(load "PLOTTER.TXT")

The command will print out the name of each function loaded from the file.


A better IDE for uLisp?
#2

No, that was NOT obvious, at least to me. — Wouldn’t that be a convenient way to implement “chaining” (as in BASIC, once upon a time), where essentially programs are loaded and unloaded according to needs, and just some variables or lists are used to transfer “state” from one program to the next?


#3

Well, it’s not quite like BASIC of yore in that (load “filename”) extends the current workspace with the parsed portions of “filename”. BASIC, as I remember, replaced the entire workspace but that may have depended on the particular BASIC being used.


#4

Well, my basic idea ( ;) ) is that this allows a crude form of “virtual memory”, if one were to necessitate such a thing, which I find awesome!