Custom calling conventions

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Tue Feb 21 07:41:43 PST 2012


Any D type can be stored in size_t.sizeof * 2 bytes of storage and
every type can be stored in that storage directly with the exception
of static arrays, which are stored as synamic arrays and large
structures, which are copied to the heap and stored by pointer. These
size_t.sizeof * 2 bytes storage in a structure with some template
methods for storing and extracting values is exactly that typeless
storage I need to implement any sort of dynamically typed mechanism
without performing unnecessary type checks and carrying around
unnecessary type information.
A Variant would be that storage with a type info and type checking.

And here's where my calling convention would kick in: I'd make a
calling convention, where all functions are binary compatible with
each other, so I can safely pass any parameter sets to any function
and the worst-case scenario would be a semantic error. Then any
function would be wrapped into this dynamic calling convention, which
takes an array of these storage objects as a parameter set and
performs a single type check per function call and the result would be
full dynamic typing in D with bare minimum overhead.

I really need full dynamic typing capabilities in D.

On Tue, Feb 21, 2012 at 7:34 PM, Gor Gyolchanyan
<gor.f.gyolchanyan at gmail.com> wrote:
> There are cases where i don't need type checking per Variant. In case
> of dynamic function calls, the parameters would be passed to a
> template, which would generate a TypeInfo of a function, with those
> parameter types and will compare with TypeInfo of the underlying
> function, effectively making only one type check per function call.
> Variant is tightly coupled with type storage and checking.
> I need a bare typeless storage for this and a separate type management
> mechanism. Without a calling convention it will look very ugly.
>
> On Tue, Feb 21, 2012 at 6:18 PM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>> On 2/21/12 5:19 AM, Gor Gyolchanyan wrote:
>>>
>>> This is just what I needed. I need to create a new calling convention
>>> to implement dynamic data typing without resorting to incredibly slow
>>> and cumbersome Variant.
>>
>>
>> If Variant is incredibly slow, that's a bug. It's a tagged union so for many
>> types it's simply the data and one extra word.
>>
>> Andrei
>>
>>
>
>
>
> --
> Bye,
> Gor Gyolchanyan.



-- 
Bye,
Gor Gyolchanyan.


More information about the Digitalmars-d mailing list