[swift-evolution] Removing explicit use of `let` from Function Parameters

Douglas Gregor dgregor at apple.com
Thu Mar 17 13:26:17 CDT 2016


> On Mar 17, 2016, at 11:22 AM, Harlan Haskins <harlan at harlanhaskins.com> wrote:
> 
> Since we’re allowing keywords as argument names, shouldn’t this:
> 
> func foo(let i: Int)

Right now, you’d have to declare this as

  func foo(`let` i: Int)

but the proposal would fix that.

> be allowed, such that it’ll be called as this:
> 
> foo(let: 3)

Right.

	- Doug


> 
> — Harlan
> 
>> On Mar 17, 2016, at 11:08 AM, Douglas Gregor via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> 
>>> On Mar 17, 2016, at 1:27 AM, Nicholas Maccharoli via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> ​As a follow-up to proposal SE-0003​: "Removing var from Function Parameters" being accepted,
>>> I think it might make sense to disallow explicitly declaring function parameters with the `let` keyword since function parameters are immutable by default.
>>> 
>>> Basically disallow writing functions like this:
>>> 
>>> func foo(let i: Int)  { ... }
>>> 
>>> and only allow the function above to be expressed as this:
>>> 
>>> func foo(i: Int) { … }
>> 
>> This makes perfect sense to me. Want to write up a proposal?
>> 
>> 	- Doug
>> 
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160317/a2839895/attachment.html>


More information about the swift-evolution mailing list