On 2011-08-29 16:10, Daniel Murphy wrote:
"Jacob Carlborg"<d...@me.com>  wrote in message
news:j3fi1u$1uge$1...@digitalmars.com...
I just got and idea, what about allowing to overload methods based on if
they're static or not.

 From my list of 'Andrei' bugs:
http://d.puremagic.com/issues/show_bug.cgi?id=3345

It sounds like a good idea, but what are the real use cases and what are the
corner cases?

In my serialization library, Orange, I want to have a "reset" method that is both static and non-static. The static method would reset some static variables while the non-static method would reset the instance variables.

Another use case is to have a static and non-static opDispatch at the same time. I've been playing around with the idea of having something similar to Ruby on Rails' activerecord implemented in D. In activerecord you can do something like this:

p = Person.find_by_name("Joe")
name = p.name

Both "find_by_name" and "name" are implemented using "method_missing" (Ruby's opDispatch). In D, this would require both a static and a non-static opDispatch.

I've already mentioned the issue when inside a class/struct and a solution, don't know if that counts as a corner case. That's the only issue I can think of so far.

--
/Jacob Carlborg

Reply via email to