Non-ugly ways to implement a 'static' class or namespace?

ryuukk_ ryuukk.dev at gmail.com
Wed Jan 25 15:43:46 UTC 2023


On Monday, 23 January 2023 at 00:11:17 UTC, thebluepandabear 
wrote:
> On Sunday, 22 January 2023 at 18:30:59 UTC, ryuukk_ wrote:
>> On Friday, 20 January 2023 at 11:28:23 UTC, thebluepandabear 
>> wrote:
>>
>>
>> D is not java/C#, it's better than that!
>>
>>
>> ```D
>>
>> // api.d
>>
>> void draw(){}
>>
>>
>> // app.d
>>
>> import API = api;
>>
>>
>> void main()
>> {
>>     API.draw();
>> }
>>
>> ```
>
> Sorry don't like that solution specifically. That's because it 
> is a procedural implementation, not an OOP-style one. I don't 
> know how much of the D community writes procedurally but I'm 
> personally an OOP-type of guy.

using static class and static function is not "OOP way" of doing 
things, it's a hack to mimic procedural style because Java 
doesn't have proper modules / scoping

mimicking the shortcomings of Java is a bad idea imo

D empowers you to write simple yet effective code, you should 
give it a try and embrace it




More information about the Digitalmars-d-learn mailing list