Allow units of measure in for loops
I propose we extend the for loop typing to allow looping over an integer with units of measure.
Currently, the following won't compile:
let maximumDistance = 3<km>
let minimumDistance = 1<km>
for trial = minimumDistance to maximumDistance do
goRunning (trial * 1<km>)
The existing way of approaching this problem is to cast away the units of measure, and multiply them back in within the loop, which is ugly and reduces the safety that uom adds.
Pros and Cons
Advantages:
- An improvement to the usefulness of units of measure
Disadvantages:
- Maybe this would make loop optimization more tricky?
Extra informtion
Estimated cost (XS, S, M, L, XL, XXL):
S to M ?
Related suggestions: (put links to reated suggestions here)
Allow units of measure in sequence ranges #535
Affadavit (must be submitted)
Please tick this by placing a cross in the box:
Please tick all that apply:
Allow units of measure in for loops
I propose we extend the for loop typing to allow looping over an integer with units of measure.
Currently, the following won't compile:
The existing way of approaching this problem is to cast away the units of measure, and multiply them back in within the loop, which is ugly and reduces the safety that uom adds.
Pros and Cons
Advantages:
Disadvantages:
Extra informtion
Estimated cost (XS, S, M, L, XL, XXL):
S to M ?
Related suggestions: (put links to reated suggestions here)
Allow units of measure in sequence ranges #535
Affadavit (must be submitted)
Please tick this by placing a cross in the box:
Please tick all that apply: