Static foreach bug?

Soma soma at gmail.com
Mon Sep 3 18:03:18 UTC 2018


On Sunday, 2 September 2018 at 19:42:20 UTC, bauss wrote:
> unmaintainable piece of code:
>
> ```
> final class ClassName : SoapBinding, Interface
> {
>   public:
>   final:
>   this()
>   {
>     super();
>   }
>    import __stdtraits = std.traits;
>    static foreach (member; __traits(derivedMembers, Interface))
>   {
>     mixin
>     (
>       mixin("(__stdtraits.ReturnType!" ~ member ~ ").stringof") 
> ~
>       " " ~
>       member ~
>       "(" ~
>         mixin("parameters!" ~ member) ~
>       ") { /* Do stuff ... */ }"
>     );
>   }
> }
> ```

Sorry to disrupt your threat, but as a lurking in this forum 
using D for small projects, and after looking such snippet my 
first impression is how D is getting polluted and becoming more 
like Java and C++.

"final class", "public final this", "super"...

And of course this is just the beginning, other attributes:

"inout", "@disable", "@system".

And keeps funny when names are somewhat 'synonymous': "shared", 
"__gshared"

or like these 3: "@safe", "@trusted", "pure"

or like these 2: "const", "immutable".

And the list goes on and on...

For beginners (Or even average programmers) it would be "very 
nice" to not confuse them.

Soma.


More information about the Digitalmars-d mailing list