Skip to content

Optional routine parameter types #20

@emiljapelt

Description

@emiljapelt

Kind of annoying having to always type out all parameters... It is not the seplin way.

Current: | T_Routine of char list * (var_mod * typ) list
Instead: | T_Routine of char list * (var_mod * typ option) list

Then when resolving types, only the defined types can be used.
If type resolution is succesful, missing parameter types can be filled out.

The goal is essentially that the following becomes valid:

intern iter :(_, (T)):= <T>(a: T[], f) {
  for(i ::= 0; i < |a|; i +:= 1)
    f(a[i]);
}

entry main ::= () {
  iter("Hello world!", (c) { print c; });
}

The type of 'iter' should be valid, as both parameters have a type, 'a' from the routine expression and 'f' from the assignment.

The call to 'iter' should be valid, as 'T' can be infered to be 'char', and 'c' could then be given that type, before the anon routine is type checked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions