Thread overview
static const methods
Aug 06, 2002
Sandor Hojtsy
Aug 07, 2002
Sean L. Palmer
Aug 08, 2002
Walter
Aug 21, 2002
Sandor Hojtsy
Aug 23, 2002
Walter
August 06, 2002
In C++, this was disallowed:

class Someting {
  static void Method() const;
};

It should mean a static method which should not change any of the static
members.
As compared to the allowed:

class Someting {
  void Method() const;
};

Meaning a non-static method, which should not change any of the members. Does / will D support static const methods?

Yours, Sandor


August 07, 2002
In D, const is a storage class, not a modifier or attribute.    It's not part of the type system.

Sean

"Sandor Hojtsy" <hojtsy@index.hu> wrote in message news:aio9j9$hjk$1@digitaldaemon.com...
> In C++, this was disallowed:
>
> class Someting {
>   static void Method() const;
> };
>
> It should mean a static method which should not change any of the static
> members.
> As compared to the allowed:
>
> class Someting {
>   void Method() const;
> };
>
> Meaning a non-static method, which should not change any of the members. Does / will D support static const methods?
>
> Yours, Sandor



August 08, 2002
"Sean L. Palmer" <seanpalmer@earthlink.net> wrote in message news:aiql5v$13cs$1@digitaldaemon.com...
> In D, const is a storage class, not a modifier or attribute.    It's not part of the type system.

Right. The const thing in C/C++ is a good idea, it just never worked out well in practice.


August 21, 2002
"Walter" <walter@digitalmars.com> wrote in message news:aisdjh$23t3$1@digitaldaemon.com...
>
> "Sean L. Palmer" <seanpalmer@earthlink.net> wrote in message news:aiql5v$13cs$1@digitaldaemon.com...
> > In D, const is a storage class, not a modifier or attribute.    It's not part of the type system.
>
> Right. The const thing in C/C++ is a good idea, it just never worked out well in practice.
>

There is no need to call this property "const", if it bothers you.

class Someting {
   void restricted Method();
};

Such a method should be unable to change any member values. I found such restrictions usefull.



August 23, 2002
"Sandor Hojtsy" <hojtsy@index.hu> wrote in message news:ajvpgs$g7i$1@digitaldaemon.com...
> There is no need to call this property "const", if it bothers you.
>
> class Someting {
>    void restricted Method();
> };
>
> Such a method should be unable to change any member values. I found such restrictions usefull.

Dealing with const/volatile attributes permeates the C++ spec, and causes a great deal of complexity and implementation grief. The benefit isn't there for the added complexity.