Date: Mon, 9 Jun 2025 23:17:52 +0100
On Mon, Jun 9, 2025 at 8:17 PM Thiago Macieira wrote:
>
> Several people told Frederick, repeatedly, that he was coming up with a
> solution in search of a problem
You're right, I'm working backwards on this one. In all the papers
that I've submitted to Nevin to get a P number, I've put in
motivations -- I wrote those papers describing a problem and then
proposing a solution. I wouldn't submit this draft paper to Nevin
without any clear motivations and code examples.
The reason I'm working backwards on this one is that it's such a
low-level facility. With such basic functionality at such a low level,
there's so many possibilities to find uses at mid and higher levels.
Like this: I've already shown that you can 'dynamic_cast' from a '
void * ' to a ' void * ', so long as both the source and destination
are polymorphic, but I want to take it a step further and try to
'dynamic_cast' from a ' void * ' to any polymorphic type. The idea
being that if you have a polyhandle, then you can use a method called
'dynamicCast' to check if you can get any given polymorphic type from
it, like this:
SomePolymorphicClass obj;
SomePolymorphicBase &b = obj;
std::polyhandle p(b);
auto *const ptr = p.dynamicCast< SomeOtherPolymorphicBase >();
Looking at the Itanium ABI, 'dynamic_cast' is implemented as:
void *_dynamic_cast (
const void *src_ptr, // object started from
const __class_type_info *src_type, // type of the
starting object
const __class_type_info *dst_type, // desired target type
ptrdiff_t src2dst) // how src and dst are related
And looking at the Microsoft ABI, 'dynamic_cast' is implemented as:
void *__RTDynamicCast( void *inptr, long VfDelta, void *SrcType,
void *TargetType, bool isReference );
So I think I _might_ be able to get this to work on both ABI's. And if
I do get this working, that's when it will really get interesting and
open up all sorts of possibilities. I'll be able to come with loads of
good examples. But even if it turns out that the 'dynamicCast' method
won't work on both Itanium and Microsoft, I have a few other
half-baked ideas about possibilites for std::polyhandle.
>
> Several people told Frederick, repeatedly, that he was coming up with a
> solution in search of a problem
You're right, I'm working backwards on this one. In all the papers
that I've submitted to Nevin to get a P number, I've put in
motivations -- I wrote those papers describing a problem and then
proposing a solution. I wouldn't submit this draft paper to Nevin
without any clear motivations and code examples.
The reason I'm working backwards on this one is that it's such a
low-level facility. With such basic functionality at such a low level,
there's so many possibilities to find uses at mid and higher levels.
Like this: I've already shown that you can 'dynamic_cast' from a '
void * ' to a ' void * ', so long as both the source and destination
are polymorphic, but I want to take it a step further and try to
'dynamic_cast' from a ' void * ' to any polymorphic type. The idea
being that if you have a polyhandle, then you can use a method called
'dynamicCast' to check if you can get any given polymorphic type from
it, like this:
SomePolymorphicClass obj;
SomePolymorphicBase &b = obj;
std::polyhandle p(b);
auto *const ptr = p.dynamicCast< SomeOtherPolymorphicBase >();
Looking at the Itanium ABI, 'dynamic_cast' is implemented as:
void *_dynamic_cast (
const void *src_ptr, // object started from
const __class_type_info *src_type, // type of the
starting object
const __class_type_info *dst_type, // desired target type
ptrdiff_t src2dst) // how src and dst are related
And looking at the Microsoft ABI, 'dynamic_cast' is implemented as:
void *__RTDynamicCast( void *inptr, long VfDelta, void *SrcType,
void *TargetType, bool isReference );
So I think I _might_ be able to get this to work on both ABI's. And if
I do get this working, that's when it will really get interesting and
open up all sorts of possibilities. I'll be able to come with loads of
good examples. But even if it turns out that the 'dynamicCast' method
won't work on both Itanium and Microsoft, I have a few other
half-baked ideas about possibilites for std::polyhandle.
Received on 2025-06-09 22:18:03