I have a minimal amount of experience with Lisp and have read the blog posts on how to implement the basic special forms which are needed to define a Lisp. I’m considering trying to write my own Lisp as a scripting language for a platform whose primary language is something that I don’t like. Thing is, I don’t really want to write code using a minimal set of primitives. I want to write in a full Lisp.

Are there any “bring your own bootstrap” Lisp implementations, which provide a more full-featured language once the basic primitives have been provided? Something that would let me go more quickly from a couple hundred lines of bootstrap code into a more full fledged language, even if the runtime is slow.

  • Frere_de_la_Quote@alien.top
    cake
    B
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Actually, you have two different ways to execute your program: as a string with “execute” or with a file with “load”. In both cases, when you execute your code, it returns an Element object that can be anything that your program may return. You can then test if it is a list with isList(), or a string or a number. You have then many way to translate this object into what you want. The method “toString” is just one way to transform your output in a string to display it on screen:

    Element* e = lisp->execute(“(numbers 1 2 3 4 5)”) returns a vector of doubles. You can then iterate on it to extract your values:

    vector res; if (e->label() == t_numbers) { ((Numbers*)e)->liste.to_vector(res); }

    Another way, which is much more generic:

    if (e->isList()) { for (long i = 0; i < e->size(); i++) { res.push_back(e->index(i)->asNumber()); } }