News for hackers. Stuff that matters.
Re:Functional programming is not popular because it is weird... by FeepingCreature on Tuesday September 14, 2021 @01:35AM (#28520626)
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.

Re:Functional programming is not popular because it is weird... by sk0g on Tuesday September 14, 2021 @01:43AM (#28520680)
That 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.

Re:Functional programming is not popular because it is weird... by asdasdaergwerh on Tuesday September 14, 2021 @02:08AM (#28520876)
Re:Functional programming is not popular because it is weird... by FeepingCreature on Tuesday September 14, 2021 @02:42AM (#28521147)
Yep 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

Re:Functional programming is not popular because it is weird... by _dain_ on Tuesday September 14, 2021 @05:59AM (#28522433)
Nim has this as well, it's lovely.