[CM] What is the "normal" way to handle errors for side effect functions in Scheme?

Iain Duncan iainduncanlists at gmail.com
Sun May 17 12:31:43 PDT 2020


Here's a snippet of what I'm trying, corrections or confirmation welcome:

// error and abort if not an int vector and table name
    if( !s7_is_vector(s7_source_vector) ||
!s7_is_int_vector(s7_source_vector) ){
        // error posts to the max console
        char *error_msg = "vector->table: arg 1 must be an integer vector";
        error(error_msg);
        return s7_error(s7, s7_make_symbol(s7, "io-error"),
s7_make_string(s7, error_msg) );
    }else{
        // do other stuff, let's say it's all good
        return s7_nil(s7);
    }

On Sun, May 17, 2020 at 12:11 PM Iain Duncan <iainduncanlists at gmail.com>
wrote:

> Hi folks, I'm hoping an experienced schemer can help me. I have a
> collection of FFI functions that are called for their side effects (ie
> writing to a table or buffer in Max). They can error out if, for example,
> they are called with a non-existent table name. I know what they should do
> in Max (post to the error log), but am not sure what the right thing is for
> them to do in a Scheme API. Right now I have my pure side-effect functions
> return Scheme nil when they are done. In Python, I would throw an
> exception. If anyone can point me at how to implement this so that
> experienced schemer's doing thing the API is garbage, that would be lovely.
>
> thanks!
> iain
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/mailman/private/cmdist/attachments/20200517/d472b98f/attachment.html>


More information about the Cmdist mailing list