Skip to content

Consider removing splatting from operator overrides #196

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

Open
programmerjake opened this issue Nov 19, 2021 · 11 comments
Open

Consider removing splatting from operator overrides #196

programmerjake opened this issue Nov 19, 2021 · 11 comments

Comments

@programmerjake
Copy link
Member

Removing splatting from operator overloads would make simd more consistent with the rest of Rust where explicit type conversions are basically always needed, it would also greatly simplify our docs.

Because splatting is so common, we could add a global splat function (wouldn't necessarily replace Simd::splat, but would be otherwise identical) and/or a Splat trait such that you could write my_scalar.splat().

Zulip: https://rust-lang.zulipchat.com/#narrow/stream/257879-project-portable-simd/topic/remove.20splatting.20on.20operators.3F

Related: #195 (comment)
and: #10 (comment)

@workingjubilee
Copy link
Member

workingjubilee commented Nov 19, 2021

It is not a great amount of simplification, and having to manually splat everywhere makes reading the resulting code more complicated. Comparing it to the absence of numeric promotion is a false analogy, as the lanewise behavior does not vary, whereas numeric promotion does change lanewise behavior.

@programmerjake
Copy link
Member Author

programmerjake commented Nov 19, 2021

It is not a great amount of simplification, and having to manually splat everywhere makes reading the resulting code more complicated.

while it may be a little more complex (mitigated by splat fn/trait being short to write), imho consistency and explicitness is waay more important.

Comparing it to the absence of numeric promotion is a false analogy, as the lanewise behavior does not vary, whereas numeric promotion does change lanewise behavior.

That's just cuz your selectively glossing over aspects of the types. imho scalar/vector is a sufficiently important distinction that it should probably not be hidden.

@programmerjake
Copy link
Member Author

From Zulip:
@thomcc:

if we lose autosplatting, i suspect most of the inference errors related to simd in non-simd code will go away too

@programmerjake
Copy link
Member Author

Fixing inference in non-simd code may be the most significant reason to remove splatting, as @workingjubilee mentioned on Zulip

@workingjubilee
Copy link
Member

Type inference also "hides" details, and yet we have it, because it's not actually hiding anything if you evaluate something in context, So the ship that Rust should never """hide""" anything on a line-by-line basis has long since sailed. There are other languages which treat their users as if they cannot read anything if it is not written out in triplicate, and I purposefully avoid them.

@Lokathor
Copy link
Contributor

Yeah, not having splatting makes specifically literals a pain in the ass to work with. And we should make them easier to use not worse to use.

@programmerjake
Copy link
Member Author

Yeah, not having splatting makes specifically literals a pain in the ass to work with. And we should make them easier to use not worse to use.

I recognize that, so I think adding splatted literals might be a good idea: 3.5_f32x4 or 3.5_f32x_

@Lokathor
Copy link
Contributor

You would have had me on board if you said something like "let float literals infer into being compiled as a splatted simd value". But if you have to type it all the way out that's very bad. I want core::simd to be so good I throw out the wide crate.

@programmerjake
Copy link
Member Author

hmm, that's an idea i had kinda rejected due to type inference...if you think it'll work i think that'd be a good idea

@Lokathor
Copy link
Contributor

That would be like a whole T-lang MCP->RFC cycle to get done. I don't think we have the bandwidth for that right now honestly.

@programmerjake
Copy link
Member Author

That would be like a whole T-lang MCP->RFC cycle to get done. I don't think we have the bandwidth for that right now honestly.

so, we could use splat as a fallback till then, kinda like try! was

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

3 participants