Would it be easier than using custom variants?
Considering that custom variants are cross platform and the
IDispatch solution currently is not I'd say no.
Maybe there is a solution using RTTI?
With Extended RTTI you could probably do something like this, though this only works if the Extended RTTI is indeed enabled for that specific visibility section. But that functionality has not been integrated yet.
But in general - having looked at the Rosetta Code task - I think that this isn't something that Object Pascal can really do in the spirit of which the task was given.