5

I'm interested in seeing how low-level a programmer can go in pure Common Lisp (or, failing that, in implementation-specific extensions). Google hasn't been able to find me much information about this, so I'd like to hear what the experts have to say. This post mentioned a feature of SBCL to define what the author called "virtual operators", but searching for "common lisp virtual operators" didn't yield much. The author also mentioned how hard it was to find documentation about it. Do similar systems exist for other implementations, is there any basis for it in the standard (though considering that such a feature would mostly be used for writing ISA-specific code, portability shouldn't really be high on the priorities for users of it), and where can documentation for features such as this be found?

It would be great to find a way to extend the "programmable programming language" concept to low-level code as well (especially for areas where efficiency is highly important and other libraries written in C or assembly may not be available).

3

1 Answer 1

3

This is very implementation specific and not portable at all.

Yes, SBCL uses VOPs, but other implementations have completely different compilation targets.

If you intend to go low-level in a somewhat portable way, you have two avenues:

  • Optimize using declarations, inlining, manual unrolling etc., checking your progress with disassemble

  • Implement a static blob externally, then interface it with an FFI

4
  • What is VOP stands for?
    – muyinliu
    Apr 8, 2018 at 14:19
  • Virtual OPerator. See the original question.
    – Svante
    Apr 8, 2018 at 21:18
  • I am familiar with your first method (declarations and check disassemble). Do you know of any tools to enforce that you don't break optimizations, without the fragile reliance on remembering to check the assembly? Perhaps a compile option for that function, or a macro for writing lower level prog blocks? Oct 8, 2022 at 4:37
  • Not really. The SBCL compiler gives some notes when it can't optimize something, as soon as you declared some optimization. Other than that, I could imagine performance tests (comparing against a known computation so that changing or unknown machine speeds get compensated).
    – Svante
    Oct 10, 2022 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.