Boost logo

Boost :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2003-10-05 18:11:56


At 22:56 2003-10-05, David Abrahams wrote:

>In an attempt to improve on the interface used by the Boost.Graph
>library for named parameters, I came up with the enclosed scheme,
>which allows the following Python-like syntax:
>
>
> int x1 = f("x", 3.14, 22);
> int x2 = f(value = 3.14, name = "x");
> int x3 = f(value = 6.5);
> int x4 = f();
>
> int x5 = g("x", 3.14, 22);
> int x6 = g(value = 3.14, name = "x");
>
> int x8 = g("q", index = 77);
>
>I'm pretty proud of myself (;->) but I'm not too satisfied with how
>much code is required for someone wanting to write a new function
>accepting keyword arguments, and further I'm not sure how to design a
>good interface for automatically generating the boilerplate with the
>preprocessor. Consider that there may be initial non-keyword args,
>which might themselves be templated or not.
>
>I thought I'd open it up for suggestions. Thoughts, anyone?

I got two ideas on how to reduce the code required for a function. I'm
attaching a modified version of your code which demonstrates the
two ideas on your example functions.

---
Daniel Wallin



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk