[Discussion] RFC 1091 - Extending the Types which Support Units of Measure #496
Replies: 19 comments 2 replies
-
In reply to #495 (comment):
Did you actually see this fail? Because alias-resolution already exists, perhaps once you've allowed let f (x: int<kg>) y: int32<kg> = x + y // should be valid, inferred type for y is int<kg>
let g (x: int<kg>) y: int32<kg^2> = x * y // should be valid, inferred type for y is int<kg>
let h (x: int<kg>) y = x * y // inferred return type is int<kg^2>, inferred type for y is int<kg>
let h (x: int32<kg>) y = x * y // inferred return type is int32<kg^2>, inferred type for y is int32<kg> @pblasucci If this leads to a lot of extra work, I've (still) no problem in postponing this, and allow the constraint solver and/or type inference to choke on this, i.e., where the user just has to stick to one chosen alias. |
Beta Was this translation helpful? Give feedback.
-
@abelbraaksma, thanks for opening up the issue.
Unfortunately, yes. I tried the exact code you posted (after enabling
Indeed. With unmeasured values, the types (e.g. (Aside: there's also a possibly related issue with respect to how constants are resolved to entities in the type checker; but I want to study that portion of code a bit further before discussing it.)
☝️ Just to clarify: you mean we'd release the update so that unsigned and native ints are supported -- but only a single abbreviation for each primitive can be measurable (i.e Because I'm comfortable with either that or delaying the whole thing. But I reallllly don't want to have multiple abbreviations for the same type be not-interchangeable. |
Beta Was this translation helpful? Give feedback.
-
That's a good point (your last one), I agree with that. |
Beta Was this translation helpful? Give feedback.
-
I figure now's a good time to update the discussion... State of the PR:
Errata:
Remaining work is:
|
Beta Was this translation helpful? Give feedback.
-
Wow, that's an impressive set of features! Good work! I'll have a go with your branch 👍. |
Beta Was this translation helpful? Give feedback.
-
Spoke too soon... there's an error specifically with Looks like a parser issue. It's actually present in production F#... but I guess it wasn't considered a big deal, since you can't add units to it anyway (in 4.x). |
Beta Was this translation helpful? Give feedback.
-
OK. Gonna add this here for posterity's sake (and in case anyone is curious)... I finished the analysis of the issue I was having with unsigned native integers. Basically, it was a bug in the parser. More specifically, the lexer filter was not including Anyway, at this point, I just need to straighten out a bit of testing ('cuz preview features), and apply any reviewer feedback. 🙂 |
Beta Was this translation helpful? Give feedback.
-
That's a great find! Must've been tricky and a deep dive into the compiler, nice work! |
Beta Was this translation helpful? Give feedback.
-
So, there are the following "maybe"s in the RFC:
It'd be nice to take a decision on them (n.b. they are currently all implemented in the PR -- but it's easy enough to drop out individual ones if they're unwanted for one reason or another). If we can arrive at a definitive answer here, I'll go update the code and/or RFC as needed. |
Beta Was this translation helpful? Give feedback.
-
For originality, it would be very good to have these all in. The alternative, not supporting type aliases would no doubt raise questions why @cartermp, would you agree that we should support these? They've already been implemented. As I understand it, the nominal types are not supported by this RFC, and neither are user defined type aliases of primitives (unless the type alias is itself an alias of a measured type). But all FSharp.Core defined aliases are supported. |
Beta Was this translation helpful? Give feedback.
-
@abelbraaksma Your understanding is correct. |
Beta Was this translation helpful? Give feedback.
-
Just found out about this: https://devblogs.microsoft.com/dotnet/introducing-the-half-type/ Do we need a plan for also supporting this? Or is it too far "down the road" to be considered in the current work? |
Beta Was this translation helpful? Give feedback.
-
Yeah, I actually wanted to add a language suggestion to that effect, it probably shouldn't be part of this one, as it is a whole new type, specifically meant for high performance simd programming. |
Beta Was this translation helpful? Give feedback.
-
Done: #498 |
Beta Was this translation helpful? Give feedback.
-
I know everyone is very busy, but are there any further thoughts on: #496 (comment)? (I don't mean to bug anyone. Just want to keep this RFC "on radar" and, hopefully, progressing 🙂 ) |
Beta Was this translation helpful? Give feedback.
-
I think at this point I'll leave it to @dsyme to consider the scope |
Beta Was this translation helpful? Give feedback.
-
We should just do all of these unless there's a technical problem with this. It's wrong for people who decide on |
Beta Was this translation helpful? Give feedback.
-
Thanks everyone! I've updated the RFC to reflect this decision. |
Beta Was this translation helpful? Give feedback.
-
So, I just noticed the checkbox for
is still not checked for this RFC. Is this something that needs tending to, and if so, is it possible to sneak this in before the .NET 6 release is November? I'm really keen to see this feature get "over the goal line". 🙂 Thanks! |
Beta Was this translation helpful? Give feedback.
-
This thread discusses the proposal in #495.
There's already some discussion in that issue. To summarize the open issues:
nativeint
orunativeint
be allowed as UoM? Answer: under discussionInt32<kg>
vsint<kg>
)? Answer: under discussionint<kg>
be used interchangeably withint32<kg>
? Answer: under discussionBeta Was this translation helpful? Give feedback.
All reactions