Segment violation (was Re: Why I could not cast string to int?)

xancorreu xancorreu at gmail.com
Fri Feb 3 06:45:16 PST 2012


Al 03/02/12 00:14, En/na bearophile ha escrit:
> xancorreu:
>
>> But you "only" put a "in" in
>> recFactorial function argument. What this mean? **Why** this is more
>> efficient than mine?
> It wasn't meant to improve performance. "in" turns a function argument to "input only" (and eventually scoped too). Generally when you program in D2 it's a good practice to use immutability where you can and where this doesn't cause other performance or typing problems. Immutability avoids bugs, allows a stronger purity (and I have seen DMD is often able to compiler a little more efficient program if you use immutability/constants everywhere they are a good fit). So 95% of the arguments of your program are better tagged with "in".

Mmm. Thanks. It remembers me val in scala ;-)
I note it for  optimizations.
> Bye,
> bearophile



More information about the Digitalmars-d-learn mailing list