Overloading an imported function
John Colvin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Oct 21 05:29:00 PDT 2015
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 argument types (real)
>
> 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?
>
> I don't see anything in http://dlang.org/module.html that says
> I cannot define an overload of an imported function. Did I miss
> something?
You might find something useful in section 2 of
https://github.com/DlangScience/design/blob/master/design.pdf and
also somewhat related:
http://arsdnet.net/this-week-in-d/sep-27.html
More information about the Digitalmars-d-learn
mailing list