curegit / session-csharp Goto Github PK
View Code? Open in Web Editor NEWSession-typed concurrent and distributed programming for .NET
Home Page: https://doi.org/10.48550/arXiv.2004.01325
Session-typed concurrent and distributed programming for .NET
Home Page: https://doi.org/10.48550/arXiv.2004.01325
Succ のネストでジャンプ先を指定するよりも楽になる
再起をするためのインターフェースメソッドは自然数ごとにオーバーロードで定義するので、表現できる範囲は変わらない
[参考] 非同期ライブラリを正しく実装する
https://www.infoq.com/jp/articles/Async-API-Design
簡潔な見た目のために
var proto = S2C<int> * C2S<string> * End | C2S<int> * End;
のように書きたい
ユーザが演算子をオーバーロードするときにgenericにできるようになるかもしれない
dotnet/csharplang/issues/813
ただしこれでも、オーバーロードできる演算子の中で右結合のものがないので不都合が残る
非継続渡しの消極的選択メソッドを実装したい。
分岐先を表すコンストラクタと分岐先のセッションをもつバリアントを用意するのが理想。
Choice <a, b> = Left of a | Right of b
コンスタントをinternalにした抽象クラスを用いると、派生クラスの作成を制限できる。
バリアントの代わりとなる。
namespace SessionTypes.Binary
{
public abstract class Choice<L, R> where L : SessionType where R : SessionType
{
internal Choice() { }
}
public sealed class Left<L, R> : Choice<L, R> where L : SessionType where R : SessionType
{
}
public sealed class Right<L, R> : Choice<L, R> where L : SessionType where R : SessionType
{
}
}
しかしダウンキャストのために型をパラメータ含めて書く必要がある。
switch (c2.Follow())
{
case Left<Respond<int, Close>, Respond<string, Close>> left:
break;
case Right<Respond<int, Close>, Respond<string, Close>> right:
break;
}
非継続渡しの消極的選択メソッドとFluent APIをあわせると、名前変えを抑えつつ手続き的な制御構造と親和に書けるので、需要は大きい。
もっと思考を要する。
ライブラリとして実用する為には必要
Session Continue((Session, Value) session, out T value)
のような拡張メソッドを用意すると
(await s.Send(v).Receive()).Continue(out var value).Send(...)
非同期受信をこのようにチェーンできる
Session Let(Session session, out T var, T value)
のような拡張メソッドを用意すると
s.Receive(out var v).Let(out var r, Sqrt(v)).Send(r).Send(Sqrt(r)).Close()
チェーンの途中で変数宣言ができる
パフォーマンスに寄与するかもしれないが、デフォルトはTaskを使うことになっている
https://docs.microsoft.com/ja-jp/dotnet/api/system.threading.tasks.valuetask-1?view=netstandard-2.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.