Tuesday, June 22, 2010

language function args

More stream of consciousness....

One of my favorite poster children of screwed up function calls is the FOX toolkit.

Here's an example taken straight from wikipedia:

FXMainWindow *main=new FXMainWindow(&application, "Hello", NULL, NULL, DECOR_ALL);

As you can tell the argument list is highly self documenting. NULL, NULL is very meaningful.

Sadly I've been driven to write something like this before.

Just a thought for some other type syntax


FXMainWindow * const main
(new FXMainWindow with
application=&application
, name="Hello"
, icon=NULL
, miniicon=NULL
, opts=DECOR_ALL);


What's interesting is that naming the fucntion args allows arbitrary ordering of args and arbitrary default argument implementation in the function.

No comments:

Post a Comment