Seeking advice on programming style

Victor Porton porton at narod.ru
Mon Dec 31 21:51:11 UTC 2018


I have (in D bindings of a C library, which I am writing):

module rdf.raptor.uri;

struct URIWithoutFinalize {
   // ...
}

struct URI {
   // ...
   @property URIWithoutFinalize base() { /* ... */ }
   alias base this;
}

(in fact, these structs are created by a system of template 
mixins).

The two structs differ mainly by their destructor behavior.

What can you advice to put non-member functions?

1. module scope (but then they may need to have long names to 
disambiguate with other modules).
2. as statics in URIWithoutFinalize (but then the full name of 
the functions would contain WithoutFinalize what is not quite 
about what they are).
3. as statics in URI (but then they are in a logically derived 
struct, while may belong logically to the base that is to 
URIWithoutFinalize)
4. in a new struct specifically created to hold static function 
(but then how to name it?)


More information about the Digitalmars-d mailing list