Thread overview | |||||
---|---|---|---|---|---|
|
October 07, 2003 What happened to const? | ||||
---|---|---|---|---|
| ||||
I'm actually very fond of 'const' in C++. You can give (a pointer to) an object to anybody for reading only. I've looked through the docs but can't seem to find anything about 'const' in D. Did I miss it? Or was it removed, if so, why? L. |
October 07, 2003 Re: What happened to const? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lio | > I'm actually very fond of 'const' in C++. You can give (a pointer to) an object > to anybody for reading only. I've looked through the docs but can't seem to find > anything about 'const' in D. Did I miss it? Or was it removed, if so, why? > > L. > > Currently, const is used only as a stirage modifier and not a type modifier. IMHO, D give with one hand and take away with the other one. We have better "design by contract" but we miss full constness support... which also help to prevent errors. I think we should support constness at least on final objects (say a Point` a Rect or String class for example). In fact, I would say that we should support it on any object (except possibly for interface --- since they might interact with COM --- and in that case, QueryInterface would not be const so having interface won't break the constness of an object) Philippe |
October 07, 2003 Re: What happened to const? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lio | "Lio" <Lio_member@pathlink.com> wrote in message news:blu0np$2m7n$1@digitaldaemon.com... > I'm actually very fond of 'const' in C++. You can give (a pointer to) an object > to anybody for reading only. I've looked through the docs but can't seem to find > anything about 'const' in D. Did I miss it? Or was it removed, if so, why? 'const' exists in D as a storage class, not a type modifier (as in C++). There have been numerous long threads here discussing the pros and cons of it. |
Copyright © 1999-2021 by the D Language Foundation