On Thu, 08 Jan 2015 15:59:10 +0000
"Nordlöw" via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
wrote:

> On Thursday, 8 January 2015 at 15:49:46 UTC, Dragos Carp wrote:
> > On Thursday, 8 January 2015 at 15:45:27 UTC, Nordlöw wrote:
> >> Is
> >>
> >>    key in aa ? aa[key] : ValueType.init;
> >>
> >> the most efficient way to maybe return a value from an 
> >> associative array aa?
> >
> > aa.get(key, ValueType.init)
> 
> That was too easy ;)
> 
> It would be nice if the compiler could detect usage of aa.get() 
> automatically and issue either a diagnostics or transform it in 
> an optimization pass.
how can it? compiler doesn't know what the code is supposed to do. if
compilers will know such things someday, we can stop writing programs
altogether, as compilers will be able to write any program for us. ;-)

Attachment: signature.asc
Description: PGP signature

Reply via email to