[swift-evolution] Allow ' in variable/constant names?

David Sweeris davesweeris at mac.com
Wed Jan 11 08:48:11 CST 2017


> On Jan 11, 2017, at 07:43, Karl Wagner via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On 11 Jan 2017, at 14:08, Tuur Anton via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> I often have related variables. Would be nice to just add ' like I can in Haskell:
>> 
>> let foo  = "asdf"
>> let foo' = "asdf2"
>> 
>> What do you think?
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> Ooooh… the mathematician in me would love that. 
> 
> let foo    = …
> let foo’   = …
> let foo’’  = …
> let foo’’’ = …
> 
> But I suspect the additional complexity to the parser isn’t worth it. When are two bars just two bars, and when are they an empty string literal?

I can't think of any instances where it'd be ambiguous... An empty character literal tacked on to the end of an identifier is a syntax error, right? Likewise if you've got an empty literal just hanging out in the middle of a statement, that's a syntax error as well. "=", "(", and such are all invalid identifier characters, so you couldn't name something that might be confused with an assignment or anything... I can't speak to the difficulty of implementing this, but I don't think it'd break anything. OTOH, I woke up about 5 minutes ago and haven't had my coffee yet.

My inner mathematician would be very happy indeed... +1

- Dave Sweeris 




More information about the swift-evolution mailing list