Re: Returning records instead of multiple values Dr. Arne Babenhauserheide 19 Sep 2026 18:58 UTC
Peter McGoron <xxxxxx@mcgoron.com> writes:

> The `procedure-check-of` currently returns two values. However, it
> might be better to have it return a record type that one can then call
> procedure-argument-checks and procedure-return-checks on.
>
> My reason for this is that an implementation can then add more fields
> to that record for their own extensions. For example, it could add a
> field to the record type that documents checks for keyword arguments.

I prefer multiple values, because they avoid the added indirection and
imported symbols of records (they’d also need procedure-checks? and
make-procedure-checks, and those could conflict from different
implementations of procedures that support procedure-check-of), and
multiple values avoid having to know implementation details to retrieve
additional information.

Practical problem: if you use both define-checked (SRFI-253) and
define-typed (SRFI-284), then the record types from both might have
different fields, but multiple-value returns should be compatible and
allow introspection of both with the same mechanism.

But multiple values pose the problem that some Scheme implementations
throw errors when you don’t retrieve all values.

Both problems could be avoided by returning an alist, where
implementations can add arbitrary keys without creating conflicts.

That would then be pretty close to just returning the
procedure-properties as used in Guile, though.

Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
https://www.draketo.de