Skip to content

シンプルラムダ引数 #490

@ufcpp

Description

@ufcpp

https://github.com/dotnet/csharplang/blob/main/proposals/simple-lambda-parameters-with-modifiers.md

D d1 = (int x, ref int y) => { }; // OK
D d2 = (x, ref int y) => { }; // NG
D d3 = (x, ref y) => { }; // これをできるようにしたい

delegate void D(int x, ref int r);

// ref はそんなに使わないかもしれないけど、
// こんな out あるでしょ?
delegate bool TryParse<T>(string x, out T value);

in, ref, out, ref readonly, scoped がターゲット。

D d = (w, in x, ref y, out z, scoped s) => z = 0;

delegate void D(int w, in int x, ref int y, out int z, scoped Span<int> s);

メモ:

  • scoped という名前のクラスが元々あった」みたいなアレな状況では一応破壊的変更があり得る。一応。
  • params は対象外(対象にするかどうか?議論はあったけど否決)
  • () なしはダメ。ref x => ref x はエラー((ref x) => ref x は行ける)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions