August 02, 2020 Re: __typeid | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 01.08.20 18:12, Andrei Alexandrescu wrote: > > Reading a bit more about TypeInfo and related stuff, I figure (and correct me if I'm wrong) that the entire machinery is currently used for the following purposes (only): > > * Built-in associative arrays (which ought to be phased out) > > * Inform the GC of what it needs to scan (provided in an awkward manner though, this is subject to a later discussion) > > * Dynamic cast information for class objects > > * Object creation for Object.factory() (which also should be phased out) There's also its toString. I have on occasion used writeln(typeid(classInstance)); |
August 02, 2020 Re: __typeid | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On 8/1/20 10:47 PM, Paul Backus wrote:
> On Saturday, 1 August 2020 at 16:12:58 UTC, Andrei Alexandrescu wrote:
>> * An important use of __typeid will be to implement Variant "the right way". Using the __typeid instead of the unsightly pointer to handler function in Variant would go a long way toward simplifying it. the __typeid API would be therefore geared toward the needs of that type. I've come to the realization that that type is essential for the use of D in dynamic contexts. I'd name that type Box, put it in druntime, and make it available to Das Besser C.
>
> In other languages, a Box is a wrapper that turns a value type into a reference type. [1][2][3] It is not a container for a single dynamically-typed value--in fact, its value is typically statically-typed.
>
> Most languages do not have a type like the one D currently calls Variant, but in those that do, the most widely-accepted name seems to be Any. [4][5]
>
> [1] https://docs.oracle.com/javase/tutorial/java/data/autoboxing.html
> [2] https://doc.rust-lang.org/std/boxed/struct.Box.html
> [3] https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/boxing-and-unboxing
>
> [4] https://en.cppreference.com/w/cpp/utility/any
> [5] https://www.scala-lang.org/api/current/scala/Any.html
Any is great.
|
August 09, 2020 Re: __typeid | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On 8/2/20 11:34 AM, Timon Gehr wrote:
> On 01.08.20 18:12, Andrei Alexandrescu wrote:
>>
>> Reading a bit more about TypeInfo and related stuff, I figure (and correct me if I'm wrong) that the entire machinery is currently used for the following purposes (only):
>>
>> * Built-in associative arrays (which ought to be phased out)
>>
>> * Inform the GC of what it needs to scan (provided in an awkward manner though, this is subject to a later discussion)
>>
>> * Dynamic cast information for class objects
>>
>> * Object creation for Object.factory() (which also should be phased out)
>
> There's also its toString. I have on occasion used writeln(typeid(classInstance));
Noted, thanks.
|
August 09, 2020 Re: __typeid | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | I implemented as far as I could from the classinfo API: https://github.com/dlang/druntime/pull/3174 I couldn't get my hands on number of things, such as: * the vtable (only vptr is accessible, not the size) * the vtables of implemented interfaces * the info whether a class is a COM class (I was surprised to learn that IUnknown is only defined in Windows-specific modules... it should be available to Posix too. * hasOffTi |
Copyright © 1999-2021 by the D Language Foundation