mutable struct BadStack
    data::Int
    ref::Ref{BadStack}
    function BadStack(x::Int=0,r::Ref{BadStack}=Ref{BadStack}())
        return new(x,r)
    end
end

function push(p::Ref{BadStack},x::Int)
    return Ref(BadStack(x,p))
end
function empty(p::Ref{BadStack})
    return isassigned(p)
end
function top(p::Ref{BadStack})
    return p[].data
end
function pop(p::Ref{BadStack})
    return p[].ref
end

t=Ref(BadStack(6))
t=push(t,8)
println(top(t))
t=pop(t)
println(top(t))
