Skip to content

関数定義を修正する/return の修正/tupleの実装 #8

Description

@shadowlink0122

概要

うまく処理できていない部分がある

実装できているもの

  • 複数type定義
    • 関数定義を (type, type, ...) にできる

実装できていないもの

  • 複数return
    • 関数定義に合わせて複数の値をreturnできる
    • return var1, var2, ... ;

方針

  • tupleを実装する
    • ( var1, var2, ... ) を認識できる
    • auto a, b = ( var1, var2 )はそれぞれ a, b に代入される
      • a, bは適切に型推論される
      • 数値の場合は int がデフォルト
    • return tuple; の場合は1つの型(要素に違う型を含む)として認識する
  • もしくは上記と同等の機能

実装例

( type, ... ) func(type a, ... ) {
    return n, ... ;
}
( int, short ) func() {
    int a = 1;
    short b = 1;
    return a, b; // return (a, b)
}

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions