[Swift-devel] Call function.

Mihael Hategan hategan at mcs.anl.gov
Mon Aug 15 11:47:18 CDT 2011


On Thu, 2011-08-11 at 11:50 -0700, Mihael Hategan wrote:
> Given a standard cat (matching the above signature), we could have:
> 
> mycat = cat;
> 
> But the issue there is that now variables and procedures appear to live
> in the same namespace. So the semantics of the following code are
> unclear:
> 
> int f = 2;
> (int r) f(int i) {...};
> x = f;
> 
> What is assigned to x?
> 
> There are three resolutions I can think of:
> 1. Keep them in the same namespace, treat all procs as if they were
> equivalent to name = signature {body}. Disallow variables and procedures
> with the same name.
> 2. Do not keep them in the same namespace and consider the namespace
> implicit in the type. So if I assign to a non-procedure type then it's a
> normal variable, and if I assign to (or use in the context of) a
> procedure type, then it's a procedure. This could be confusing to a user
> and it requires one to look at the context of an expression to determine
> its type, which complicates the compiler code.
> 3. Have some special keyword that indicates the procedure namespace:
> myfn= proc f (or myfn = proc(f) or myfn = proc:f).
> 

Ok, so let's make this democratic. Opinions, preferences?




More information about the Swift-devel mailing list