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

default constructors #1180

Open
alex-s168 opened this issue Jan 27, 2025 · 1 comment
Open

default constructors #1180

alex-s168 opened this issue Jan 27, 2025 · 1 comment
Assignees

Comments

@alex-s168
Copy link
Contributor

would be useful for writing generic code.

I don't know how zero Maybe<x> = None works, but that could somehow be used for this

@andrew-johnson-4
Copy link
Owner

I think this could be a feature with default arguments to functions.

In the compiler right now there is a "default" constructor for one of the AST cases.

type AST = ASTEOF
         | ASTNil
         | App { is-cons: U64, left: AST[], right: AST[] }
         | Var { key: CString, token: Token }
         | Lit { key: CString, token: Token }
         | Abs { lhs: AST[], rhs: AST[], tt: Type }
         | AType { tt: Type }
         | Seq { left: AST[], right: AST[] }
         | Glb { key: Token , val: AST[] }
         | Typedef { lhs: AST[] , rhs: AST[] }
         | Meta { description: AST[] };

let $"App"(left: AST[], right: AST[]): AST = App { false, left, right };

default arguments could make this easier to declare.

@andrew-johnson-4 andrew-johnson-4 self-assigned this Jan 27, 2025
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

2 participants