The standard functions sin and cos are declared in the system unit (https://wiki.freepascal.org/System_unit). You can unambiguously refer to them via their fully-qualified identifiers, e. g. system.sin (https://www.freepascal.org/docs-html/rtl/system/sin.html).
You’re welcome.
type
complex= record
...
end;
function Sin(c: complex): something;
...
@Roald
Are you aware of the FPC UComplex unit which defines a complex record type, and provides csin() and ccos() routines?
The standard functions sin and cos are declared in the system unit (https://wiki.freepascal.org/System_unit). You can unambiguously refer to them via their fully-qualified identifiers, e. g. system.sin (https://www.freepascal.org/docs-html/rtl/system/sin.html).Yepp. Just as I expected, a simple solution that I had forgotten.
You’re welcome.
Kay got it right. Thank you anyway, I can see how my question can be misunderstood.The standard functions sin and cos are declared in the system unit (https://wiki.freepascal.org/System_unit). You can unambiguously refer to them via their fully-qualified identifiers, e. g. system.sin (https://www.freepascal.org/docs-html/rtl/system/sin.html).
You’re welcome.
Not what he's asking: how can an unqualified name be forced to refer to Sin() and Cos() that he's defined, rather than the System unit?
Roald: try defining a complex type as a record rather than a class, then having Sin() etc. functions taking complex as their parameter type.Code: [Select]type
complex= record
...
end;
function Sin(c: complex): something;
...
Not tested. You can see I'm rusty at this, I can't remember what the return type should be :-)
MarkMLl
I think, if you define the type as record, you can further define functions with a keyword overload to force the compiler to look in other units.
(but it will only work if all others are also marked overload;)
Now the compiler will continue searching in other units if it doesn't find a matching version of an overloaded function in one unit, and if the overload keyword is present.Though, granted, it's not very clear where the modifier must be present, whether in the current unit's overloads or in all of them.
(but it will only work if all others are also marked overload;)
Well, I tested with a simple "string parameter" overload of Sin() and it worked a'right, but then sin() is not really a "normal" function ...
Could you call both variants ? otherwise it is a simple matter of scope, not overloading.
(but it will only work if all others are also marked overload;)If only one unit has the "overload" directive, sequence in "uses" section is important. Compiler starts search from units which were mentioned last and if it finds a header with mismatching parameters and "overload", it continues a search. Otherwise not.
(but it will only work if all others are also marked overload;)If only one unit has the "overload" directive, sequence in "uses" section is important. Compiler starts search from units which were mentioned last and if it finds a header with mismatching parameters and "overload", it continues a search. Otherwise not.
uses first, second, third;
you can't call DoSomething(367.25); writing uses second, first, third;
and calling DoSomething(321) will convert the integer and use the "Double" overload.