October 13
On Wednesday, 13 October 2021 at 10:55:59 UTC, Timon Gehr wrote:
> On 10/11/21 1:43 PM, Stefan Koch wrote:
>> risk of having my work "re-appropriated"
>
> Why do you think there is such a risk?

I have had experience which indicates there is.

I want to avoid a cargo-cult version of core.reflect.

Not just because it took me months of research but also because I am not done yet.

My vision for this is to enable new styles of meta-programming.

And for that to happen, there mustn't be a watered down version in the language.

October 13

On Wednesday, 13 October 2021 at 19:16:48 UTC, Stefan Koch wrote:

>

On Wednesday, 13 October 2021 at 10:55:59 UTC, Timon Gehr wrote:

>

On 10/11/21 1:43 PM, Stefan Koch wrote:

>

risk of having my work "re-appropriated"

Why do you think there is such a risk?

I have had experience which indicates there is.

I want to avoid a cargo-cult version of core.reflect.

Not just because it took me months of research but also because I am not done yet.

My vision for this is to enable new styles of meta-programming.

And for that to happen, there mustn't be a watered down version in the language.

👍

October 14

On Monday, 11 October 2021 at 11:43:14 UTC, Stefan Koch wrote:

>

Good day to you.

I have decided to release a preview binary for core.reflect.
And I am including the low-level-runtime.

Cheers,

And let me know how you like it.

Wow, this is great! Just ran the demo on WSL2.

There are many uses for it. Off the top of my head, recently Rikki wrote for me a mixin which generated a C ABI for any D class. This could be used in a similar way to generate wrappers very easily I imagine.

It could probably be useful for IDE tooling as well.

mixin template CWrapper(Type) {
    import std.traits;

    export extern(C):

    pragma(mangle, "create_" ~ __traits(identifier, Type))
    void* creator(Parameters!(Type.__ctor) args) {
        return cast(void*)new Type(args);
    }

    mixin(() {
        string ret;

        foreach(m; __traits(allMembers, Type)) {
            static if (m != "__ctor" && m != "__dtor" && isFunction!(__traits(getMember, Type, m))) {
                ret ~= `ReturnType!(__traits(getMember, Type, "` ~ m ~ `")) ` ~ __traits(identifier, Type) ~ `_` ~ m ~ `(void* obj, Parameters!(__traits(getMember, Type, "` ~ m ~ `")) args) { return (cast(Type)obj).` ~ m ~ `(args); }`;
            }
        }

        return ret;
    }());
}

class Foo {
    int x;
    this(int x) { this.x = x; }
    int getX() { return x; }
}
mixin CWrapper!(Foo);

// GENERATED CODE:
extern(C) {
    void* create_Foo(int); // returns void* to Foo instance
    int Foo_getX(void*); // takes void* to Foo instance
}
October 14

On Thursday, 14 October 2021 at 19:10:24 UTC, Gavin Ray wrote:

>

On Monday, 11 October 2021 at 11:43:14 UTC, Stefan Koch wrote:

>

Good day to you.

I have decided to release a preview binary for core.reflect.
And I am including the low-level-runtime.

Cheers,

And let me know how you like it.

Wow, this is great! Just ran the demo on WSL2.

There are many uses for it. Off the top of my head, recently Rikki wrote for me a mixin which generated a C ABI for any D class. This could be used in a similar way to generate wrappers very easily I imagine.

It could probably be useful for IDE tooling as well.

I am happy you tried it. And yes use-cases like the one you describe are exactly what core.reflect is meant to help with.

I am aiming for it to be intuitive enough that I won't have to write lots of documentation.

Next ›   Last »
1 2