Phobos PR: `call` vs. `bindTo`

Daniel Gibson via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 5 15:25:53 PDT 2014


Am 06.08.2014 00:17, schrieb Idan Arye:
> On Tuesday, 5 August 2014 at 21:10:25 UTC, Tofu Ninja wrote:
>> Can you explain the utility of both of them? I am not big into
>> functional programming so I am not seeing it.
>
> The purpose of `bindTo` is to emulate the `let` expressions found in
> many functional languages (see
> http://en.wikipedia.org/wiki/Let_expression). The idea is to bind a
> value to a name for the limited scope of a single expression.
>
> Note that `bindTo` could be implemented as:
>
>      alias bindTo = std.functional.unaryFun;
>
> and I'll probably change the implementation to this if this PR will be
> chosen. The reason I think `bindTo` is needed even if it's just an alias
> to `unaryFun` is that `bindTo` conveys better that the you are binding a
> name to a value, not just overcomplicating the code.

And my impression (in lisp/clojure) was, that let emulates (named) 
variables of imperative languages :P

Cheers,
Daniel


More information about the Digitalmars-d mailing list