Hi Amirouche,
> I had similar wish with gamma generics, and I abandoned it because
> multiple value returns get in the way of developer experience. Not in
> this library, but generally within Scheme as we know it. It is visible
> at least in the following snippet:
>
> (procedure-check-of +)
> ;; => #<procedure number?> ;; Rest argument only
> ;; => (#<procedure number?>)
>
> The first returned value is a single means the rest arguments are all
> numbers. By the way, a plain procedure as first argument is how to
> tell
> the shape of rest arguments?
I’m not sure why you consider multiple value returns bad for developer
experience. There are conventional ways to deal with them, accessible
essentially everywhere—let-values, receive etc.
Then, the issue of plain procedures and rest argument typing. In short:
there’s no way to tell the type of a standard procedure rest argument
portably. SRFI-253 does not allow that, for example. However,
implementations do support that, with e.g. Chicken, supporting #!rest
typing. Chibi does not support rest argument typing for procedures, but
supports it for opcodes:
(opcode-param-type + 0)
;; => #<type "Number">
> By the way, giving an example how that works with let-keywords, and
> let-optionals:
>
> https://synthcode.com/scheme/chibi/lib/chibi/optional.html
Optionals are an obvious extension, but they are not portable. That’s
why I don’t mention them, focusing on rest argument
only. Implementations might extend what procedure-type-of returns with
whatever syntax, as long as it stays in the general shape of two return
values as pairs / objects.
> On an unrelated note:
>
> (procedure-check-of procedure?)
> ;; => (#f) ;; No check due to “any” type
> ;; => (#<procedure boolean?>)
>
> What is the meaning of boolean?
#f is reserved for “any” / * type. I could’ve specified (constantly #t)
as a returned check instead of it, but that’d be much less
introspectable and reliant on SRFI 235. Thus #f.
> check->sexp is what I call `sum` [latin for be] except it is missing a
> way of relating symbols within the sexp to its implementation
> and by the way recursively inspecting the check in the case where the
> check is a combinator.
This is always a compromise between simplicity and exactness. Here I
opted for simplicity of raw s-expressions. It is also consistent with
checks / procedures being essentially a single blob value with little
introspection. It is still valuable, even if crude.
> I believe the naming of procedure-check-of is unclear, and the
> signature is too. Another reason to call that work ambitious even if
> necessary.
In what way is it unclear, exactly? Can you expand on that?
Thank you for such detailed feedback!
Best of love,
--
Artyom Bologov
https://aartaka.me