On 2014-06-26 10:38:53 +0000, bearophile said:
For people that are not following closely what's happening in GitHub,
there are some nice or very nice patches waiting to be fixed and/or
accepted, among the last ones:
--------------------
This proposes a __traits(documentation, expr):
https://github.com/D-Programming-Language/dmd/pull/3531
Something similar is used in Python and Lisp, it allows to introspect
the comments. It's useful for various generative purposes.
One quirk of this implementation, that I am not sure about:
Comments will only be available if DMD is invoked with the "-D" flag.
If no comment is available for expr, __traits(comment, expr) evaluates
to the empty string.<
--------------------
Optional monitors for class instances, including a fallback:
https://github.com/D-Programming-Language/dmd/pull/3547
It was discussed in this newsgroup too. Beside the little save in
memory (probably small), monitors today are not much appreciated.
Andrei seemed to agree with this idea.
--------------------
https://github.com/D-Programming-Language/dmd/pull/3615
Will allow very handy, more DRY and less bug-prone like this:
// static array type
int[$] a1 = [1,2]; // int[2]
auto[$] a2 = [3,4,5]; // int[3]
const[$] a3 = [6,7,8]; // const(int[3])
// dynamic array type
immutable[] a4 = [1,2]; // immutable(int)[]
shared[] a5 = [3,4,5]; // shared(int)[]
// partially specified part is unqualified.
// pointer type
auto* p1 = new int(3); // int*
const* p2 = new int(3); // const(int)*
// mixing
auto[][$] x1 = [[1,2,3],[4,5]]; // int[][2]
shared*[$] x2 = [new int(1), new int(2)]; // shared(int)*[2]
A comment by Walter:
My reservation on this is I keep thinking there must be a better way than [$].<
--------------------
https://github.com/D-Programming-Language/dmd/pull/3638
Allows to write code like:
void main() {
import std.algorithm;
alias sqr = a => a ^^ 2;
auto r = [1, 2, 3].map!sqr;
}
Currently you need to write:
alias F(alias f) = f;
void main() {
import std.algorithm;
alias sqr = F!(a => a ^^ 2);
auto r = [1, 2, 3].map!sqr;
}
--------------------
https://github.com/D-Programming-Language/dmd/pull/3679
This introduces __traits(valueRange, expr), and I think it introduces
range values to the ?: expressions too.
The __traits(valueRange, expr) is meant to be useful for debugging
range values, that is meant to be improved in future. Currently this
patch seems stalled because Lionello seems to not provide few small
things Walter has asked.
--------------------
https://github.com/D-Programming-Language/dmd/pull/3680
It should fix this bug:
void main() {
int[int][int] a1 = cast()[1: [2: 3]]; // workaround
int[int][int] a2 = [1: [2: 3]]; // error
}
And will allow you to write:
void main() {
import std.bigint;
BigInt[] data = [-5, 6, 9];
}
Currently in D you have write this:
void main() {
import std.bigint;
auto data = [BigInt(-5), BigInt(6), BigInt(9)];
}
Or this (writing -5.BigInt is generally not a good idea):
void main() {
import std.bigint;
auto data = [BigInt(-5), 6.BigInt, 9.BigInt];
}
--------------------
Bye,
bearophile
Some of those fix some very annoying and long standing bugs. Whoot.
-Shammah