Ceylon language

KennyTM~ kennytm at gmail.com
Fri Apr 15 11:24:04 PDT 2011


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


More information about the Digitalmars-d mailing list