Skip to content

関数の引数の初期値と型の両方を指定する場合の記法 #1017

Description

@takejohn

AiScriptでは、関数の引数において初期値と型の両方を指定する場合、初期値、型注釈の順で書くことで行えます。
例:

@f(x = 0: num) {}

TypeScriptやPython、Kotlinでは型注釈、初期値の順になっていて、初期値、型注釈の順番は他のプログラミング言語において一般的ではないかもしれません。

// TypeScript
function f(x: number = 0) {}
# Python
def f(x: int = 0):
  pass
// Kotlin
fun f(x: Int = 0) {}

初期値の記法は #475 で追加されたが、初期値を型注釈より先にするかどうかはそのときに議論されていなさそう?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions