Is D actually |-----------this-----powerful-----------|?
    David Piepgrass 
    qwertie256 at gmail.com
       
    Sat Jun  9 10:07:17 PDT 2012
    
    
  
Oops, forgot the code.
> "4. Unit inference engine: Given some notation for optionally 
> indicating units, e.g. unit(value), could a D metaprogram 
> examine the following code, infer the correct units, and issue 
> an error message on the last line?
auto mass = kg(2.0);
auto accel = 1.0;
auto force = mass*accel;
accel += metresPerSecondSquared(9.81); // units of 'force' and 
'accel' now known
force += pounds(3.0);                  // unit mismatch detected
P.S. And can D output 'pre-processed' source, i.e. the code after 
metaprograms have executed?
    
    
More information about the Digitalmars-d-learn
mailing list