Another use case for __traits(docComment)

Exil Exil at gmall.com
Tue Nov 12 01:22:09 UTC 2019


On Monday, 11 November 2019 at 17:54:07 UTC, Adam D. Ruppe wrote:
> On Monday, 11 November 2019 at 17:16:20 UTC, Steven 
> Schveighoffer wrote:
>> I still am very VERY leery of having anything in comments 
>> affect the code in any way.
>
> then just.... don't do that.

That won't stop other people.

> And btw for the record you could have comments affect code 
> right now:
>
> mixin((__LINE__ % 3) ? "one thing" : "other thing"); // adding 
> a comment above would change the line number and possibly 
> trigger the other thing!
>
>
> but such a thing is obviously absurd and nobody would write 
> that, unless maybe doing an obfuscated contest.

That isn't really all that useful. That line of code's only 
purpose is to be misused and cause misunderstanding.

Someone might come around and say, why modify documentation and 
code? Why not just modify documentation and then have the code 
read from that documentation and change behavior instead. That 
way you keep documentation and implementation in sync!

Kind of odd you have a 1:1 mapping for a scripting language 
anyways. That doesn't seem like a very rare occurrence. You don't 
pass any extra meta data for your implementations? They all have 
1:1 mapping for types? You implement things like pointers in your 
scripting language?





More information about the Digitalmars-d mailing list