Re: current type in static methods

From: codymanix (no_spam_deutronium_at_gmx.net)
Date: 03/24/04


Date: Wed, 24 Mar 2004 15:28:51 +0100


> >> And what would you consider this to mean?
> >>
> >> class A
> >> {
> >> static int s=1234;
> >>
> >> int getS()
> >> {
> >> return class.s; //note the use of class here
> >> }
> >> }
> >>
> >> My point is more in should class exist within instance methods, or
should
> > it
> >> be valid only in static.
> >
> >
> > if a keyword "class" could be used to identify the current class, it
> > should
> > be allowed in static *and* instance methods,
> > because using GetType() or class has a different meaning, so using class
> > in
> > instance method is useful too
[..]
> Which misses my point entirely. I was suggesting the usage of class as a
> pointer similar to this, instead of as a type explictly, typeof(class) may
> or may not make sense in this particular situation.
>
> Personally, typeof(class) is far to limited to be a feature on its own. It
> introduces a use of class that is inconsistent with the rest of hte
> langauge.

either we say that in *both* static and instance methods we can say
typeof(this) and this.DoIt()
or we say in static methods we must use typeof(class) and class.DoIt()
instead.

these are the options. the first option alters the meaning of the "this"
keyword which is not good.
the latter would allow the existing keyword "class" to be used within
methods where it was disallowed up to this time.

--
cody
Freeware Tools, Games and Humour
http://www.deutronium.de.vu  || http://www.deutronium.tk


Relevant Pages

  • Re: What is/are the difference(s) between assertSame and assertEquals in JUnit?
    ... It would have made the meaning of it more obvious. ... This extends the convention that "isX" expresses a boolean condition "X", and avoids the noise-word "Object" in the method name. ... May be it is not 'assertIsSame' as it is not an instance method and takes up two arguments, so one may think of 'assertAreSame'. ...
    (comp.lang.java.programmer)
  • Re: Help -- New to Java
    ... You'll need a method name that isn't a keyword. ... public static int mean{ ... This could just as well be an instance method. ... /// Bjorn A ...
    (comp.lang.java.help)
  • Re: random number generator help
    ... You are calling an instance method from a static method. ... It will work if you add the keyword "static" to the instance method: ... private static int RandomNumber ... Random random = new Random; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: new-style classes and len method
    ... the meaning of "classmethod", thinking of it as an instance method. ... class object, such a confusion is not so surprising!-) ...
    (comp.lang.python)
  • Re: new-style classes and len method
    ... I was misunderstanding ... the meaning of "classmethod", thinking of it as an instance method. ...
    (comp.lang.python)