[swift-evolution] Why doesn't Swift allow a variable and a function with the same name?
jtbandes at gmail.com
Mon Jan 30 21:34:27 CST 2017
Although there's no spelling for this...
On Mon, Jan 30, 2017 at 7:29 PM Joe Groff via swift-evolution <
swift-evolution at swift.org> wrote:
> > On Jan 30, 2017, at 11:42 AM, Austin Zheng via swift-evolution <
> swift-evolution at swift.org> wrote:
> > The reason Swift works like this is because you can assign a function
> value (independently of calling it) to a variable. So there aren't two
> separate namespaces separating function names and variable names.
> To be honest, I would say that there's no "reason" for this, except as
> lingering effects of our early "functions have simple names, and arguments
> have labeled tuple type" model. If we had originally implemented the
> language with its current (at least aspirational) Smalltalk-ish
> compound-names model, we probably would have ended up allowing this, since
> the var and func do formally have different names. The ability to reference
> a function by only the first segment of its name is likewise legacy of the
> original model, though it happens to be useful since good naming hygiene
> encourages different base names for different things to begin with.
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution