FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

in or const?

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
mutable



Joined: 22 Jun 2010
Posts: 87

PostPosted: Sun Sep 12, 2010 6:51 am    Post subject: in or const? Reply with quote

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
View user's profile Send private message
mutable



Joined: 22 Jun 2010
Posts: 87

PostPosted: Mon Sep 13, 2010 2:32 pm    Post subject: Reply with quote

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 Wink
Back to top
View user's profile Send private message
Austin



Joined: 27 Sep 2010
Posts: 1

PostPosted: Mon Sep 27, 2010 1:18 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group