Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File-scoped namespace #352

Closed
Tracked by #342
ufcpp opened this issue Aug 9, 2021 · 2 comments
Closed
Tracked by #342

File-scoped namespace #352

ufcpp opened this issue Aug 9, 2021 · 2 comments
Labels

Comments

@ufcpp
Copy link
Owner

ufcpp commented Aug 9, 2021

https://github.com/dotnet/csharplang/blob/main/proposals/csharp-10.0/file-scoped-namespaces.md

機能としてはシンプルなので説明に困ることないんだけど…
https://ufcpp.net/study/csharp/sp_namespace.html の最後辺りに足せばそれで。

問題はむしろ「なんで今更?」の方で。
「1インデントと {} 1セットを削るだけの方言」みたいなところがあって、あんまり優先的に取り組まれてきてなかった文法。
top-level statements辺りから顕著に「ちょっとでも簡素に書けるようにする」の価値が上がってる。
同じ流れで global usings も同時に入ってる。

背景に、Python が伸びてて、簡素な構文を好む人が増えたとかはありそう。

制限として、「1ファイル1名前空間しか持てない」ってのがある。
(さすがにファイルの途中で {} なしで名前空間が変化するのをいいとは思ってない。file-scoped namespace declaration よりも前に書けるのは extern alias, using directiev, global attribute だけだし、1ファイルに2個以上の 。file-scoped namespace は書けない。)
ただ、(GitHub の public リポジトリをクロールしたりとか何らかの調査で)世の中の C# コードの 99.7% は「1ファイル1名前空間」になってることがわかってるそうなので、この制限で困ることはないはず。

@ufcpp ufcpp mentioned this issue Aug 9, 2021
16 tasks
@ufcpp
Copy link
Owner Author

ufcpp commented Aug 13, 2021

@ufcpp ufcpp added the C# 10.0 label Aug 13, 2021
@ufcpp ufcpp closed this as completed Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant