Swift 中元组基数的限制(如果有)是什么? [英] What is the limit (if any) to the tuple cardinality in Swift?

查看:27
本文介绍了Swift 中元组基数的限制(如果有)是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个元组基数在 swift 中由它自己的类型表示(就像我知道的任何其他强类型编程语言一样),所以我们有

Each tuple cardinality is represented by its own type in swift (as in any other strongly-typed programming language I'm aware of), so we have

($T1, $T2)
($T1, $T2, $T3)
...

因为我们有几种不同的类型,每个基数一个,所以它们必须是有限的.

Since we have several different types, one per cardinality, they need to be finite.

在 Scala 中我们最多有 Tuple22,在 Haskell 中当前限制应该是 64.

In Scala we have up to Tuple22, in Haskell the current limit should be 64.

swift 的限制(如果有的话)是多少?另外,是编译器生成的类型实现还是我找不到的显式实现?

What's the limit (if any) in swift? Also, are the types implementations generated by the compiler or is there an explicit implementation I couldn't find?

推荐答案

在当前版本的 Xcode 6 Beta 中,编译失败,元组大于 1948(swift 可执行文件以代码 254 退出; 没有特定的警告或错误).

In the current version of Xcode 6 Beta, compilation fails with tuples of arity larger than 1948 (the swift executable exits with code 254; there isn't a specific warning or error).

这篇关于Swift 中元组基数的限制(如果有)是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆