View previous topic :: View next topic |
Author |
Message |
mutable
Joined: 22 Jun 2010 Posts: 87
|
Posted: Sun Sep 12, 2010 6:51 am Post subject: in or const? |
|
|
I use dmd 2 compilers and am uncertain if I write in my methods "const" or "in", because I have read that "in" is a shorthand for "const" in D 2.
Now I stand between the fronts, if i take Code: | void foo(const ushort width) const {
//...
} | or Code: | void foo(in ushort width) const {
//...
} |
What is your meaning?
Or does this completely make no difference? |
|
Back to top |
|
|
mutable
Joined: 22 Jun 2010 Posts: 87
|
Posted: Mon Sep 13, 2010 2:32 pm Post subject: |
|
|
I will probably use in future "in" instead of "const".
I had not thought that it lasts days, until somebody answers on my "either - or" question. Nevertheless, thank you |
|
Back to top |
|
|
Austin
Joined: 27 Sep 2010 Posts: 1
|
Posted: Mon Sep 27, 2010 1:18 am Post subject: |
|
|
Howdy,
According to TDPL, "in" is a synonym for "const."
But for readability, "in" does not convey "this is never modified by the function" in quite the way that "const" does.
So I'd rather read code that had "const int x" instead of "in int x", since "const" tells me something without needing to check the manual.
=Austin |
|
Back to top |
|
|
|