D-ideas collection

cy via Digitalmars-d digitalmars-d at puremagic.com
Sat Aug 27 11:49:41 PDT 2016


D syntax improvement ideas, huh?

Make UFCS work for locally defined functions, with a pragma or 
something, because it can confuse people, but it can also be 
useful for state machines on ranges, and to avoid cluttering up 
module namespaces.

Pass a block of code as an argument, outside the parentheses. 
like foo!(bar,baz) { stuff } would be defined as template 
foo(bar,baz,block stuff) { ... } or something.

(incidentally you can sort of do this already, for instance by 
making a struct that completes evaluation after you call 
opBinary(string op, void delegate()) if op == "|", then 
makestruct(foo,bar) | { stuff })

Allow struct initializers to construct function arguments. I 
mean, seriously. We already practically have support for keyword 
arguments, except for this.

void foo(Something info) {...}

foo({
   arg: 23,
   arg2: 42,
   keyword: value
});

I dunno, optional parentheses if there's just one argument? So 
you could do void foo(void delegate() bar) { ... } then just foo 
{ stuff } instead of foo({ stuff })


More information about the Digitalmars-d mailing list