Function pointer from mangled name at runtime?

bitwise via Digitalmars-d digitalmars-d at
Mon Sep 4 13:07:14 PDT 2017

On Monday, 4 September 2017 at 06:54:53 UTC, Jacob Carlborg wrote:

> On 2017-09-01 22:53, bitwise wrote:
> I'm not sure how your serialization library works

Exhaustively. Entire modules or classes can be reflected 

> or is intended to work.

*does ;)

> But at some point you need a static type to be able to do 
> something with the deserialized data.

Not really.

> The only exception is when serializing an object through a base 
> class reference

Exactly, but also when you want to change the value of a field at 
runtime from a visual inspector.


// backbone of a scene-graph
abstract class Node {
     @property const(Class) info() const;
     void update(){}

// use when inheriting Node
mixin template nodeInfo() {
     override @property const(Class) info() const {
         return reflect!(typeof(this))();

abstract class Scene
     Node[] nodes;

     // enforce overridden when adding node to scene
     TNode add(TNode : Node)(TNode node)
         if( != typeid(node))
             writeln("warning: '", TNode.stringof, "' does not 
                     " - runtime behaviour may be incorrect.");

         nodes ~= node;
         return node;

class MyNode : Node
     mixin nodeInfo;
     override void update(){ /* stuff */ }

More information about the Digitalmars-d mailing list