Ceylon language

Dmitry Olshansky dmitry.olsh at gmail.com
Fri Apr 15 11:47:45 PDT 2011


On 15.04.2011 22:24, KennyTM~ wrote:
> On Apr 16, 11 00:29, Andrej Mitrovic wrote:
>> I've also tried to create a some sort of 'bind' function which could
>> let you bind arguments to specific parameters of a function. If I had
>> it working it would really help (me) out in coding for  e.g. the
>> Windows API. For example you might have a WinAPI function such as (I'm
>> pseudocoding here):
>>
>> CreateWindow(int x, int y, int w, int h, int* opt1, int* opt2, int*
>> opt3, char* name);
>>
>> And if you want to create a certain type of window with some
>> parameters which are always the same, you could create an alias that
>> binds certain arguments to this function:
>>
>> alias bind!CreateWindow(void, void, width, height, null, null, null,
>> void) myWindow;
>>
>> Here 'void' would designate arguments that you would have to fill in
>> when calling myWindow.
>>
>> You would call it like:
>> myWindow(posX, posY, "MyWindowName");
>>
>> which would translate the call to:
>> CreateWindow(posX, posY, width, height, null, null, null, 
>> "MyWindowName");
>
> I don't see the point reviving the std.bind module*. In your case a 
> new function name 'myWindow' needs to be defined, which makes it 
> easier to just create a wrapper function
>
>     auto myWindow(int x, int y, char* name) {
>        return CreateWindow(x, y, width, height, null, null, null, name);
>     }
>
> *: http://www.digitalmars.com/d/2.0/phobos/std_bind.html

I absolutely agree, also creating delegate in place solves pretty much 
all of std.bind use cases.

-- 
Dmitry Olshansky



More information about the Digitalmars-d mailing list