Skip to main content
deleted 214 characters in body
Source Link
Robert Harvey
  • 200.1k
  • 55
  • 468
  • 679

Fluent interfaces are easily supported in C# by using return this.

In Linq, extension methods are used to accomplish the same thing. Extension methods over IQueryable or IEnumerable are easily chained together.

Cascades, as described by the page at the link you provided, seem to be merely a subtle refinement of an ordinary Fluent Interface where return this is not required to make it work, as all method calls beginning with .. refer to the first returned result:

query('#my-form').query('button')
    ..classes.add('toggle')
    ..text = 'Click Me!'
    ..labels.add(toggleLabel);

Does C# support this? No, not exactly. But you can still write the following equivalent code:

var result = query('#my-form').query('button')
result.classes.add('toggle')
result.text = 'Click Me!'
result.labels.add(toggleLabel);

and it is only slightly more verbose (and arguably easier to read).

As to the question, "Were they ever considered for C#," you would have to ask Anders Hejlsberg or Eric Lippert about that. My guess is that they view it as syntactic sugar, which in fact it is.

Although Dart claims that this syntax means you don't have to choose between chaining and having a meaningful return value, I don't see the point, as the syntax doesn't provide a place for the return value to go.

Fluent interfaces are easily supported in C# by using return this.

In Linq, extension methods are used to accomplish the same thing. Extension methods over IQueryable or IEnumerable are easily chained together.

Cascades, as described by the page at the link you provided, seem to be merely a subtle refinement of an ordinary Fluent Interface where return this is not required to make it work, as all method calls beginning with .. refer to the first returned result:

query('#my-form').query('button')
    ..classes.add('toggle')
    ..text = 'Click Me!'
    ..labels.add(toggleLabel);

Does C# support this? No, not exactly. But you can still write the following equivalent code:

var result = query('#my-form').query('button')
result.classes.add('toggle')
result.text = 'Click Me!'
result.labels.add(toggleLabel);

and it is only slightly more verbose (and arguably easier to read).

As to the question, "Were they ever considered for C#," you would have to ask Anders Hejlsberg or Eric Lippert about that. My guess is that they view it as syntactic sugar, which in fact it is.

Although Dart claims that this syntax means you don't have to choose between chaining and having a meaningful return value, I don't see the point, as the syntax doesn't provide a place for the return value to go.

Fluent interfaces are easily supported in C# by using return this.

In Linq, extension methods are used to accomplish the same thing. Extension methods over IQueryable or IEnumerable are easily chained together.

Cascades, as described by the page at the link you provided, seem to be merely a subtle refinement of an ordinary Fluent Interface where return this is not required to make it work, as all method calls beginning with .. refer to the first returned result:

query('#my-form').query('button')
    ..classes.add('toggle')
    ..text = 'Click Me!'
    ..labels.add(toggleLabel);

Does C# support this? No, not exactly. But you can still write the following equivalent code:

var result = query('#my-form').query('button')
result.classes.add('toggle')
result.text = 'Click Me!'
result.labels.add(toggleLabel);

and it is only slightly more verbose (and arguably easier to read).

As to the question, "Were they ever considered for C#," you would have to ask Anders Hejlsberg or Eric Lippert about that. My guess is that they view it as syntactic sugar, which in fact it is.

deleted 12 characters in body; added 217 characters in body
Source Link
Robert Harvey
  • 200.1k
  • 55
  • 468
  • 679

Fluent interfaces are easily supported in C# by using return this.

In Linq, extension methods are used to accomplish the same thing. Extension methods over IQueryable or IEnumerable are easily chained together.

Cascades, as described by the page at the link you provided, seem to be merely a subtle refinement of an ordinary Fluent Interface where return this is not required to make it work, as all method calls beginning with .. refer to the first returned result:

query('#my-form').query('button')
    ..classes.add('toggle')
    ..text = 'Click Me!'
    ..labels.add(toggleLabel);

Does C# support this? No, not exactly. But you can still write the following equivalent code:

var result = query('#my-form').query('button')
result.classes.add('toggle')
result.text = 'Click Me!'
result.labels.add(toggleLabel);

and it is only slightly more verbose (and arguably easier to read).

As to the question, "Were they ever considered for C#," you would have to ask Anders Hejlsberg or Eric Lippert about that. My guess is that they view it as superfluous syntactic sugar, which in fact it is.

Although Dart claims that this syntax means you don't have to choose between chaining and having a meaningful return value, I don't see the point, as the syntax doesn't provide a place for the return value to go.

Fluent interfaces are easily supported in C# by using return this.

In Linq, extension methods are used to accomplish the same thing. Extension methods over IQueryable or IEnumerable are easily chained together.

Cascades, as described by the page at the link you provided, seem to be merely a subtle refinement of an ordinary Fluent Interface where return this is not required to make it work, as all method calls beginning with .. refer to the first returned result:

query('#my-form').query('button')
    ..classes.add('toggle')
    ..text = 'Click Me!'
    ..labels.add(toggleLabel);

Does C# support this? No, not exactly. But you can still write the following equivalent code:

var result = query('#my-form').query('button')
result.classes.add('toggle')
result.text = 'Click Me!'
result.labels.add(toggleLabel);

and it is only slightly more verbose (and arguably easier to read).

As to the question, "Were they ever considered for C#," you would have to ask Anders Hejlsberg or Eric Lippert about that. My guess is that they view it as superfluous syntactic sugar, which in fact it is.

Fluent interfaces are easily supported in C# by using return this.

In Linq, extension methods are used to accomplish the same thing. Extension methods over IQueryable or IEnumerable are easily chained together.

Cascades, as described by the page at the link you provided, seem to be merely a subtle refinement of an ordinary Fluent Interface where return this is not required to make it work, as all method calls beginning with .. refer to the first returned result:

query('#my-form').query('button')
    ..classes.add('toggle')
    ..text = 'Click Me!'
    ..labels.add(toggleLabel);

Does C# support this? No, not exactly. But you can still write the following equivalent code:

var result = query('#my-form').query('button')
result.classes.add('toggle')
result.text = 'Click Me!'
result.labels.add(toggleLabel);

and it is only slightly more verbose (and arguably easier to read).

As to the question, "Were they ever considered for C#," you would have to ask Anders Hejlsberg or Eric Lippert about that. My guess is that they view it as syntactic sugar, which in fact it is.

Although Dart claims that this syntax means you don't have to choose between chaining and having a meaningful return value, I don't see the point, as the syntax doesn't provide a place for the return value to go.

added 13 characters in body; added 30 characters in body; added 4 characters in body; added 202 characters in body; added 8 characters in body; added 130 characters in body
Source Link
Robert Harvey
  • 200.1k
  • 55
  • 468
  • 679

Fluent interfaces are easily supported in C# by using return this.

In Linq, extension methods are used to accomplish the same thing. Extension methods over IQueryable or IEnumerable are easily chained together.

Cascades, as described by the page at the link you provided, seem to be merely a subtle refinement of an ordinary Fluent Interface where return this is not required to make it work, as all method calls beginning with .. refer to the first returned result:

query('#my-form').query('button')
    ..classes.add('toggle')
    ..text = 'Click Me!'
    ..labels.add(toggleLabel);

Does C# support this? No, not exactly. But you can still write the following equivalent code:

var valueresult = query('#my-form').query('button')
valueresult.classes.add('toggle')
valueresult.text = 'Click Me!'
valueresult.labels.add(toggleLabel);

and it is only slightly more verbose (and arguably easier to read).

As to the question, "Were they ever considered for C#," you would have to ask Anders Hejlsberg or Eric Lippert about that. My guess is that they view it as superfluous syntactic sugar, which in fact it is.

Fluent interfaces are easily supported in C# by using return this.

In Linq, extension methods are used to accomplish the same thing. Extension methods over IQueryable or IEnumerable are easily chained together.

Cascades, as described by the page at the link you provided, seem to be merely a subtle refinement of an ordinary Fluent Interface:

query('#my-form').query('button')
    ..classes.add('toggle')
    ..text = 'Click Me!'
    ..labels.add(toggleLabel);

Does C# support this? No. But you can still write:

var value = query('#my-form').query('button')
value.classes.add('toggle')
value.text = 'Click Me!'
value.labels.add(toggleLabel);

and it is only slightly more verbose (and arguably easier to read).

Fluent interfaces are easily supported in C# by using return this.

In Linq, extension methods are used to accomplish the same thing. Extension methods over IQueryable or IEnumerable are easily chained together.

Cascades, as described by the page at the link you provided, seem to be merely a subtle refinement of an ordinary Fluent Interface where return this is not required to make it work, as all method calls beginning with .. refer to the first returned result:

query('#my-form').query('button')
    ..classes.add('toggle')
    ..text = 'Click Me!'
    ..labels.add(toggleLabel);

Does C# support this? No, not exactly. But you can still write the following equivalent code:

var result = query('#my-form').query('button')
result.classes.add('toggle')
result.text = 'Click Me!'
result.labels.add(toggleLabel);

and it is only slightly more verbose (and arguably easier to read).

As to the question, "Were they ever considered for C#," you would have to ask Anders Hejlsberg or Eric Lippert about that. My guess is that they view it as superfluous syntactic sugar, which in fact it is.

Source Link
Robert Harvey
  • 200.1k
  • 55
  • 468
  • 679
Loading