D - What happened to const?
- Lio <Lio_member pathlink.com> Oct 07 2003
- "Philippe Mori" <philippe_mori hotmail.com> Oct 07 2003
- "Walter" <walter digitalmars.com> Oct 07 2003
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.
Oct 07 2003
I'm actually very fond of 'const' in C++. You can give (a pointer to) an
to anybody for reading only. I've looked through the docs but can't seem
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
Oct 07 2003
"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
to anybody for reading only. I've looked through the docs but can't seem
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.
Oct 07 2003









"Philippe Mori" <philippe_mori hotmail.com> 