| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
June 16, 2010 [phobos] D std.bind | ||||
|---|---|---|---|---|
| ||||
(Added Phobos.) We haven't tested std.bind in a long time. With the advent of function literals etc., it seems pointless. Walter and I think it should be deprecated.
Andrei
Jason Spencer wrote:
> Hi,
>
> I've been trying to get the simplest program that uses bind() to work with D 2.046 (or 2.036 or 2.047), but I've run into problem after problem. First, it seems D2 tightened up const handling, and the NullAlias struct of type const EmptySlot would match is expressions. After fixing that, I'm now getting:
>
> C:\Jason\D>dmd bTest.d
> C:\tools\dmd2\windows\bin\..\..\src\phobos\std\binder.d(230): Error: alias std.bind.Tuple!().Tuple.meta template identifier prependT is not a member of alias meta
> C:\tools\dmd2\windows\bin\..\..\src\phobos\std\binder.d(775): Error: no property 'prependT!(T)' for type 'Tuple!()'
> C:\tools\dmd2\windows\bin\..\..\src\phobos\std\binder.d(775): Error: alias std.bind.dynArgTypes!(i,Tuple!(int),Tuple!(DynArg!(0)),1).prependType!(int,DynArg!(0)).res cannot alias an expression __error
>
> I'm a D newbie, and the syntax is too much for to start on without getting a couple of practice programs down first.
>
> Do you know if anyone has tested std.bind in recent releases? I've talked to Tom, but he doesn't seem to be supporting it, esp. in D 2. I've also posted on DigitalMars.D. Any other ideas?
>
> Thanks,
> Jason
| ||||
June 16, 2010 [phobos] D std.bind | ||||
|---|---|---|---|---|
| ||||
(Readded Phobos) I wrote a curry in std.functional which I think could be a good starting point.
Andrei
Jason Spencer wrote:
> So is there a recommended way to approach arbitrary depth currying? std.algorithm only allows one level. Bind was the only one I knew of that would allow me to "nest" curries as deeply as I'd like to. Other ideas?
>
> Thanks,
> Jason
>
>
> ----- Original Message ----
>> From: Andrei Alexandrescu <andrei at erdani.com>
>> To: Jason Spencer <spencer8 at sbcglobal.net>
>> Cc: Discuss the phobos library for D <phobos at puremagic.com>
>> Sent: Wed, June 16, 2010 2:57:20 PM
>> Subject: Re: D std.bind
>>
>> (Added Phobos.) We haven't tested std.bind in a long time. With the advent of function literals etc., it seems pointless. Walter and I think it should be deprecated.
>
> Andrei
>
> Jason Spencer wrote:
>> Hi, I've been trying to get the simplest program that uses bind() to work with D 2.046 (or 2.036 or 2.047), but I've run into problem after problem. First, it seems D2 tightened up const handling, and the NullAlias struct of type const EmptySlot would match is expressions. After fixing that, I'm now getting:
>>
>> C:\Jason\D>dmd bTest.d
>>
>> C:\tools\dmd2\windows\bin\..\..\src\phobos\std\binder.d(230): Error: alias
>> std.bind.Tuple!().Tuple.meta template identifier prependT is not a member of
>> alias meta
>> C:\tools\dmd2\windows\bin\..\..\src\phobos\std\binder.d(775):
>> Error: no property 'prependT!(T)' for type 'Tuple!()'
>>
>> C:\tools\dmd2\windows\bin\..\..\src\phobos\std\binder.d(775): Error: alias std.bind.dynArgTypes!(i,Tuple!(int),Tuple!(DynArg!(0)),1).prependType!(int,DynArg!(0)).res cannot alias an expression __error
>>
>> I'm a D newbie, and the syntax is too much for to start on without getting a couple of practice programs down first. Do you know if anyone has tested std.bind in recent releases? I've talked to Tom, but he doesn't seem to be supporting it, esp. in D 2. I've also posted on DigitalMars.D. Any other ideas?
>>
>> Thanks,
>> Jason
| ||||
June 17, 2010 [phobos] D std.bind | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Andrei Alexandrescu <andrei at ...> writes: > > (Readded Phobos) I wrote a curry in std.functional which I think could be a good starting point. I'm new to D syntax, but if I read that right, std.curry just gives you an alias to a function call of two variables that fills in one for you. Deprecating bind would still leave holes for: - Currying an arbitrary length parameter list - storing a delegate to the curried function - composing curries (could be replaced by previous 2 if done in a certain way) - binding at arbitrary parameter indexes and maybe a couple of other things. In short, bind gives support for all kinds of partial applications, where as std.curry only allows picking off one arg in a two arg function. If bind were deprecated, is there a plan to replace the other functionality? Seems like with the new functional capabilities of D 2, bind is MORE necessary, since I would imagine more higher order functions being written and extended. If that's true, then there's gonna be an awful lot of boiler plate code like: auto p_2 = function ReturnType!plus (ParameterTypeTuple!plus[1] arg2, ParameterTypeTuple!plus[2] arg3) { return plus(2, arg2, arg3); } ; rather than auto p_2 = bind(plus, 2, _0, _1); I'd love to see partial applications supported in the language, but short of that, I'd say there needs to be some easier way to curry in, say 5 argument calls, or else the functional features of D really loose power. Bind already provides that. Maybe it just needs a make-over? Jason > Jason Spencer wrote: > > So is there a recommended way to approach arbitrary depth currying? std.algorithm only allows one level. > Bind was the only one I knew of that would allow me to "nest" curries as deeply as I'd like to. Other ideas? > > > > Thanks, > > Jason > > > > > > ----- Original Message ---- > >> From: Andrei Alexandrescu <andrei at ...> > >> To: Jason Spencer <spencer8 at ...> > >> Cc: Discuss the phobos library for D <phobos at ...> > >> Sent: Wed, June 16, 2010 2:57:20 PM > >> Subject: Re: D std.bind > >> > >> (Added Phobos.) We haven't tested std.bind in a long time. With the advent of > >> function literals etc., it seems pointless. Walter and I think it should be deprecated. > > > > Andrei > > > > Jason Spencer wrote: > >> Hi, I've been trying to get the simplest program that uses bind() to work with D 2.046 > >> (or 2.036 or 2.047), but I've run into problem after problem. First, it seems D2 tightened up const handling, and the NullAlias struct of type const > >> EmptySlot would match is expressions. After fixing that, I'm now getting: > >> > >> C:\Jason\D>dmd bTest.d > >> > >> C:\tools\dmd2\windows\bin\..\..\src\phobos\std\binder.d(230): Error: alias std.bind.Tuple!().Tuple.meta template identifier prependT is not a member of > >> alias meta > >> C:\tools\dmd2\windows\bin\..\..\src\phobos\std\binder.d(775): > >> Error: no property 'prependT!(T)' for type 'Tuple!()' > >> > >> C:\tools\dmd2\windows\bin\..\..\src\phobos\std\binder.d(775): Error: alias > >> > std.bind.dynArgTypes!(i,Tuple!(int),Tuple!(DynArg!(0)),1).prependType!(int,DynAr g!(0)).res > >> cannot alias an expression __error > >> > >> I'm a D newbie, and the syntax is too much for to start on without getting a couple of practice programs > >> down first. Do you know if anyone has tested std.bind in recent releases? I've talked to Tom, but he doesn't seem to be supporting it, esp. in D 2. I've also posted on DigitalMars.D. Any other ideas? > >> > >> Thanks, > >> Jason > | |||
June 18, 2010 [phobos] D std.bind | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | I agree and std.cpuid too.
Masahiro
On Thu, 17 Jun 2010 06:57:20 +0900, Andrei Alexandrescu <andrei at erdani.com> wrote:
> (Added Phobos.) We haven't tested std.bind in a long time. With the advent of function literals etc., it seems pointless. Walter and I think it should be deprecated.
>
> Andrei
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply