Feedback on Átila's Vision for D
Meta
jared771 at gmail.com
Tue Oct 15 15:05:52 UTC 2019
On Tuesday, 15 October 2019 at 13:09:15 UTC, Mike Parker wrote:
> This thread is for general feedback and discussion regarding
> Átila's blog post on his vision for D's future.
>
> https://dlang.org/blog/2019/10/15/my-vision-of-ds-future/
"Instead of disparate ways of getting things done with fragmented
APIs (__traits, std.traits, custom code), I’d like for there to
be a library that centralizes all reflection needs with a great
API."
Yes, 100% agreed. Another benefit of having one unified API is
that it's easier to paper over the weird differences between
various methods of doing reflection.
Ex:
is(typeof({ return x + x; })) vs __traits(compiles, { return x +
x; })
__traits(identifier, x) vs. x.stringof (x.stringof will fail to
compile if x is a function with at least 1 parameter, but
__traits(identifier) works)
I'm curious, is Atila's work on this building on Andrei's? I
remember him talking about his work on a reflection library at a
recent DConf (I think it was last year's).
"String interpolation"
I've been finding a lot of places in my code where string
interpolation would make it much more readable. It would be nice
to be able to use them in invariants, in contracts, out
contracts, and assert statements, e.g.:
struct OneIndexedArray(T)
{
T[] store;
T opIndex(size_t i)
in (i > 0, "Index $i is out of range for
$(OneIndexedArray.stringof)")
in (i < store.length,
"Index is out of range for $(OneIndexedArray.stringof)
(length: $(store.length), index: $i")
{
...
}
}
It's a real pain having to stick a
`.format(OneIndexedArray.stringof, store.length, i)` at the end
of the message.
pragma(msg) get's this right, presumably because it's a compile
time-only construct.
More information about the Digitalmars-d
mailing list