Skip to content

Can someone explain how this code works? #7

@Qiyamah

Description

@Qiyamah

Hi,
Can someone explain how x::Integer::Small works? What does it mean?
When I macro expand this code:

@traitor function howbig(x::Integer::Small)
    "Teensy..."
end

I get the following expansion. Can some one explain to me how the following code works?

quote
    $(Expr(:stagedfunction, :(howbig(x::Integer)), quote
    dict = Traitor.get_trait_table(howbig, Tuple{Integer})
    f = Traitor.trait_dispatch(dict, Tuple{x})
    (Core._expr)(:block, $(Expr(:copyast, :($(QuoteNode(:($(Expr(:meta, :inline)))))))), (Core._expr)(:call, f, :x))
end))
    function _howbig{::Integer::Tuple{Small}}(x::Integer) # REPL[10], line 2:
        "Teensy..."
    end
    d = Traitor.get_trait_table(howbig, Tuple{Integer})
    d[Tuple{Tuple{Small}}] = _howbig{::Integer::Tuple{Small}}
end

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions