[Swift-devel] Call function.
Mihael Hategan
hategan at mcs.anl.gov
Mon Aug 15 01:42:44 CDT 2011
On Mon, 2011-08-15 at 11:47 +0530, Yadu Nand wrote:
> On Mon, Aug 15, 2011 at 11:31 AM, Jonathan Monette <jonmon at mcs.anl.gov> wrote:
> > Well that case should be valid shouldn't it? I may have misunderstood the validity of overwritten functions. I know in Java you could have several methods named with the same identifier and which method that was called was determined at compile time based on the argument signature. So this seems like it should be a valid case but again I may have misunderstood the discussion on re-defining functions.
>
> Yes java, C++ all support functional-polymorphism. I am not
> sure how karajan deals with this underneath,
It doesn't. It's dynamically typed, so it has no function polymorphism.
> but at the level
> where checks are made in swift, the code definitely doesn't
> support it yet.
>
Since it's static typing, it would be known at compile time which exact
function each call refers to. So given:
(int r) plus(int a, int b);
(float r) plus(float a, float b);
The compiler would map the two to two different karajan functions (say
plus1 and plus2) and invocations of plus(1, 2) would become plus1(1, 2)
and those of plus(1.0, 2.0) would become plus2(1.0, 2.0).
For a more detailed explanation of how this is done in various
compilers, see http://en.wikipedia.org/wiki/Name_mangling
More information about the Swift-devel
mailing list