On Wednesday, 16 March 2016 at 14:19:56 UTC, Nordlöw wrote:
On Wednesday, 16 March 2016 at 13:57:51 UTC, ZombineDev wrote:
BTW, is there overlap between a unit system library and Andrei's BigO system? Maybe it would be useful if the later can be expressed with the former.

Interesting. Could you elaborate? What units should be involved?

Andralex?

I think it started here:
http://forum.dlang.org/post/n3sdm1$1fba$1...@digitalmars.com

See also:
http://forum.dlang.org/post/n3t8f8$2ii6$1...@digitalmars.com
http://forum.dlang.org/post/n4s66a$i9u$1...@digitalmars.com
https://issues.dlang.org/show_bug.cgi?id=15464

The two dimensions are time and space (memory). They are not expressed in absolute units of measurement, but show approximate rate of growth as the size of the input grows. Andrei's proposal defines an algebra over them. A system of units is also an algebra, so I wondering if we can somehow generalize the essence of both ideas.

BTW, after rereading the links above, I came up with a related idea: When you have a large existing codebase it may be too much work to change all types to be strongly typed like this:

==============================

// before:
struct Car
{
    double relativeSpeed(Car other); // measured in km/h
    double relativeDistance(Car other); // measured in km
}

// after:

alias KMpH = kilo!Metre / Second(3600);

struct Car
{
    KMpH!double relativeSpeed(Car other);
    kilo!(Metre!(double)) relativeDistance(Car other);
}
==============================

Sometimes a more gradual approach may be useful:

==============================
// before:
struct Car
{
    double relativeSpeed(Car other); // km/h
    double relativeDistance(Car other); // km
}

// after:

alias KMpH = kilo!Metre / Second(3600);

struct Car
{
    double relativeSpeed(Car other) @Unit!KMpH;
    double relativeDistance(Car other) @Unit!(kilo!Metre);
}
==============================


Reply via email to