Example for Documentation?

Meta via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 21 12:00:15 PDT 2015


On Tuesday, 21 April 2015 at 17:30:08 UTC, Steven Schveighoffer 
wrote:
> quoted lambdas are indeed shorter, but the issue with them is 
> that "a<b" instantiates a different template than "a < b", 
> whereas the lambda does not.
>
> In fact, that is why we added shorthand lambdas to the 
> language. Note that in this case, it's just wasted code space 
> and not a real issue. but for example, RedBlackTree!(int, "a < 
> b") is not compatible with RedBlackTree!(int, "a<b"), even 
> though they are identical.
>
> I'm not saying we shouldn't allow string lambdas, just that we 
> shouldn't encourage them as "proper" D code.

Unfortunately, it doesn't work at all for lambdas.

RedBlackTree!(int, (a, b) => a < b) tree1;
RedBlackTree!(int, (a, b) => a < b) tree2;

//Fails
assert(is(typeof(tree1) == typeof(tree2)));


More information about the Digitalmars-d mailing list