Worst ideas/features in programming languages?

Timon Gehr timon.gehr at gmx.ch
Tue Nov 23 14:05:49 UTC 2021


On 11/23/21 10:09 AM, bauss wrote:
> On Tuesday, 23 November 2021 at 07:55:45 UTC, Timon Gehr wrote:
>> On 12.10.21 23:38, Timon Gehr wrote:
>>>> * Features you'd like to see in D
>>
>> Another thing I have sometimes wished for, but forgot to include:
>>
>> - package and module templates
> 
> What do you mean by that?
> 
> Something like this? Or?
> 
> ```d
> module main;
> 
> import a!5;
> 
> void main()
> {
>      auto foo = new Foo;
>      foo.field4 = 10;
> }
> ```
> 
> ```d
> module a(int fieldCount);
> 
> import std.string : format;
> 
> class Foo
> {
>      static foreach (i; 0 .. fieldCount)
>      {
>          mixin(format("int field%d", i));
>      }
> }
> ```

Yes, something like this. Thanks for clarifying! This is a module 
template, I am not sure what's the best way to parameterize an entire 
package, maybe the declaration should be in every file like this:

module package_(T).a;


More information about the Digitalmars-d mailing list