The daily D riddle

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Jan 28 08:36:02 UTC 2018


On Sun, Jan 28, 2018 at 12:27:52AM -0800, Walter Bright via Digitalmars-d wrote:
> On 1/28/2018 12:05 AM, Jonathan M Davis wrote:
> > As to _why_ it works, I don't know - it seems like a bad idea to me
> > - but it does.
> 
> It's so your code needn't care whether it is a static member or not,
> just the implementer of the class needs to care.

Is there a practical use case for which this is actually useful?

Most of the time, if I'm calling a static method, there's a specific
reason why it's a static method rather than a normal method, e.g., it
could be a factory method for constructing an instance of the class.  It
wouldn't make any sense for code calling that method to need an object
to invoke it with.  Conversely, if I'm calling a non-static method, the
expectation is that it's doing something to a specific instance of the
class, not something global to all instances.  While theoretically it
*could* be useful to be agnostic about whether a method is static or
non-static, I can't think of any real-world use case for it.  Do you
have one in mind?


T

-- 
Your inconsistency is the only consistent thing about you! -- KD


More information about the Digitalmars-d mailing list