The Artima Developer Community
Sponsored Link

Weblogs Forum
Metaprogramming on Steroids: Overloaded Type Operators

15 replies on 2 pages. Most recent reply: Sep 29, 2005 2:25 AM by Howard Lovatt

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 15 replies on 2 pages [ « | 1 2 ]
Howard Lovatt

Posts: 321
Nickname: hlovatt
Registered: Mar, 2003

Re: Metaprogramming on Steroids: Overloaded Type Operators Posted: Sep 29, 2005 2:25 AM
Reply to this message Reply
Advertisement
@Sean Conner

Your suggestion is what the proposal for Java does (JSR-275), e.g. they have a class Length which is the length in meters (SI) and conversion operators that take a value and a unit and convert them to meters. e.g.:
Length x = valueOf( 1, MILE ); 
Length y = valueOf( 1, MILE );
Length z = x.plus( y ); // OK
Area a = valueOf( 1, HECTOR );
z = x.plus( a ); /* Compile time error - you can't add a Length and an area */

Flat View: This topic has 15 replies on 2 pages [ « | 1  2 ]
Topic: Post-TDD Previous Topic   Next Topic Topic: Representing Units of Measure


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us