arsd.qrcode introduced and on my wish list: __arguments.

Posted 2021-07-26

I added a qrcode module and wish we had a tuple of arguments in all functions, not just variadics.

Core D Development Statistics

In the community

Community announcements

See more at the announce forum.

What Adam is working on

I added an arsd.qrcode module this week. It is a simple direct port of a C library with a bare minimum D wrapper added. Porting C code is boring, but it really doesn't take long and then you can use it so much more easily in D, since dmd -i can pick it right up (though if you do compile the C ahead of time and bind to it, dmd -i can also pick it up there, just that's harder to distribute since the user must also compile the C code separately).

Anyway, it only generates, it doesn't scan. That's enough for me right now, it is just for a little weekend toy im making. Don't expect much development on this, but since it was based on a reasonably solid looking C library, it will probably work ok too. Main thing I might do is change some of those pointers to slices.

This will probably be included not in the next tag, but in the tag after that to give me a chance to stabilize it.

On my wish list

I often wish there was a tuple of the function's arguments available. I call it __arguments. D already has something similar for the D-style variadics, but I'd like to see it for all functions.

void foo(int a, int b) {
     auto c = __arguments[0]; // same as int c = a;
     writeln(__arguments); // same as writeln(a, b);
}

It is such a little thing but it would make that kind of forwarding a lot easier.

I also wouldn't mind a __this_function thing, but that's fairly easy to hack around with __traits(parent, {}). And yah, you could kinda do some weird mixin thing with traits(parent) and pulling out the parameters tuple and mixing in the names. But much better to just have __arguments that just works.