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

cast as syntax #173

Open
trans opened this issue Mar 12, 2017 · 1 comment
Open

cast as syntax #173

trans opened this issue Mar 12, 2017 · 1 comment

Comments

@trans
Copy link

trans commented Mar 12, 2017

Just read your "Lately in Kitten" article. Was wondering why you chose the verbose notation:

1.0 cast as (Float32)

At the very least why not just

1.0 as (Float32)

But probably more important, why not RPN form, e.g.

1.0 (Float32) cast
@evincarofautumn
Copy link
Owner

evincarofautumn commented Mar 12, 2017

cast is going to be the trait for enabling conversions between types. as (Type) is the identity function on Type, so it just constrains the result, and it’s only necessary if the return type is ambiguous. For example, if foo has type Float32 -> Float32, then the type of cast in 1.0 cast foo is unambiguous, and no type annotation is necessary.

If cast as becomes a pain point, we could add sugar for it, e.g., to (Type).

The reason it’s not postfix is that Kitten parses types differently from terms, so there needs to be an indicator to the compiler that it should switch from term to type. That could be relaxed at some point (e.g. #132).

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