D to Javascript converter (a hacked up dmd)

Jacob Carlborg doob at me.com
Thu Mar 1 11:42:32 PST 2012


On 2012-03-01 16:07, Adam D. Ruppe wrote:
> On Thursday, 1 March 2012 at 07:14:02 UTC, Jacob Carlborg wrote:
>> BTW, how do you fit D's class based object model in JavaScript's
>> prototype based object model?
>
> Short answer is each D object in JS has a virtual
> function array and implements array as properties
> attached to the object. The JS constructor for the
> object populates these arrays.
>
> Virtual calls thus look like:
> obj._virtual_table[call_num]();
>
> instead of
> obj.function();
>
> It is similar in principle to how you'd implement
> it in C.
>
> Long answer:

Ok, I see. Thanks for the detailed explanation.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list