You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, we can't support an operator like -n as we already define the operator as an infix operator.
Proposal A
I suggest to support this we make it like the following:
provide let (-) = (a, b) => tagSimpleNumber(Wasmi32.add(untagSimpleNumber(a), untagSimpleNumber(b)))
@prefix
provide let (-) = (a) => a * -1
@postfix
provide let (-) = (a) => decr(a)
we could then replace the function names with in the case of @prefix we could make it $(-) and in the case of @postfix we could make it (-)$ as grain doesn't allow $ in idents, this ensures that we won't overwrite a user var or function while providing each definition a unique name to avoid needing operator overloading.
Proposal B
Instead of requiring a user decorator on the function we could only allow an operator to be, infix and prefix or postfix but never both prefix and postfix. In this scenario we could determine that you are writing the prefix or postfix implementation as it would only take a single variable. Without rewriting a lot of semantics in the compiler we would probably be best still using the name override. The downfall of this approach, is while its simplier it narrows what the user can do.
Problem:
One thing that we certainly need to figure out here would be the semantics of from Module use { and Module.(-)(x, y)
The text was updated successfully, but these errors were encountered:
Currently, we can't support an operator like
-n
as we already define the operator as an infix operator.Proposal A
I suggest to support this we make it like the following:
we could then replace the function names with in the case of
@prefix
we could make it$(-)
and in the case of@postfix
we could make it(-)$
as grain doesn't allow$
in idents, this ensures that we won't overwrite a user var or function while providing each definition a unique name to avoid needing operator overloading.Proposal B
Instead of requiring a user decorator on the function we could only allow an operator to be,
infix
andprefix
orpostfix
but never bothprefix
andpostfix
. In this scenario we could determine that you are writing theprefix
orpostfix
implementation as it would only take a single variable. Without rewriting a lot of semantics in the compiler we would probably be best still using the name override. The downfall of this approach, is while its simplier it narrows what the user can do.Problem:
One thing that we certainly need to figure out here would be the semantics of
from Module use {
andModule.(-)(x, y)
The text was updated successfully, but these errors were encountered: