[Feature] Open up the tuple name inferencing to custom tuple factories #853
Replies: 5 comments
-
@bradphelan You may want to check the discussion about a similar suggestion here. |
Beta Was this translation helpful? Give feedback.
-
The poster seems to be asking for something different. I'm not asking that
the compiler assumes anything. The propagation of names is explicit via
tagging through attributes.
…On Fri, 25 Aug 2017, 12:42 Eyal Solnik ***@***.***> wrote:
@bradphelan <https://github.com/bradphelan> You may want to check the
discussion about a similar suggestion here
<https://github.com/dotnet/csharplang/issues/829>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/dotnet/csharplang/issues/853#issuecomment-324884214>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABE8jq_-BQFO8s29eV6kgEicuoQWNHWks5sbqUkgaJpZM4PCYhV>
.
|
Beta Was this translation helpful? Give feedback.
-
It's just another way of solving what I was after in that other issue in my view. My example from there could be handled with this method: public static TR Foo<T1 [TupleName(0)], T2 [TupleName(0)], TR>(
this (T1 [TupleNameInference(0)], T2 [TupleNameInference(0)]) t,
Func<(T1 [TupleNameInference(0)], T2 [TupleNameInference(0)]), TR> f) => f(t);
...
(a:1, b:1).Foo(t => t.a == t.b); // this should work It's verbose, but something like that would do the job. |
Beta Was this translation helpful? Give feedback.
-
@bradphelan I said similar not exactly the same, if I thought the latter I'd say it's a duplication. |
Beta Was this translation helpful? Give feedback.
-
Though I do feel that just naming things with the form public static TR Foo<T1, T2, TR>(
this (T1:name1, T2:name2) t,
Func<(T1:name1, T2:name2), TR> f) => f(t); and something like: public static IObservable<(T1:n1, T2:n2, T3:n3)> WhenAnyValue<TSender, TRet, T1, T2, T3>(
this TSender This,
Expression<Func<TSender, T1:n1>> property1,
Expression<Func<TSender, T2:n2>> property2,
Expression<Func<TSender, T3:n3>> property3,
) |
Beta Was this translation helpful? Give feedback.
-
I start to notice the following cruft in my code when using
https://reactiveui.net/docs/handbook/when-any/
Generates me an
But to achieve this I have had to write
which seems like I am repeating myself. The name inferencing should be smarter.
Better would be to declare a version of WhenAnyValue that returned tuples with names inferenced from a custom strategy. For example a version of WhenAnyValue with no callback could be defined to return an IObservable of tuples. To guide the the name inferencing an attribute strategy could be used.
with WhenAnyValue declared as
The attribute [TupleNameInference($N)] would analyze the passed expression at the call site and assign names at the call site to the tuple members as directed.
Beta Was this translation helpful? Give feedback.
All reactions