[swift-evolution] [Review] SE-0144: Allow Single Dollar Sign as a Valid Identifier
Rick Mann
rmann at latencyzero.com
Wed Oct 19 19:40:46 CDT 2016
> On Oct 18, 2016, at 09:39 , Nevin Brackett-Rozinsky via swift-evolution <swift-evolution at swift.org> wrote:
>
> It seems natural to me that currency symbols should be operators. This would allow, for example, prefix and postfix operators that take a number and return a “Currency” instance:
>
> let inMyPocket = $20
> let lochNess = £3.50
> let twoBits = 25¢
>
> if (inMyPocket - lochNess) > twoBits { … }
>
> Of course, the unnamed closure parameter identifiers would conflict with that use of the dollar sign. However, I think Anton has the right idea. We already use the number sign for compiler magic, so it would make sense to call the closure parameters #0, #1, etc. In my view those even read better than what we have now.
Except of course, '#' means "pound" is some contexts, and you might want to make a # operator return a weight.
I'm okay with giving up '#' for this, however.
--
Rick Mann
rmann at latencyzero.com
More information about the swift-evolution
mailing list