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 with multiple args #4624

Closed
wants to merge 3 commits into from
Closed

@TypeOf with multiple args #4624

wants to merge 3 commits into from

Conversation

LemonBoy
Copy link
Contributor

@LemonBoy LemonBoy commented Mar 4, 2020

Closes #439 (oh that's quite old)

Missing pieces (for another PR/day):

  • Use it in more places
  • Documentation

@mproved
Copy link
Contributor

mproved commented Mar 4, 2020

Shouldn't this take tuple as argument instead of varargs?

@LemonBoy
Copy link
Contributor Author

LemonBoy commented Mar 4, 2020

It feels a bit awkward with tuples, @TypeOf(.{bar}) looks like you're asking for the tuple type.

@SpexGuy
Copy link
Contributor

SpexGuy commented Mar 4, 2020

Maybe we need a separate macro for this case? Something like @PeerType(.{ @TypeOf(a), @TypeOf(b) }). Pretty fugly but it's more consistent with the lack of overloads elsewhere and separates PTR from var -> type resolution which would let you use it in situations where only the types are known.

@LemonBoy
Copy link
Contributor Author

LemonBoy commented Mar 4, 2020

TypeOf is not overloaded this way, the single-argument case is nothing but the multi-argument one with N=1.

@SpexGuy
Copy link
Contributor

SpexGuy commented Mar 4, 2020

That's true, but it doesn't change that I can't do resolution if I only know the types. Are there any other precedents for varargs builtins?

@alexnask
Copy link
Contributor

alexnask commented Mar 4, 2020

@SpexGuy
@compileLog, @asyncCall , @newStackCall (although the last two have to be switched to use an argument pack tuple)

@SpexGuy
Copy link
Contributor

SpexGuy commented Mar 4, 2020

Ok then this is probably fine. I'm just worried that proponents of varargs will point to this as a reason to add them back into the language. ("you couldn't even write the builtins without them" or some argument along those lines.)

@SpexGuy
Copy link
Contributor

SpexGuy commented Mar 4, 2020

But that concern can be separate from this PR. This is hardly the place for this discussion. Sorry @LemonBoy, carry on.

@andrewrk
Copy link
Member

andrewrk commented Mar 4, 2020

landed in 378bf1c

@andrewrk andrewrk closed this Mar 4, 2020
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

Successfully merging this pull request may close these issues.

@typeOf() should take multiple parameters and do peer type resolution
5 participants