Overloading an imported function

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
import std.math; real round(real val, int prec) { real pow = 10 ^^ prec; return round(val * pow) / pow; } Trying to compile this I get: foo.d(5): Error: function foo.round (real val, int prec) is not callable using argument types (real) When I've imported std.math which contains round(r

Re: Overloading an imported function

2015-10-21 Thread Kagamin via Digitalmars-d-learn
http://dlang.org/hijack.html

Re: Overloading an imported function

2015-10-21 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 21 October 2015 at 12:05:27 UTC, Shriramana Sharma wrote: import std.math; real round(real val, int prec) { real pow = 10 ^^ prec; return round(val * pow) / pow; } Trying to compile this I get: foo.d(5): Error: function foo.round (real val, int prec) is not callable using

Re: Overloading an imported function

2015-10-21 Thread anonymous via Digitalmars-d-learn
On Wednesday, October 21, 2015 02:05 PM, Shriramana Sharma wrote: > When I've imported std.math which contains round(real), why is the > compiler complaining about not being able to call the overload function > defined in *this* module? The functions don't form an overload set. You need to bring

Re: Overloading an imported function

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
Kagamin wrote: > http://dlang.org/hijack.html Thanks people, but even as per the rules: 1. Perform overload resolution independently on each overload set 2. If there is no match in any overload set, then error 3. If there is a match in exactly one overload set, then go with that 4. If there is a

Re: Overloading an imported function

2015-10-21 Thread anonymous via Digitalmars-d-learn
On Wednesday, October 21, 2015 08:28 PM, Shriramana Sharma wrote: > Kagamin wrote: > >> http://dlang.org/hijack.html > > Thanks people, but even as per the rules: > > 1. Perform overload resolution independently on each overload set > 2. If there is no match in any overload set, then error > 3.

Re: Overloading an imported function

2015-10-21 Thread Shriramana Sharma via Digitalmars-d-learn
anonymous wrote: > Huh. I can't find any specification on this, but apparently the local > overload set shadows any imported overload sets completely. Should I file a bug on this then? -- Shriramana Sharma, Penguin #395953

Re: Overloading an imported function

2015-10-22 Thread anonymous via Digitalmars-d-learn
On 22.10.2015 06:14, Shriramana Sharma wrote: anonymous wrote: Huh. I can't find any specification on this, but apparently the local overload set shadows any imported overload sets completely. Should I file a bug on this then? I'm not sure. Maybe make a thread on the main group first. It's

Re: Overloading an imported function

2015-10-23 Thread Maxim Fomin via Digitalmars-d-learn
On Wednesday, 21 October 2015 at 12:05:27 UTC, Shriramana Sharma wrote: import std.math; real round(real val, int prec) { real pow = 10 ^^ prec; return round(val * pow) / pow; } Trying to compile this I get: foo.d(5): Error: function foo.round (real val, int prec) is not callable using