h3rald / min

A small but practical concatenative programming language and shell
https://min-lang.org
MIT License
310 stars 23 forks source link

Difference between operators and quotations #114

Closed h3rald closed 3 years ago

h3rald commented 3 years ago

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:

This should be better clarified in the docs.

ghost commented 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.

h3rald commented 3 years ago

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 😉

h3rald commented 3 years ago

Fixed in v0.31.0.