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

More explicitly document the type system #452

Open
JSAbrahams opened this issue Jan 24, 2023 · 0 comments
Open

More explicitly document the type system #452

JSAbrahams opened this issue Jan 24, 2023 · 0 comments
Assignees
Labels
documentation Update or fix documentation

Comments

@JSAbrahams
Copy link
Owner

JSAbrahams commented Jan 24, 2023

Many type system features are now kind of clear, but not wholly.
In the sense that I have a broad sense of what I want to achieve, but many design decisions are left vague.
Luckily, there's a lot of work on type systems done over the decades which we can leverage.
We should more completely document the type system to:

  • Guide our testing efforts, to make sure that we implement what we say we implement.
  • Guide our roadmap, what features we want and what we don't want to allow at all.

In a general sense, our guiding philosophy is that Mamba should be as flexible as possible.
We are not implementing a systems language, so we don't have to worry as much about stack vs. heap shenanigans.
But, if the check stage passes, then the application should be well-typed, in the sense that (not exhaustive perse but close I assume):

  • We only call functions which exist.
  • We only use types which exist.
  • We only call methods if a variable's type declares said method.
  • We only pass arguments to functions and methods which are (sub)types of the types declared in the signature.

Implicitly the above also ensures that:

  • All variables' types are known at compile/transpile time.

Of course, we can't always guarantee the above if we call Python code.
For that we need an unsafe operator, see:

Questions such as:

  • Is it static vs. dynamic (the former)
  • Is it manifest vs. inferred (the latter)
  • Do we use nominal or a structural type system (ideally the former but are there some situations where we accidentally allow the latter?)
  • Do we use duck typing?
    We do in some situations check only that a type implements a method, but does that actually mean we perform duck typing?
    Do we do it to a limited extent, or not at all (but still static of course).

What about the following?

@JSAbrahams JSAbrahams added the documentation Update or fix documentation label Jan 24, 2023
@JSAbrahams JSAbrahams self-assigned this Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Update or fix documentation
Projects
None yet
Development

No branches or pull requests

1 participant