Last update October 11, 2012

Doc Comments /
Declaration



Declarations    

Table of contents of this page
Declarations   
Comments   
Is abstract implemented?   
Can I get a deeper explaination of synchronized?   
Is there a more detailed in/out/inout documentation ?   
Links   

Comments    

Is abstract implemented?    

It is implemented, it just behaves differently to what you're expecting. From what I can see..

 class Parent
 {
     int foo();
 }

class Child : Parent { int foo() { return 20; } }

The above will not compile, *unless* I put 'abstract' in front of the class, or the method 'foo' eg

 abstract class Parent
 {
     int foo();
 }
or

 class Parent
 {
     abstract int foo();
 }

so abstract allows a class to have undefined method bodies. It does not prohibit instantiation of a class as long as it has all it's method bodies.

I do like the fact that you do not need to place abstract on all the methods of a class, one abstract on the class definition will affect all methods in the class.

I do not like the fact that you cannot provide bodies and still prohibit instantiation of the abstract class.

These are my gut reactions, maybe it's time for a rethink, perhaps D has it right, if a class has all it's method bodies, why prohibit it's instantiation? In which case placing abstract in front of the class or method (with a body) should give an error.

Regan.

From NG:digitalmars.D/5867

Can I get a deeper explaination of synchronized?    

I'd like some examples, of where and how to use it. For example, is it per-function synchronisation, or can all the functions in a class be synchronized? I.e, a global lock for all functions within the class.

Is there a more detailed in/out/inout documentation ?    

See: http://dlang.org/function.html#parameters

Right now I found out by experimenting that

 void foo(out char[] x) {
   x ~= "content";
 }
behaves like
 void foo(ref char[] x) {
   char[] tmp;
   tmp ~= "content";
   x = tmp;
 }
and I don't even know if I can rely on this behaviour.

Links    


FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: October 11, 2012 4:45 (diff))