On Tuesday, 28 October 2014 at 02:34:14 UTC, ketmar via Digitalmars-d wrote:
On Tue, 28 Oct 2014 01:36:01 +0000
bitwise via Digitalmars-d <digitalmars-d@puremagic.com> wrote:

I have actually found a work around as well, which was to wrap the actual retrieval of the function address in a lambda, and pass the lambda by template parameter instead:
it's not a "workaround", it's almost exactly what i did in my sample,
just not that hairy.

you can't get address of anything in compile time, 'cause there is no such address. but you can do it in runtime, of course. that's what you
doing: postponing "&" to runtime.

as far as I could google, no one has attempted this yet.
no one published it yet, not "no one attempted". i desperately need runtime reflection for my (still private) component builder project, so i'm slowly writing that mechanics. and my "command console" using similar technique to allow user inspect variables and classes, and call
function/methods in runtime.

I do something possibly similar for generating console help text using runtime reflection. It could have used compile-time reflection, but it gets annoying to use.

Using https://shardsoft.com/stash/projects/SHARD/repos/dap/browse/source/dap/Standalone.d (with https://shardsoft.com/stash/projects/SHARD/repos/shardtools/browse/source/ShardTools/CommandLine.d and https://shardsoft.com/stash/projects/SHARD/repos/shardtools/browse/source/ShardTools/Reflection.d?until=45ded3019f3f05d7b68e5746d34da1de7433ccf6), it generates something like:

D Asset Pipeline
Converts assets into an intermediate post-processed format more efficiently loaded at runtime.
Commands:
        [-h|--help]: Displays the help string.
[-a|--add]: Adds the given raw asset to the asset store using the default processor and default settings. [-r|--remove]: Removes the asset with the specified qualified name from the asset store.
        [-l|--list]: Lists all assets currently stored.
[-b|--build]: Builds all dirty assets using current settings.
        [-i|--inspect]: Shows all properties of the given asset.
[-m|--modify]: Modifies a property of a processor on an asset, or the processor used to build the asset.
Options:
[--input-folder]: The folder that assets should be read from and settings stored in. Default: Content\Input [--output-folder]: The folder that generated assets should be saved to. Default: Content\Output [--log-level]: The minimum severity for a message to be logged. Default: info


The command lines then invoke methods registered through runtime reflection, which allow the user to change individual properties on the set processor using --modify, again using runtime reflection to find the setting that the user wants and converting their input to the appropriate type.

Reply via email to