Topic: template new syntax [was: Evolution of C++ : Thinking ahead of what's to come]
Author: "Andrei Alexandrescu (See Website for Email)" <SeeWebsiteForEmail@moderncppdesign.com>
Date: Sun, 26 Sep 2004 16:05:41 GMT Raw View
"Francis Glassborow" <francis@robinton.demon.co.uk> wrote in message
news:qgKV29BD5WRBFwxO@robinton.demon.co.uk...
> In article <20040912140835.GA5789@mail19g.g19.rapidsite.net>, Lothar
> Werzinger <lothar@xcerla.com> writes
>>When it comes to default arguments I would muh more like the Python way by
>>naming the variables. With that you can specify them in any order and omit
>>all that you do not want to use. Of course that would REQUIRE to have
>>names
>>in the declaration of methods/functions with default parameters.
>
> It would also require that those names have some form of extended scope,
> and that is a little less trivial.
Indeed. That's a reoccurring theme when adding new features: they have to
play nice with the existing language.
The "!" or "?" in lieu of a defaulted argument is a very local language
change because no valid program as of today contains such a sign followed by
a comma or a closing parenthesis. On the other hand:
// calls Foo(0, "hello andrei", 3.14);
Foo(amount = 3.14, text = "hello andrei");
is compilable code in the current language given the appropriate semantic
context.
Andrei
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: David Abrahams <dave@boost-consulting.com>
Date: Mon, 27 Sep 2004 16:55:54 GMT Raw View
"Andrei Alexandrescu (See Website for Email)" <SeeWebsiteForEmail@moderncppdesign.com> writes:
> "Francis Glassborow" <francis@robinton.demon.co.uk> wrote in message
> news:qgKV29BD5WRBFwxO@robinton.demon.co.uk...
>> In article <20040912140835.GA5789@mail19g.g19.rapidsite.net>, Lothar
>> Werzinger <lothar@xcerla.com> writes
>>>When it comes to default arguments I would muh more like the Python way by
>>>naming the variables. With that you can specify them in any order and omit
>>>all that you do not want to use. Of course that would REQUIRE to have
>>>names
>>>in the declaration of methods/functions with default parameters.
>>
>> It would also require that those names have some form of extended scope,
>> and that is a little less trivial.
>
> Indeed. That's a reoccurring theme when adding new features: they have to
> play nice with the existing language.
>
> The "!" or "?" in lieu of a defaulted argument is a very local language
> change because no valid program as of today contains such a sign followed by
> a comma or a closing parenthesis. On the other hand:
>
> // calls Foo(0, "hello andrei", 3.14);
> Foo(amount = 3.14, text = "hello andrei");
>
> is compilable code in the current language given the appropriate semantic
> context.
Yeah: http://tinyurl.com/3mx6d
But positional defaults really run out of usefulness for many kinds of
functions where they'd be appropriate. Sometimes it's just too hard
to remember what the positions mean. Real keyword arguments are still
important to have. Maybe
Foo(amount: 3.14, text: "hello andrei");
would work.
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: David Abrahams <dave@boost-consulting.com>
Date: Mon, 27 Sep 2004 20:06:15 GMT Raw View
David Abrahams <dave@boost-consulting.com> writes:
> "Andrei Alexandrescu (See Website for Email)" <SeeWebsiteForEmail@moderncppdesign.com> writes:
>
>> "Francis Glassborow" <francis@robinton.demon.co.uk> wrote in message
>> news:qgKV29BD5WRBFwxO@robinton.demon.co.uk...
>>> In article <20040912140835.GA5789@mail19g.g19.rapidsite.net>, Lothar
>>> Werzinger <lothar@xcerla.com> writes
>>>>When it comes to default arguments I would muh more like the Python way by
>>>>naming the variables. With that you can specify them in any order and omit
>>>>all that you do not want to use. Of course that would REQUIRE to have
>>>>names
>>>>in the declaration of methods/functions with default parameters.
>>>
>>> It would also require that those names have some form of extended scope,
>>> and that is a little less trivial.
>>
>> Indeed. That's a reoccurring theme when adding new features: they have to
>> play nice with the existing language.
>>
>> The "!" or "?" in lieu of a defaulted argument is a very local language
>> change because no valid program as of today contains such a sign followed by
>> a comma or a closing parenthesis. On the other hand:
>>
>> // calls Foo(0, "hello andrei", 3.14);
>> Foo(amount = 3.14, text = "hello andrei");
>>
>> is compilable code in the current language given the appropriate semantic
>> context.
>
> Yeah: http://tinyurl.com/3mx6d
Whoops; wrong link. http://tinyurl.com/2qtkk (sorry).
> But positional defaults really run out of usefulness for many kinds of
> functions where they'd be appropriate. Sometimes it's just too hard
> to remember what the positions mean. Real keyword arguments are still
> important to have. Maybe
>
> Foo(amount: 3.14, text: "hello andrei");
>
> would work.
>
> --
> Dave Abrahams
> Boost Consulting
> http://www.boost-consulting.com
>
> ---
> [ comp.std.c++ is moderated. To submit articles, try just posting with ]
> [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
> [ --- Please see the FAQ before posting. --- ]
> [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
>
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]