Seeking advice on programming style
Andre Pany
andre at s-e-a-p.de
Tue Jan 1 08:23:07 UTC 2019
On Monday, 31 December 2018 at 21:51:11 UTC, Victor Porton wrote:
> 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?)
Little bit off topic.
Curl now exposes its URL api. It would be great if it could be
added to Phobos:)
https://daniel.haxx.se/blog/2018/09/09/libcurl-gets-a-url-api/
Kind regards
Andre
More information about the Digitalmars-d
mailing list