Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact and its use of FileConduit..

Moderators: kris

Posted: 08/08/07 03:01:10


I'm not sure whether lines like

auto conduit = new FileConduit(..);

should instead be

scope conduit = new FileConduit(..);.

I also wonder whether it would be a good idea in the read () function to supply a style struct to the FileConduit that has the cache byte set to FileConduit.Cache.Stream?

Author Message

Posted: 08/08/07 16:27:23

Not an expert on D, but I think you are confused on the meaning of auto. Auto simply tells the compiler to pick the type of the variable you are defining based on what you are assigning it.

scope tells the compiler to call the destructor when the current scope goes away. IIRC, the second line you have there won't compile because scope is an attribute, not a type.

Could be wrong though, very new to D :)

Posted: 08/08/07 23:42:08 -- Modified: 08/08/07 23:51:57 by
r.lph50 -- Modified 2 Times

The compiler can infer the type with a few attributes: static, const, scope as well as the storage class that no longer does anything: auto (the spec).

auto was used in earlier versions of D to get scoped classes. I wonder if then, there is a vestigal use of it because the FileConduit is only used in the scope of the method so would be a prime candidate.

What I am not sure about is how a scoped object's destructor interacts with a scope(exit) call to a method of that object.

Posted: 08/10/07 14:48:29

Interesting. This is good to know. I was under the impression that only the "auto" keyword takes the place of the type, and that the other attributes cannot do the same. I have a lot to learn :)