Ceylon language

Andrej Mitrovic andrej.mitrovich at gmail.com
Fri Apr 15 09:29:41 PDT 2011


I've recently made an attempt to make a curry alternative which can
take any number of parameters (currently the curry implementation only
works with 1 parameter). I've put my implementation in bugzilla, it is
extremely simple (and maybe buggy :p)
http://d.puremagic.com/issues/show_bug.cgi?id=5829.

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");

WinAPI is full of functions which take optional parameters which need
to be set to null if they're not to be used, so this kind of 'bind'
function could be pretty useful. But I've had zero luck with CTFE and
templates. Perhaps Don's upcoming CTFE revamp could make this
possible.


More information about the Digitalmars-d mailing list