Proposed Enhancement: Deprecate std.conv.text With 0 Arguments

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 23 15:46:18 PDT 2016


On Wednesday, 22 June 2016 at 15:39:11 UTC, Meta wrote:
> If it is called with 0 arguments it will return null.

No it will  return empty string.

> This  behaviour has caused several bugs in my code because
> combined with optional parens and UFCS, it is easy to 
> accidentally
> call text with 0 args but have it look like passing a variable 
> to a function. An example bug that I recently found in my code:
>

This is a problem with optional (), not text.

test takes n parameters and return a string representation of 
these parameters. returning an empty string when no parameters is 
provided is very much expected.

The alternative is to add special case. And here you get into the 
bad design land. When some bad design is introduced it causes 
problems. Now there is the option to introduce more and more bad 
design to work around the original bad design, or adopt a 
principled approach. I'd rather go for #2 . if I wanted #1, I'd 
be using C++ or PHP, which both fit that spot better than D.

When the solution to a problem is adding more special casing, you 
can be sure you are not moving in the right direction.



More information about the Digitalmars-d mailing list