-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Closed
Labels
language design
Any changes to the language, e.g. new featuresAny changes to the language, e.g. new features
Description
Originally proposed by @maurelian
It should be possible to define a user-defined type that is identical to a provided value type (including operators, members, etc.), but cannot be implicitly converted to any other type, and can only be explicitly converted to and from the underlying value type.
This has the effect that arithmetic operations are impossible to perform across these types.
Example (syntax under discussion):
typedef DistanceInMeters uint;
typedef DistanceInInch uint;
typedef Price fixed128x10;
DistanceInMeters distanceToDestination;
Price buyerPrice;
Price sellerPrice;
In the above, you can do buyerPrice - sellerPrice, but you cannot do buyerPrice * distanceToDestination.
maurelian, PaulRBerg and fulldecent
Metadata
Metadata
Assignees
Labels
language design
Any changes to the language, e.g. new featuresAny changes to the language, e.g. new features