[C++-sig] container construction

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Wed Jun 19 00:37:16 CEST 2002


--- David Abrahams <david.abrahams at rcn.com> wrote:
> as you can in Python. So, I guess we need
> 
>     make_list(3, 5, 7) -> [3, 5, 7]
> 
> and
> 
>     make_tuple('x', 2) -> ('x', 2)
> 
> Other interfaces are possible, though:
> 
>     tuple(items = 'x', 2)
>     list(items = 3, 5, 7)

make_list, make_tuple looks best to my twisted mind.

>     dict(1, "one").add(2, "two")   // chaining
>     dict(1, "one"), dict(2, "two") // overloaded comma operator
>     dict(1, 'one', 2, 'two')       // even arities only

I'd go with .add(). dict(1, 'one', 2, 'two') is clear, but you might also have
dict(3, 16, 7, 13, 13, 14, 19, 12, 15, 1). dict(3, 16).add(7, 13).add(13,
14).add(19, 12).add(15, 1) is a bit more to type but the expression is more
obvious.

Ralf



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com





More information about the Cplusplus-sig mailing list