[swift-evolution] idea: immutable setters for structs and tuples?

Zsolt Szatmári szatmari.zs at gmail.com
Wed Mar 23 03:06:53 CDT 2016

Dear All,


  The only thing I am really missing right now from Swift is described as
following. This works in some other languages, e.g.  F#, Kotlin, and Haskell.


  F# example (taken from https://fsharpforfunandprofit.com/posts/correctness-


let john = {firstName="John"; lastName="Doe"}

let alice = {john with FirstName="Alice"}


  Current way to do this in Swift is:


let john = (firstName:"John", lastName:"Doe")  
var alice = john  
alice.firstName = "Alice"  


  This might seem to be a nuance, but it's more cumbersome (especially if one
wants to do this frequently), and we are left with a var at the end.

  Also, this idea rhymes with the current direction of removing var arguments
from functions.

  What do You think? Thank You.




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

More information about the swift-evolution mailing list