定义与调用的不同参数格式

发布于 2024-12-05 03:07:15 字数 559 浏览 2 评论 0原文

我很好奇为什么主构造函数参数必须在类型定义中缩进到左括号之外,但在调用时可以使用类型名称缩进。

type AnIncrediblyLaboriouslyEternallyLongTypeName(arg1, arg2,
      arg3, arg4) = //WARNING: Possible incorrect indentation
  class end

let x = AnIncrediblyLaboriouslyEternallyLongTypeName(
          1, 2, 3, 4) //works

解决方案是将参数缩进到第二个显示器的左边缘之外:

type AnIncrediblyLaboriouslyEternallyLongTypeName(arg1, arg2,
                                                  arg3, arg4) = 
  class end

我想知道为什么这两种情况下的规则不同。

这也适用于方法。我只是选择主构造函数作为示例。

I'm curious why primary constructor args must be indented beyond the opening paren, in the type definition, yet may be indented with the type name when invoked.

type AnIncrediblyLaboriouslyEternallyLongTypeName(arg1, arg2,
      arg3, arg4) = //WARNING: Possible incorrect indentation
  class end

let x = AnIncrediblyLaboriouslyEternallyLongTypeName(
          1, 2, 3, 4) //works

The solution is to indent the args beyond the left edge of your second monitor:

type AnIncrediblyLaboriouslyEternallyLongTypeName(arg1, arg2,
                                                  arg3, arg4) = 
  class end

I'm wondering why the rules are different in these two scenarios.

This also applies to methods. I just chose primary constructors as an example.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甩你一脸翔 2024-12-12 03:07:15

我不记得了,但请注意,这

type AnIncrediblyLaboriouslyEternallyLongTypeName
        (arg1, arg2, arg3, arg4) = // works
  class end 

也是允许的。

I do not recall, but note that this

type AnIncrediblyLaboriouslyEternallyLongTypeName
        (arg1, arg2, arg3, arg4) = // works
  class end 

is also allowed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文