- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Units of Measurement — Scala Macros to the rescue?
Mon, 2012-02-13, 20:31
#52
Re: Re: Units of Measurement ‹ Scala Macros to the rescue?
For newcomers to this topic, a nice intro in IEEE Computer, Jan 2012, by B.Stroustrup:
http://www.computer.org/csdl/mags/co/2012/01/mco2012010047.html (members only).
General language design issues also worth the reading.
Robert.
Le 13/02/2012 15:41, Weber, Martin S a écrit :
>
> On 2012-02-10 05:51 , "André van Delft" wrote:
>
>> Martin,
>>
>> Strictly speaking, you are right. An energy is not a torque.
> Well, this is scala. So "strictly speaking" is the perfect formulation...
>
>> I think that dimension checking in the way I implemented
>> would still be useful.
> I agree. Which is why there's at least two dozen implementations for at
> least a dozen programming languages out there. But...
>
>> Support for quantity checking in a
>> programming language would be too hard, IMHO.
> Nah. With the amount of hobbyist category theory pros around it shouldn't
> be too hard. This is also something better than pimping straight function
> application with theoretical background to show off the usefulness of
> their trait. Actually a (non performant but working) solution is
> straight-forward. Of course scala compilations take too long already but
> it's the promises of static typing that make some accept that. In that
> sense adding a little time for true unit safety won't hurt.
>
> Point is, to "support SI" you better really support the SI. Having worked
> on the markup side of this, it's scary what people tag as "SI" which then
> isn't. Reading the BIPM VIM with attention to detail is a good startŠ
>
> Regards,
> -Martin
>
>
>
On 2012-02-10 05:51 , "André van Delft" wrote:
>Martin,
>
>Strictly speaking, you are right. An energy is not a torque.
Well, this is scala. So "strictly speaking" is the perfect formulation...
>I think that dimension checking in the way I implemented
>would still be useful.
I agree. Which is why there's at least two dozen implementations for at
least a dozen programming languages out there. But...
>Support for quantity checking in a
>programming language would be too hard, IMHO.
Nah. With the amount of hobbyist category theory pros around it shouldn't
be too hard. This is also something better than pimping straight function
application with theoretical background to show off the usefulness of
their trait. Actually a (non performant but working) solution is
straight-forward. Of course scala compilations take too long already but
it's the promises of static typing that make some accept that. In that
sense adding a little time for true unit safety won't hurt.
Point is, to "support SI" you better really support the SI. Having worked
on the markup side of this, it's scary what people tag as "SI" which then
isn't. Reading the BIPM VIM with attention to detail is a good startŠ
Regards,
-Martin