Last active
May 28, 2016 23:03
-
-
Save griotspeak/f0f3480cb6569b5e5ad9aff761bb996f to your computer and use it in GitHub Desktop.
Wish I could tell the compiler to just use Expression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Expression : IntegerLiteralConvertible { | |
let value: Int | |
init(integerLiteral value: Int) { | |
self.value = value | |
} | |
} | |
struct Subexpression : IntegerLiteralConvertible { | |
let value: Int | |
init(integerLiteral value: Int) { | |
self.value = value | |
} | |
} | |
func * (lhs: Expression, rhs: Expression) -> Expression { | |
return Expression(integerLiteral: lhs.value * rhs.value) | |
} | |
func * (lhs: Subexpression, rhs: Expression) -> Expression { | |
return Expression(integerLiteral: lhs.value * rhs.value) | |
} | |
func * (lhs: Expression, rhs: Subexpression) -> Expression { | |
return Expression(integerLiteral: lhs.value * rhs.value) | |
} | |
typealias DefaultIntegerType = Expression | |
let foo: Expression = 3*((4 * 3) as Expression) | |
let bar: Expression = 4 * 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment