On 8/31/11 11:29 PM, David Nadlinger wrote:
On 8/25/11 8:53 AM, Jacob Carlborg wrote:
On 2011-08-24 20:36, jdrewsen wrote:

One way that may improve this would be to move the static methods
outside the class and make them into module functions instead.

The drawbacks of this is:

1, When importing the module there would be more symbols polluting the
namespace.

[…]
You could wrap the free functions in a Curl struct:

Curl.get(...);


Please don't (ab)use classes/structs as namespace if you don't have a
really good reason to do so – D offers static and/or selective imports
for situation where one doesn't want to pollute the scope when importing
something. When using free functions, one can always do »static import
etc.curl;«, but there is no way back once a dummy struct is used (well,
technically I think it would be possible to write a mixin template that
aliases all struct members into the local scope, but…).

David

Polluting the global namespace: it's called "dealing with the language" instead of "dealing with the problem you want to solve".

Reply via email to