Where statement

bearophile bearophileHUGS at lycos.com
Sun Jul 25 06:12:02 PDT 2010


Trass3r:

>You immediately give the counter-argument? ^^<

I try to give both pros and cons :-)
I think when expressions get even more complex 'where' can help.


> Another possibility would probably be the following, but it's not as  
> compact and nice:
> 
> double c;
> {
>         double a = retrieve_a();
>         double b = retrieve_b();
> 
>         c = sqrt(a*a + b*b);
> }

If 'c' has a very complex type, you really want to use 'auto', but you can't there. In functional-style programming types can be very complex and long to write, for example the result of a map(filter(lazy generator)).

Bye,
bearophile


More information about the Digitalmars-d mailing list