Skip to content
This repository has been archived by the owner on May 23, 2020. It is now read-only.

Provide different name for Composite Types parameter and Currency Symbol #1

Open
YongHee-Kim opened this issue Mar 7, 2019 · 0 comments

Comments

@YongHee-Kim
Copy link

YongHee-Kim commented Mar 7, 2019

Thanks for the amazing work
I'm writing a game economy simulator and, learning a lot from your code.

while studying CurrenciesBase, I was confused about currency struct

struct Currency{C, T} <: AbstractMonetary
    val::T

    (::Type{Currency{C}})(x::Real) where C = new{C,typeof(x)}(x)
end

T stands for DataType but what does C stands for? after sometime, I realized that it is a type for currency name itself.

But it still makes my head spin when I read Monetary{T,U,V}, and I think providing a different name for CurrencySymbol might be better for code readability.

How about NAME or name for Currency Symbol?

struct Currency{name, T} <: AbstractMonetary
    val::T

    (::Type{Currency{name}})(x::Real) where name = new{name,typeof(x)}(x)
end

+(m::Monetary{name,T,U}, n::Monetary{name,T,U}) where {name,T,U} = Monetary{name,T,U}(m.val + n.val)

This is just naive opinion from non expert. feel free to ignore.

thanks again for sharing your work 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant