I has had always been much difficulty on understaning MetaProgramming.
Here is an example. I tried again and again to get to the target. These codes works fine. But I believe thers must be some more brief way to get to this. Where can I change the codes?
abstract type Soft end
macro base_info1(ticker,super_tp,tz)
struct_name=Symbol(ticker,super_tp)
const_name=Symbol(ticker,:er)
show_name=String(ticker)
return quote
struct $struct_name <: $super_tp; end
const $const_name=$struct_name()
Base.show(io::IO,x::$struct_name)=print(io,$show_name)
tick_size(::T) where {T<:$struct_name}=$tz
end |> esc
end
@base_info1 AB Soft 1
ABSoft
#ABSoft
ABer
#AB
tick_size(ABer)
#1