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

Explicit type deduction #38

Open
mehcode opened this issue Jun 7, 2015 · 4 comments
Open

Explicit type deduction #38

mehcode opened this issue Jun 7, 2015 · 4 comments

Comments

@mehcode
Copy link
Contributor

mehcode commented Jun 7, 2015

let x: bool;
let y: type(x) = false;  // y is a bool
let m = 34;
let p: type(&m - &m);  // p is the platform-dependent pointer difference type
def some(x: int) -> bool { }
let ref: type(some);  // ref is the type of the function `some`

Other suggestions for the keyword: typeof or decltype (from C++)

@mehcode
Copy link
Contributor Author

mehcode commented Jun 7, 2015

If we name it typeof, it'd parallel nicely with sizeof (should we decide to add it)

@mehcode
Copy link
Contributor Author

mehcode commented Jun 7, 2015

Then again the byte-size of a type isn't a question the modern programmer asks or cares about. A whole keyword for the operation is a lot for something only rarely used.

@dmiller113
Copy link
Member

Except you are trying to support kernal dev, and they'd use it I think.

@mehcode
Copy link
Contributor Author

mehcode commented Jun 7, 2015

True. Also sizeof is something easily implemented in a macro / generic function.

let size = (((0 as *T) + 1) as *byte) - (0 as *byte);

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