ranges of characters and the overabundance of traits that go with them

Dukc via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 16 05:04:39 PDT 2017


On Monday, 13 March 2017 at 19:08:12 UTC, H. S. Teoh wrote:
> What the user sees should be the most generic API that makes 
> sense relative to this function.  For cases where the 
> implementation can't (yet) handle, a helpful error message is 
> given, and the docs should also indicate the present 
> limitations.

phobos each, and probably other functions too, is sometimes hard 
to use because template constrains make them disappear when you 
enter something faulty to them. Thus the error message only says 
something like: No function overload "each" for arguments (...) 
found.

I found that it is easier to use a home-made each, without 
constrains. It still tries to implement the code, thus telling 
why the argument does not work. Perhaps phobos each should do the 
same. Of course with an error message saying that the argument 
wasn't iterable, so that the template does not appear buggy. 
Is'nt that what you were suggesting anyway?

I also agree that static ifs inside the template are preferable 
to multiple constrained templates doing essentially the same 
thing in different ways.


More information about the Digitalmars-d mailing list