on Mon Aug 22 2016, Félix Cloutier wrote:
> I remember that the conclusion for type-safe unit calculations was
> that we didn't want to implement it as a compiler feature, but rather
> implement compiler features that would make it possible (as it is in
> C++
Hi Vladimir,
Your latest code is even nicer :) and works for most part, however found
the following issues below:
let dist : Distance = 10.km + 5.m + 5.mm
let dist2 : Distance = 100.km + 5.m
let weight : Weight = 10.pounds + 5.kg + 5.g // Assume we have Weight type
defined also
//let num =
On 23.08.2016 12:42, Nur Ismail wrote:
Hi Vladimir,
Thanks for your code, it's actually quite close to what I want :)
Some comments:
1) The main downside is that to read back the value, one can't re-use ".m",
".km", etc. and have to use ".inMeters()", etc. Would have been nice to be
able read
Hi Vladimir,
Thanks for your code, it's actually quite close to what I want :)
Some comments:
1) The main downside is that to read back the value, one can't re-use ".m",
".km", etc. and have to use ".inMeters()", etc. Would have been nice to be
able read and write using the same suffixes.
2)
I programmed in Ada in about 1990 and used typed numerics all the time.
Missed them ever since…
I would suggest to take a look at Ada and steal the best features to implement
typed numerics.
struct Distance: Double(checkedBounds: (lower: 100.0, upper: 10_000.0), delta:
0.1, digits: 10) { … }
Reposting comment from Dave A. in a previous thread:
"I'm not sure how useful this is, because it's not really a comment on
your efforts, but... some of us think we know how this problem domain
*should* be addressed, and we know that Swift doesn't yet have the
necessary language facilities
Wasn't there something about "units" announced at wwdc that does exactly this?
Sent from my iPhone
> On Aug 22, 2016, at 09:54, Nur Ismail via swift-evolution
> wrote:
>
> Hi,
>
> I'm new to the list, but have an idea for Typed Numerics.
> Basically numeric values
> On 22 Aug 2016, at 18:17, Charlie Monroe via swift-evolution
> wrote:
>
> I've personally come across something like Nur suggested. In particular, this
> is with NSTimeInterval, which is a typedef for Double.
>
> What I wanted to do is to make
>
> extension
I've personally come across something like Nur suggested. In particular, this
is with NSTimeInterval, which is a typedef for Double.
What I wanted to do is to make
extension NSTimeInterval {
static let minute: NSTimeInterval = 60.0
static let hour: NSTimeInterval = 3600.0
The first question is what the meaning of , for example, a multiplication
of Distance ? I.e.
let x1 : Distance = 10.m
let x2 : Distance = 10.km
let x3 = x1 * x2 // ???
I.e. as soon as your Distance is Double, you allows all kind of floating
point operations on instances of this type. And some
Hello,
The idea has been explored a number of times before. In some languages that
already implement it, it's called "newtype". You can see previous discussions
by googling "site:lists.swift.org newtype". There have also been other ideas
going around for type-safe unit calculations (there's
This has definitely come up in the list before, maybe somebody else can provide
some links to the conversations.
What I would love to see is a generic way of doing newtype, basically just
defining a “typealias” but with the difference that the type checker treats it
differently.
I’m not sure
Hi,
I'm new to the list, but have an idea for Typed Numerics.
Basically numeric values (such as Double, Int, etc.) that are strongly
typed to a specific use case, for example Distance, Weight, etc. and cannot
be intermixed with untyped values.
So if I have (the syntax is made up, but perhaps
13 matches
Mail list logo