2 ms·
Here is another example of callbacks at work from the TXR Lisp test suite: using the C library funtion qsort to sort a Lisp array of strings. http://www.kylhek
by kazinator 7y ago
Here is another example of callbacks at work from the TXR Lisp test suite: using the C library funtion qsort to sort a Lisp array of strings.
http://www.kylheku.com/cgit/txr/tree/tests/017/qsort.tl http://www.kylheku.com/cgit/txr/tree/tests/017/qsort.tl
It's done in two ways, as UTF-8 char * strings and as wchar_t * strings.
What's used as the callback is the function cmp-str which is in TXR Lisp's standard library. A lambda expression could be used instead.
Also tested is the perpetration of a non-local control transfer out of the callback, instead of the normal return. This properly cleans up the temporary memory allocated for the string conversions.
- cellularmitosis 7y agoTXR looks interesting. Is there a project README?
- kazinator 7y agoThere is a boring and poorly maintained home page: http://www.nongnu.org/txr http://www.nongnu.org/txr. And big honkin' manual.