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

式ツリーがらみもうちょっとちゃんと書いてもいいかも #88

Closed
ufcpp opened this issue Aug 23, 2016 · 5 comments
Closed

Comments

@ufcpp
Copy link
Owner

ufcpp commented Aug 23, 2016

http://miso-soup3.hateblo.jp/
https://github.com/ufcpp/UfcppSample/blob/master/Chapters/Dynamic/fig/ExpressionTrees.pptx

Expression Tree (以下ET)
ET v1 … C# 3.0で導入された時点のET
v2計画 … ETは、C# 4.0以降の追加文法に対応してない。対応したいという話は出てる

参考:
dotnet/roslyn#3717
https://github.com/dotnet/roslyn/issues/2060
https://github.com/dotnet/roslyn/blob/master/docs/designNotes/2015-04-14%20C%23%20Design%20Meeting.md
dotnet/roslyn#12897

@ufcpp
Copy link
Owner Author

ufcpp commented Aug 23, 2016

  • ETは結構低レイヤー
from x in source
where x > 3
select x * x;

↑から作られるETは、↓みたいなの。全部展開済みの結果。

Enumerable.Select(
    Enumerable.Where(
        source,
        x => x > 3),
    x => x * x);

元のC#は保ってない。
だいぶ、IL化が簡単な形に展開された状態。

@ufcpp
Copy link
Owner Author

ufcpp commented Aug 23, 2016

  • ETはC# 3.0で止まってる

以下のようなものには未対応。

C# 4.0以降に、C# 的には追加された式:

  • dynamicがらみ
  • メソッドの規定値
  • await
  • ?.
  • C# 7ではさらにout var, is T x
  • C# 8では宣言式(out varをもっと柔軟にして、どこでも変数宣言できる式)
  • 同、throw式
  • タプル、分解

.NET 4以降に追加されたExpression:

  • block
  • if とか goto とかの制御構文系
  • 代入

@ufcpp
Copy link
Owner Author

ufcpp commented Aug 23, 2016

  • ET v2やるとして、式ツリーの抽象度上げるべきか

?. ノードは足すべきか

VS

一時変数に受けて ifnull チェックするような展開結果でツリー構築すべきか

https://roslyn.codeplex.com/discussions/571077

@ufcpp
Copy link
Owner Author

ufcpp commented Aug 23, 2016

  • 歴史も少々要るかも
  • .NET 4での追加分はDLR用
  • 実質的には、O/R Mapperで一番式ツリー使われてるわけだけど、それだとv1以上のものほとんどいらない
    • ?.だけはO/R M需要ある
    • とはいえ、?.だけ特殊対応というわけにも。やるなら、C# 4.0以降のC#機能の対応考えたい
      • dynamicはさすがにきつそう

課題が大概多い

  • ラムダ式から式ツリー化するのの需要が低いのの原因の問題
  • 同Queryableの需要に関する問題
  • 式ツリーにノードを増やすにあたって起きうる問題
  • ラムダ式からの式ツリー化に関して、対応文法を増やすにあたっての大変さ

https://gist.github.com/ufcpp/1b5bdeb90baaa4dbcac6e1ba2317743f

何にしても、この機能は関係者が多すぎる。
関係者が多い = 変更しにくい、複雑すぎて使いこなす大変、に直結。

@ufcpp
Copy link
Owner Author

ufcpp commented Jul 24, 2021

式ツリーの先行き自体どうなんだろう感多少あるのでいったん close。

@ufcpp ufcpp closed this as completed Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant