www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Why does phobos have collisions?

reply Mike B Johnson <Mikey Ikes.com> writes:
Error: template std.algorithm.mutation.strip cannot deduce 
function from argument types !()(string), candidates are:
src\phobos\std\algorithm\mutation.d(2280):        
std.algorithm.mutation.strip(Range, E)(Range range, E element) if 
(isBidirectionalRange!Range && is(typeof(range.front == element) 
: bool))
\src\phobos\std\algorithm\mutation.d(2287):        
std.algorithm.mutation.strip(alias pred, Range)(Range range) if 
(isBidirectionalRange!Range && is(typeof(pred(range.back)) : 
bool))

This is on a line of code that simply strips away a string...

and works fine when using standard strip(without importing 
std.algorithm)... but when importing std.algorithm too, those 
errors pop up... seems like a defect.
Jun 07 2017
next sibling parent Dukc <ajieskola gmail.com> writes:
On Wednesday, 7 June 2017 at 10:01:30 UTC, Mike B Johnson wrote:
 and works fine when using standard strip(without importing 
 std.algorithm)... but when importing std.algorithm too, those 
 errors pop up... seems like a defect.
What do you mean with "standard strip"? In my vocabulary, functions in std.algorithm ARE the standard ones. It is not a name clash. If it were, the compiler would announce "ambiquous name lookup" or something like that. The error you have tells that none of the names fit, not that many of them did. Yes, the name matched, but the static types of arguments (either compile-time or runtime) you passed did not. I think you should copy here what you wote, so we can get a better picture where the problem is.
Jun 07 2017
prev sibling next sibling parent Dukc <ajieskola gmail.com> writes:
On Wednesday, 7 June 2017 at 10:01:30 UTC, Mike B Johnson wrote:
 template std.algorithm.mutation.strip cannot deduce function 
 from argument types !()(string)
Judging by that you correctly passed a string to strip, but did not specify what to strip from it. You can either specify an example of characters you want to strip off, or an alias predicate which judges whether an element should go.
Jun 07 2017
prev sibling parent reply Ivan Kazmenko <gassa mail.ru> writes:
On Wednesday, 7 June 2017 at 10:01:30 UTC, Mike B Johnson wrote:
 Error: template std.algorithm.mutation.strip cannot deduce 
 function from argument types !()(string), candidates are:
 src\phobos\std\algorithm\mutation.d(2280):        
 std.algorithm.mutation.strip(Range, E)(Range range, E element) 
 if (isBidirectionalRange!Range && is(typeof(range.front == 
 element) : bool))
 \src\phobos\std\algorithm\mutation.d(2287):        
 std.algorithm.mutation.strip(alias pred, Range)(Range range) if 
 (isBidirectionalRange!Range && is(typeof(pred(range.back)) : 
 bool))

 This is on a line of code that simply strips away a string...

 and works fine when using standard strip(without importing 
 std.algorithm)... but when importing std.algorithm too, those 
 errors pop up... seems like a defect.
Actually, it looks like the std.algorithm[.mutation] is imported but std.string isn't. As std.algorithm's strip is more generic, it cannot assume what's the "whitespace" to be stripped, so it's not callable without explicitly specifying what to strip. I've experienced this too, and it's really a bit confusing the first time it happens. Ivan Kazmenko.
Jun 07 2017
parent drug <drug2004 bk.ru> writes:
07.06.2017 17:57, Ivan Kazmenko пишет:
 On Wednesday, 7 June 2017 at 10:01:30 UTC, Mike B Johnson wrote:
 Error: template std.algorithm.mutation.strip cannot deduce function 
 from argument types !()(string), candidates are:
 src\phobos\std\algorithm\mutation.d(2280): 
 std.algorithm.mutation.strip(Range, E)(Range range, E element) if 
 (isBidirectionalRange!Range && is(typeof(range.front == element) : bool))
 \src\phobos\std\algorithm\mutation.d(2287): 
 std.algorithm.mutation.strip(alias pred, Range)(Range range) if 
 (isBidirectionalRange!Range && is(typeof(pred(range.back)) : bool))

 This is on a line of code that simply strips away a string...

 and works fine when using standard strip(without importing 
 std.algorithm)... but when importing std.algorithm too, those errors 
 pop up... seems like a defect.
Actually, it looks like the std.algorithm[.mutation] is imported but std.string isn't. As std.algorithm's strip is more generic, it cannot assume what's the "whitespace" to be stripped, so it's not callable without explicitly specifying what to strip. I've experienced this too, and it's really a bit confusing the first time it happens. Ivan Kazmenko.
Selective imports are good in this case.
Jun 07 2017