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

Support object constructor for distinct object types #19367

Open
MichalMarsalek opened this issue Jan 11, 2022 · 0 comments
Open

Support object constructor for distinct object types #19367

MichalMarsalek opened this issue Jan 11, 2022 · 0 comments
Labels

Comments

@MichalMarsalek
Copy link
Contributor

MichalMarsalek commented Jan 11, 2022

Summary

I feel like the following should be a valid code

type Foo = object
  data:int
type Bar {.borrow: `.`.} = distinct Foo

let x = Bar(data:0)

since I'd expect Bar to behave the same as if I just copied the type definition of Foo.

Description

I propose the code above to be treated as a valid code with the meaning of

type Foo = object
  data:int
type Bar = distinct Foo

let x = Bar Foo(data:0)

Alternatives

One alternative is to use the original type object constructor followed by the type change. If that gets tedious, one can create an init proc. Nevertheless the proposed syntax seems cleaner and intuituve.

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

No branches or pull requests

1 participant