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

@typeOf() should take multiple parameters and do peer type resolution #439

Closed
thejoshwolfe opened this issue Sep 1, 2017 · 0 comments
Closed
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@thejoshwolfe
Copy link
Contributor

the type of:

const foo = switch (bar()) {
    A => a(),
    B => b(),
    C => c(),
}

is some type that each of a(), b(), and c() either are or can implicitly convert to. Determining this type is called peer type resolution. That's already a solved problem.

The @typeOf() builtin function should take multiple parameters and do peer type resolution on them to expose this concept directly to users.

This is useful in this context:

fn max(a: var, b: var) -> @typeOf(a, b) {
    if (a > b) a else b
}
@thejoshwolfe thejoshwolfe added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Sep 1, 2017
@thejoshwolfe thejoshwolfe added this to the 0.2.0 milestone Sep 1, 2017
@andrewrk andrewrk modified the milestones: 0.2.0, 0.3.0 Nov 14, 2017
@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Feb 28, 2018
@andrewrk andrewrk modified the milestones: 0.4.0, 0.5.0 Sep 28, 2018
@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 May 9, 2019
@andrewrk andrewrk added proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. accepted This proposal is planned. and removed enhancement Solving this issue will likely involve adding new logic or components to the codebase. labels Oct 17, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Feb 10, 2020
LemonBoy added a commit to LemonBoy/zig that referenced this issue Mar 4, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.6.0 Mar 4, 2020
alexnask pushed a commit to alexnask/zig that referenced this issue Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants