Should we have an Unimplemented Attribute?

Jonathan M Davis jmdavisProg at gmx.com
Wed Feb 2 18:24:50 PST 2011


On Wednesday, February 02, 2011 17:48:05 Simen kjaeraas wrote:
> Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> > On Wednesday, February 02, 2011 16:16:00 Andrej Mitrovic wrote:
> >> On 2/3/11, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> >> > Usually the thing to do would be to either comment them out or put an
> >> > assert(0)
> >> 
> >> Can't do that with classes and struct.
> > 
> > ??? You can comment out classes and structs just fine. You can also
> > comment out
> > member functions of classes and structs just fine. You can put assert(0)
> > in
> > member functions of classes and structs just fine. In this case, it
> > sounds like a
> > particular member function should have been commented out but wasn't.
> > 
> > - Jonathan M Davis
> 
> I think he means that any use of an @unimplemented class should give a
> warning/error/other message.

Well ,that makes some sense, but a struct or class is pretty useless without its 
methods, so it would quickly become obvious that it wasn't fully implemented 
when you used it if the methods had assert(0) in their bodies (especially if a 
propery message went with it). However, code that isn't ready yet really should 
just be commented. I think that it's happened in the past that stuff in Phobos or 
druntime has been left in there unfinished but undocumented on the theory that 
because it was undocumented, it wasn't an issue. And I don't think that that's 
necessarily a good practice. The fact that auto functions haven't showed up the 
docs causing people to look through the source hasn't helped any either.

Really, code that isn't ready yet should be commented out unless there's a 
really good reason to leave it in there unfinished, in which case it should 
almost certainly be using assert(0) so that it blows up when you try and use it.


- Jonathan M Davis


More information about the Digitalmars-d mailing list