C is Brittle D is Plastic
Quirin Schroll
qs.il.paperinik at gmail.com
Wed Mar 25 13:21:32 UTC 2026
On Sunday, 22 March 2026 at 11:56:00 UTC, Dennis wrote:
> On Sunday, 22 March 2026 at 04:47:41 UTC, Walter Bright wrote:
>> Another source of slowdown in C that became apparent over the
>> years is C is a brittle language, rather than a plastic one.
>
> Another example where D shines in this regard is UFCS allowing
> you to turn fields into methods and vice versa:
>
> ```D
> struct S
> {
> ubyte* ptr;
> ubyte* end;
> size_t length() => end - ptr;
> }
> ```
>
> ```D
> struct S
> {
> ubyte* ptr;
> size_t length;
> ubyte* end() => ptr + length;
> }
> ```
>
> You don't need to change `.end` into `.end()`, `.end` works on
> both fields and methods.
That isn’t UFCS, that’s just empty parentheses being optional.
Those are completely orthogonal language concepts.
More information about the Digitalmars-d
mailing list