[swift-evolution] [Discussion] Parentheses

Jens Persson jens at bitcycle.com
Wed Jul 6 09:48:11 CDT 2016


Ah, thanks Anton!
But wouldn't/couldn't things be different if tuples was written with eg ⊂⊃
instead of parentheses?
(let's ignore the practical implications (difficult to write etc) for the
moment)

For example, here's an optional tuple whose single element is a function:
⊂Int -> Int⊃?

and here is an optional function:
(Int -> Int)?

In this thought-experiment, parentheses are _only_ used for grouping
(setting priorities), and they are the only grouping which is
sloppy/forgiving, so this would also be an optional tuple whose single
element is a function:

((((((((⊂Int -> Int⊃))))))?))

But this would be an optional tuple whose single element is a single
element tuple whose single element is a function:
⊂⊂Int -> Int⊃⊃?

/Jens


On Wed, Jul 6, 2016 at 12:23 PM, Anton Zhilin <antonyzhilin at gmail.com>
wrote:

> > Or maybe I have just forgotten the reasons for why there can be no such
> thing as (a nested) single element tuple (type).
>
> In Swift, types have their own (built-in) operators: infix '->', postfix
> '?', postfix '!'.
> Parentheses are required for grouping (setting priorities). If we allow
> single element tuples, ambiguities arise:
>
> (Int -> Int)?  // is that an optional tuple or just optional function?
>
> By the way, in Haskell, which allows user-defined operators on types,
> there is no single element tuple for pretty much the same reason.
>



-- 
bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden
http://www.bitcycle.com/
Phone: +46-73-753 24 62
E-mail: jens at bitcycle.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160706/477bbb3b/attachment.html>


More information about the swift-evolution mailing list