[CM] *function*

chohag at jtan.com chohag at jtan.com
Sun Apr 19 15:42:03 PDT 2026


My mini S7 launcher is, more or less, a main function that contains:

        return s7_integer(s7_load_c_string(sc, *argv, 0))

There's a loop and it can read files but that's not the point. What
matters is I can type in things like "make && ./s7run '(foo)'" for
quick tests. Who needs another REPL when you already have a shell?

When the string that's being evaluated defines a function and that
function calls *function*, the return value of *function* is a
symbol but if *function* is called from a function defined within
a file it's a list of 3-elements.

This is down to the fallback return statement at the end of
let_to_function(). I think it would be better to consistently return
a 3-element list in all cases but I don't know what the other two
items should be. The corresponding returns in g_function should
probably also be updated to match (line_symbol & file_symbol) or
perhaps return (function #f #f)?

Curiously if I begin the string with one or more \n it reports that
the function is defined on line 1 (and counting) of *stdout*.

This is a trivial concern and it only showed up while I was debugging
a macro which includes a call to *function* but it confused me for
a while that the output differed depending on where code came from.

You may also want to change the section header comment which says
*current-function*.

And I agree, I don't think the let argument to *function* makes any
sense either.

Matthew


More information about the Cmdist mailing list