Re: Rationale for CS0536?




<elvis_the_king@xxxxxx> wrote in message
news:1126558497.073068.177850@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> Daniel O'Connell [C# MVP] schrieb:
>
>> Thread t = ...;
>> t.Sleep(10);
>>
>> What does that look like its doing to you? To me it looks like its
>> putting
>> the thread referenced by t to sleep, however, its not. It is putting the
>> current thread to sleep since Sleep is a static method. If you did around
>> you will find alot of examples where that occurs.
>
> Well, that sounds reasonable; but I would just consider that a bad
> design or even naming problem, nothing that would have to be
> interdicted by the language itself?

It is not bad design, calling statics via instances is a bad idea. Allowing
what Java and C++ does and waht you suggested causes that problem.

>
> Besides that - I think I've seen compiler errors that say static
> members have to be qualified with a type name, not an instance
> (CS0176)? But probably that gets off-topic here.

Weren't you just asking why the compiler didn't let you call static methods
through instances and now you are using the compilers actual behavior as an
argument against my reason for the compiler acting that way? That just
doesn't make any sense, to be honest.


.



Relevant Pages

  • Re: Static methods overridden !!
    ... In Java overriding /is/ polymorphism. ... First off, as you also know, you can invoke any static method from any ... When it comes right down to it -- i.e. in terms of how the compiler treats ...
    (comp.lang.java.programmer)
  • Re: Microfocus Cobol "SLEEP" routine
    ... I had tried this but the compiler returns an error if there is no screen ... Is there a way in MF Cobol to pause program execution (sleep) for, ... Vaclav Snajdr ...
    (comp.lang.cobol)
  • Re: pascal equivalent of python "sleep"
    ... A conforming C compiler is compiler + its std libraries, ... I haven't been able to find a lowercase sleep() in msdn. ... linux windows) on different hardware and with several C compilers. ... If you can't be bothered to specify, I can't be bothered to find, so I ...
    (comp.lang.pascal.misc)
  • Re: pascal equivalent of python "sleep"
    ... Then find a sleep() in a strictly conforming C compiler! ... Surprise you will not find a function like C in a C compiler. ... linux windows) on different hardware and with several C compilers. ... If you can't be bothered to specify, I can't be bothered to find, so I ...
    (comp.lang.pascal.misc)
  • Re: Another shitty example of exceptions
    ... Because Free is a static method. ... the compiler resolves the Free method and for ... and inspection of the object X refers to is necessary. ... that's an access violation - you can't dereference nil. ...
    (alt.comp.lang.borland-delphi)