Topic: [std-discussion] [c++std-core-27199] Re:
Author: Thiago Macieira <thiago@macieira.org>
Date: Thu, 05 Mar 2015 18:56:36 -0800
Raw View
On Thursday 05 March 2015 17:22:10 Scott Prager wrote:
> Another reason I think we should embrace this: It brings template code
> within
> reach of absolute beginners, both to C++ and programming in general. Trying
> to
> teach an initiate what this means...
>
> template<typename Function, typename Value>
> auto f(Function fn, Value v) { return fn(v); }
>
> requires teaching the meaning on "*typename*" (because the user may not have
> needed typedefs or type aliases at this point), *template<...>*, how "
> *Function*"
> and "*Value*" do not denote real types, etc., etc.. But explaining this...
>
> auto f(auto fn, auto val) { return fn(val); }
>
> ...well, they probably already are familiar with *auto*, using *auto* as a
> parameter is intuitive, and those familiar with dynamic languages will feel
> right at home, while benefiting from static typing.
You still have to explain what a template is so that they understand that auto
there is a placeholder for the actual type and not a concrete type in itself.
Beginners may think of "auto" variables as variants like untyped languages
have.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.