Should this work?

Dicebot public at dicebot.lv
Mon Jan 27 06:34:30 PST 2014


On Monday, 27 January 2014 at 14:27:42 UTC, Regan Heath wrote:
> On Sat, 25 Jan 2014 10:15:28 -0000, Peter Alexander 
> <peter.alexander.au at gmail.com> wrote:
>> Special cases are pure evil. There's nothing special about 
>> strings in this case.
>
> This is a tangent to my suggestion.
>
> I am arguing for domain specific language (aliases) where 
> sensible, not domain specific functions.  If canFind can 
> already handle all the desirable string cases, perfect, but 
> lets alias it in std.string as "contains" so that people find 
> what they expect to find first time and don't get frustrated 
> looking for the correct generic name for the functionality they 
> want.
>
> There are likely other cases where we already have all the 
> functionality in a nice generic function, but people struggle 
> to find it because it has a suitably generic name.
>
> I just want us to lower the bar for beginners coming from other 
> languages like Java and C#.
>
> R

I think that is a small short-term learning advantage but huge 
long-term damage for code readability. Now you suddenly need to 
not only remember what Phobos can do but also all defined aliases 
for that stuff.

What could have been awesome is to be able to define such aliases 
via DDOC so that IDE's can understand them and list in 
auto-completion, while still putting "real" name in source code. 
It would have solved discoverability issue without harming naming 
consistency.


More information about the Digitalmars-d mailing list