Segment violation (was Re: Why I could not cast string to int?)
bearophile
bearophileHUGS at lycos.com
Thu Feb 2 15:14:25 PST 2012
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".
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list