3 ms·
D doesn't have pipes, being a C-like (it probably could, but it's untypical), but it has something almost as good: "uniform function call syntax", meaning that
by FeepingCreature 5y ago
D doesn't have pipes, being a C-like (it probably could, but it's untypical), but it has something almost as good: "uniform function call syntax", meaning that a function that takes X as its first parameter can be called as if it was a method of X. `foo(x)` => `x.foo()`. This makes functional programming in D a lot closer to the pipe example, in that you're usually passing a lazy iterator ("range") through a sequence of chained calls.
Every C-like language should copy this idea, imo.
- sk0g 5y agoThat sounds amazing, but I wonder if it could get unwieldy as well. Would have absolutely loved it in Go, where over the course of time I had to build up dozens if not hundreds of validators on strings, maps, etc. Ended up resorting to storing them in `companyInitials-dataType` packages, EG `abcStrings.VerifyNameIsCJK()`, but the unified call syntax would be super tidy.
- asdasdaergwerh 5y agoThis sounds like https://en.wikipedia.org/wiki/Method_chaining https://en.wikipedia.org/wiki/Method_chaining AKA https://en.wikipedia.org/wiki/Fluent_interface https://en.wikipedia.org/wiki/Fluent_interface
- FeepingCreature 5y agoYep exactly, but without requiring monkeypatching or operator hacks. Basically sorta like what C# does. edit: The extension method page even links https://en.wikipedia.org/wiki/Uniform_Function_Call_Syntax https://en.wikipedia.org/wiki/Uniform_Function_Call_Syntax
- _dain_ 5y agoNim has this as well, it's lovely.