Hi,
Perhaps I'm doing this the wrong way but I wanted to parameterize some
types by a constant, Year, like so:
abstract TaxForm{Year}
type Form1{2013} <: TaxForm{2013}
a
b
c
Form1{2013}() = new(0.0, 0.0, 0.0)
end
type Form1{2012} <: TaxForm{2012}
a
b
# no C field
Form1{2013}() = new(0.0, 0.0, 0.0)
end
type Form2{2013} <: TaxForm{2013}
e
f
g
Form2{2013}() = new(0.0, 0.0, 0.0)
end
type Form2{2012} <: TaxForm{2012}
e2 # different fields this year
f2
g2
Form2{2012}() = new(0.0, 0.0, 0.0)
end
# Create all tax form for a given year:
createforms(Year::Int) = {Form1{Year}(), Form2{Year}()}
tax_payable(f::Form1{2013}) = max(2*f.a, 0.0) + max(f.b, 0.0) + max(0.95*f.c
, 0.0)
tax_payable(f::Form1{2012}) = max(3*f.a, 0.0) + max(f.b, 0.0)
tax_payable(f::Form2{2013}) = max(f.e, 0.0) + max(f.f, 0.0) + max(0.91*f.g,
0.0)
tax_payable(f::Form2{2012}) = max(e2.a, 0.0) + max(f.f2, 0.0) + max(0.93*f.
g2, 0.0)
The fields of the form are different from form to form, and the same form
can change year to year. I've tried quite a few combinations and I get
syntax errors.
Any recommendations how to code something like this?
Yes, it is Tax time....
Glen