I recall having seen an example of using some D magic (via mixin
perhaps?) to realize tuple destructuring in assignments like
magic(first, _, second) = expression.findSplit(separator);
somewhere. But I can't seem to find it right now.
References anyone?
BTW :I'm aware of Kenjis PR, which
On Friday, 15 May 2015 at 10:23:24 UTC, Per Nordlöw wrote:
I recall having seen an example of using some D magic (via
mixin perhaps?) to realize tuple destructuring in assignments
like
magic(first, _, second) = expression.findSplit(separator);
I found it:
http://forum.dlang.org/thread/u
On Friday, 15 May 2015 at 10:23:24 UTC, Per Nordlöw wrote:
I recall having seen an example of using some D magic (via
mixin perhaps?) to realize tuple destructuring in assignments
like
magic(first, _, second) = expression.findSplit(separator);
somewhere. But I can't seem to find it right
On Friday, 15 May 2015 at 10:46:32 UTC, Per Nordlöw wrote:
Can this be solved with a mixin somehow?
To clarify, I want to be able to write
let(first, _, second) = expression.findSplit(separator);
without having to first declare `first`, `_` and `second`.
I'm guessing the closest thing we
On Friday, 15 May 2015 at 11:04:24 UTC, Per Nordlöw wrote:
I'm guessing the closest thing we can get in current D version
is something like
let(q{first, _, second},
expression.findSplit(separator));
right?
Correction: I believe it must look like
let!q{first, _, second}(expr
import std.algorithm;
template magicassign(A...) {
void magicassign(B)(B b) @property {
foreach(I, ref a; A)
static if (!is(typeof(A[I]):typeof(null)))
a = b[I];
}
}
template let(string D) {
mixin({
enum sdsl = D.findSplit
On Friday, 15 May 2015 at 12:22:55 UTC, Artur Skawina wrote:
import std.algorithm;
template let(string D) {
mixin({
enum sdsl = D.findSplit("=");
mixin(`struct S { int `~sdsl[0]~`; }`);
string code = `auto v = ` ~ sdsl[2] ~ `;`;
foreach (I, _; type
On Friday, 15 May 2015 at 12:22:55 UTC, Artur Skawina wrote:
template let(string D) {
mixin({
enum sdsl = D.findSplit("=");
mixin(`struct S { int `~sdsl[0]~`; }`);
string code = `auto v = ` ~ sdsl[2] ~ `;`;
foreach (I, _; typeof(S.tupleof))
On Friday, 15 May 2015 at 13:40:01 UTC, Per Nordlöw wrote:
I added support for auto, const and immutable declarations at
https://github.com/nordlow/justd/blob/master/ties.d#L96
And support for ignoring `_` as a variable as:
import std.algorithm.searching: findSplit;
mixin let!q{ c, _,