digitalmars.D - Phobos PR: `call` vs. `bindTo`
- H. S. Teoh via Digitalmars-d (15/16) Aug 05 2014 There are currently two Phobos PR's that implement essentially the same
- Tofu Ninja (4/23) Aug 05 2014 Can you explain the utility of both of them? I am not big into
- Idan Arye (12/14) Aug 05 2014 The purpose of `bindTo` is to emulate the `let` expressions found
- Daniel Gibson (5/18) Aug 05 2014 And my impression (in lisp/clojure) was, that let emulates (named)
- Idan Arye (15/42) Aug 06 2014 That's partially true. While `let` can be used to emulate named
- Brian Schott (1/1) Aug 05 2014 I'd probably never use either of them.
- Meta (4/23) Aug 05 2014 I don't think either is particularly useful. This is something
- Nick Treleaven (5/11) Aug 07 2014 I think it should be part of the language (UFCS for lambda functions):
- Idan Arye (3/20) Aug 07 2014 This syntax will also allow UFCS with fully qualified names, with
- Rikki Cattermole (3/17) Aug 05 2014 I'm not convinced that either PR adds anything of use. As noted unaryFun...
- Tobias Pankrath (8/8) Aug 05 2014 From the PR:
- Idan Arye (7/15) Aug 06 2014 This is already possible - the problem is that type inference
- Ary Borenszweig (3/17) Aug 06 2014 It's called "variable declaration" in imperative languages, and I think
- Idan Arye (5/33) Aug 06 2014 Yes, D has variable declarations, but it doesn't allow you to
- Jonathan M Davis (10/28) Aug 07 2014 I concur with what others have said. Neither of these proposals
There are currently two Phobos PR's that implement essentially the same functionality, but in slightly different ways: https://github.com/D-Programming-Language/phobos/pull/1255 https://github.com/D-Programming-Language/phobos/pull/2343From the discussion on Github, it seems to me that we should onlyintroduce one new function rather than two similar but not-quite-the-same functions. Since the discussion seems stuck on Github, I thought I should bring it here to the larger community to see if we can reach a consensus (who am I kidding... but one can hope :-P) on: (1) What name to use (bring on the bikeshed rainbow) (2) Exactly what functionality should be included. (3) Which PR to merge. T -- They say that "guns don't kill people, people kill people." Well I think the gun helps. If you just stood there and yelled BANG, I don't think you'd kill too many people. -- Eddie Izzard, Dressed to Kill
Aug 05 2014
On Tuesday, 5 August 2014 at 19:31:08 UTC, H. S. Teoh via Digitalmars-d wrote:There are currently two Phobos PR's that implement essentially the same functionality, but in slightly different ways: https://github.com/D-Programming-Language/phobos/pull/1255 https://github.com/D-Programming-Language/phobos/pull/2343Can you explain the utility of both of them? I am not big into functional programming so I am not seeing it.From the discussion on Github, it seems to me that we should onlyintroduce one new function rather than two similar but not-quite-the-same functions. Since the discussion seems stuck on Github, I thought I should bring it here to the larger community to see if we can reach a consensus (who am I kidding... but one can hope :-P) on: (1) What name to use (bring on the bikeshed rainbow) (2) Exactly what functionality should be included. (3) Which PR to merge. T
Aug 05 2014
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.
Aug 05 2014
Am 06.08.2014 00:17, schrieb Idan Arye:On Tuesday, 5 August 2014 at 21:10:25 UTC, Tofu Ninja wrote:And my impression (in lisp/clojure) was, that let emulates (named) variables of imperative languages :P Cheers, DanielCan 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.
Aug 05 2014
On Tuesday, 5 August 2014 at 22:25:53 UTC, Daniel Gibson wrote:Am 06.08.2014 00:17, schrieb Idan Arye:That's partially true. While `let` can be used to emulate named variables, it carries it's own weight - enough for many functional languages to have both `let` and regular variable declarations. Take a look at this Scheme example - http://repl.it/WVU - It shows both regular variable declaration with `define` and a `let` expression. `(define x 12)` declares("binds") `x` for the scope it was written in - the entire scope of `foo`. The `let` expression creates a new scope and binds `y` in it. Clojure doesn't have regular variable binding(`def` always uses the global scope, even if you use it inside a function) so you have to use `let` to emulate it, though `let` is still used for it's original purpose - which I think is useful enough for Phobos to have it.On Tuesday, 5 August 2014 at 21:10:25 UTC, Tofu Ninja wrote:And my impression (in lisp/clojure) was, that let emulates (named) variables of imperative languages :P Cheers, DanielCan 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.
Aug 06 2014
On Tuesday, 5 August 2014 at 19:31:08 UTC, H. S. Teoh via Digitalmars-d wrote:There are currently two Phobos PR's that implement essentially the same functionality, but in slightly different ways: https://github.com/D-Programming-Language/phobos/pull/1255 https://github.com/D-Programming-Language/phobos/pull/2343I don't think either is particularly useful. This is something that's either part of the language, or doesn't exist.From the discussion on Github, it seems to me that we should onlyintroduce one new function rather than two similar but not-quite-the-same functions. Since the discussion seems stuck on Github, I thought I should bring it here to the larger community to see if we can reach a consensus (who am I kidding... but one can hope :-P) on: (1) What name to use (bring on the bikeshed rainbow) (2) Exactly what functionality should be included. (3) Which PR to merge. T
Aug 05 2014
On 05/08/2014 23:10, Meta wrote:On Tuesday, 5 August 2014 at 19:31:08 UTC, H. S. Teoh via Digitalmars-d wrote:I think it should be part of the language (UFCS for lambda functions): some.long.ufcs.chain.(x => x + x/2).writeln; This can be useful in real code to avoid breaking a UFCS chain and having to introduce a temporary variable, which is more ugly.There are currently two Phobos PR's that implement essentially the same functionality, but in slightly different ways:I don't think either is particularly useful. This is something that's either part of the language, or doesn't exist.
Aug 07 2014
On Thursday, 7 August 2014 at 11:47:02 UTC, Nick Treleaven wrote:On 05/08/2014 23:10, Meta wrote:This syntax will also allow UFCS with fully qualified names, with functions-in-variables and with methods.On Tuesday, 5 August 2014 at 19:31:08 UTC, H. S. Teoh via Digitalmars-d wrote:I think it should be part of the language (UFCS for lambda functions): some.long.ufcs.chain.(x => x + x/2).writeln; This can be useful in real code to avoid breaking a UFCS chain and having to introduce a temporary variable, which is more ugly.There are currently two Phobos PR's that implement essentially the same functionality, but in slightly different ways:I don't think either is particularly useful. This is something that's either part of the language, or doesn't exist.
Aug 07 2014
On 6/08/2014 7:29 a.m., H. S. Teoh via Digitalmars-d wrote:There are currently two Phobos PR's that implement essentially the same functionality, but in slightly different ways: https://github.com/D-Programming-Language/phobos/pull/1255 https://github.com/D-Programming-Language/phobos/pull/2343I'm not convinced that either PR adds anything of use. As noted unaryFun can be used identically to bindTo. So its wasted code in my opinion.From the discussion on Github, it seems to me that we should onlyintroduce one new function rather than two similar but not-quite-the-same functions. Since the discussion seems stuck on Github, I thought I should bring it here to the larger community to see if we can reach a consensus (who am I kidding... but one can hope :-P) on: (1) What name to use (bring on the bikeshed rainbow) (2) Exactly what functionality should be included. (3) Which PR to merge. T
Aug 05 2014
From the PR: --- A better way to bind multiple arguments would be: ((int x = 2, int y = 3, ) => (x * y))() --- Could we make this possible?
Aug 05 2014
On Wednesday, 6 August 2014 at 05:45:09 UTC, Tobias Pankrath wrote:From the PR: --- A better way to bind multiple arguments would be: ((int x = 2, int y = 3, ) => (x * y))() --- Could we make this possible?This is already possible - the problem is that type inference doesn't work here, so we can't do ((auto x = 2, auto y = 3, ) => (x * y))()
Aug 06 2014
On 8/5/14, 4:29 PM, H. S. Teoh via Digitalmars-d wrote:There are currently two Phobos PR's that implement essentially the same functionality, but in slightly different ways: https://github.com/D-Programming-Language/phobos/pull/1255 https://github.com/D-Programming-Language/phobos/pull/2343It's called "variable declaration" in imperative languages, and I think D has that.From the discussion on Github, it seems to me that we should onlyintroduce one new function rather than two similar but not-quite-the-same functions. Since the discussion seems stuck on Github, I thought I should bring it here to the larger community to see if we can reach a consensus (who am I kidding... but one can hope :-P) on: (1) What name to use (bring on the bikeshed rainbow) (2) Exactly what functionality should be included. (3) Which PR to merge. T
Aug 06 2014
On Wednesday, 6 August 2014 at 20:12:16 UTC, Ary Borenszweig wrote:On 8/5/14, 4:29 PM, H. S. Teoh via Digitalmars-d wrote:Yes, D has variable declarations, but it doesn't allow you to declare them mid-expression for the limited scope of an expression - and that's what `bindTo` aims to achieve.There are currently two Phobos PR's that implement essentially the same functionality, but in slightly different ways: https://github.com/D-Programming-Language/phobos/pull/1255 https://github.com/D-Programming-Language/phobos/pull/2343It's called "variable declaration" in imperative languages, and I think D has that.From the discussion on Github, it seems to me that we should onlyintroduce one new function rather than two similar but not-quite-the-same functions. Since the discussion seems stuck on Github, I thought I should bring it here to the larger community to see if we can reach a consensus (who am I kidding... but one can hope :-P) on: (1) What name to use (bring on the bikeshed rainbow) (2) Exactly what functionality should be included. (3) Which PR to merge. T
Aug 06 2014
On Tuesday, 5 August 2014 at 19:31:08 UTC, H. S. Teoh via Digitalmars-d wrote:There are currently two Phobos PR's that implement essentially the same functionality, but in slightly different ways: https://github.com/D-Programming-Language/phobos/pull/1255 https://github.com/D-Programming-Language/phobos/pull/2343I concur with what others have said. Neither of these proposals carry their own weight. They're just shuffling around functionality that we already have so that someone can write their code in a slightly different order. If someone really wants to alter their code like this, they can just write these functions themselves, but they're not of enough value to the community at large to be worth adding to Phobos. - Jonathan M DavisFrom the discussion on Github, it seems to me that we should onlyintroduce one new function rather than two similar but not-quite-the-same functions. Since the discussion seems stuck on Github, I thought I should bring it here to the larger community to see if we can reach a consensus (who am I kidding... but one can hope :-P) on: (1) What name to use (bring on the bikeshed rainbow) (2) Exactly what functionality should be included. (3) Which PR to merge.
Aug 07 2014