Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overloading the complement operator ? #185

Open
callendorph opened this issue Dec 28, 2022 · 0 comments
Open

Overloading the complement operator ? #185

callendorph opened this issue Dec 28, 2022 · 0 comments

Comments

@callendorph
Copy link

From the docs , the not operator maps to the complement function. This function is defined in core.stanza as:

public defn complement (a:True|False) -> True|False

This makes it impossible to override the not operator. For instance:

    public defstruct AST : 
        name:String

    public defn complement (x:AST) -> AST : 
        AST(string-join(["not ", name(x)]))

... 

val a = AST("a")
val b = not a           <-- This will not compile

This generates:

Cannot call function complement of type True|False -> True|False with arguments of type (AST).

I does not seem like I can overload the complement function because it doesn't allow for defmethod style usage.
Thoughts ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant