staged functions with type arguments

151 views
Skip to first unread message

Simon Byrne

unread,
Oct 5, 2014, 10:21:07 AM10/5/14
to juli...@googlegroups.com
I want to call a stagedfunction with a type argument: how do I access that type at the meta stage? I want to define something like:

stagedfunction prevfloat{T<:FloatingPoint,s}(t::Type{T},c::MathConst{s})
    bc = big(c())
    f = with_rounding(BigFloat,RoundDown) do
        convert(T,bc)
    end
    :(f)
end

However calling prevfloat(Float64,pi) gives me an ERROR: T not defined.

I can't use t instead, as at the meta stage, it has value Type{Float64}. I guess I could define an "untype" function to get access to the parameter, but that seems a bit too complicated. Is there a better way to do this?

-Simon

Tim Holy

unread,
Oct 5, 2014, 10:28:24 AM10/5/14
to juli...@googlegroups.com
See #8505. Besides fixing that bug, your untype is probably the best short-term
work-around.

--Tim
Reply all
Reply to author
Forward
0 new messages