Closed h3rald closed 3 years ago
A converter which converts operator signutures to normal symbol definitions can handle:
( symbol add-one
(int :n ==> int :result)
(n 1 + @result)
) operator
to
( :n n (int) expect ; <- <in-expectation groups here>
" " :result ; <- <outs here>
n 1 + @result ; <- <body here>
) :add-one
But ... there is no a symbol or anything that does things i explained above as far as i know, in min.
Well that would work but it would require some more language addition: expect can be used to construct such symbol BUT at the moment it doesn't support generics. While it would be technically possible to extend it or provide a way to validate generics in native min, it is quite a lot of work now... and in the end I am not sure the serialization of operators is worth the hassle.
Other programming languages normally don't support serialization of functions anyway 😉
Fixed in v0.31.0.
Every operator defined with the
operator
symbol is, as a matter of fact, a native symbol: the additional checks and expectations that are built-in with the construct are written in Nim by processing the signature, and the body quotation is evaluated.This means that symbols defined with
operator
:save-symbol
becomes pretty useless.source
.define
.This should be better clarified in the docs.