Article View: pl.comp.objects
Article #15341Re: Jeszcze o C++ templates i ich zwiazku z ....
From: A.L.
Date: Tue, 05 Sep 2006 00:36
Date: Tue, 05 Sep 2006 00:36
47 lines
2611 bytes
2611 bytes
On Mon, 04 Sep 2006 19:28:54 -0500, A.L. <alewando@fala2005.com>
wrote:
>
Kawalek mi ucielo
A.L.
>
>Here is a small excerpt from the definitions of the interfaces List and Iterator in package
>Java.util:
>public interface List<E> { void add(E x);
> Iterator<E> iterator();
>}
>public interface Iterator<E> { E next();
> boolean hasNext();
>}
>
>"You might imagine that List<Integer> stands for a version of List
>where E has been uniformly replaced by Integer:
>
>public interface IntegerList { void add(Integer x)
>Iterator<Integer> iterator();
>}
>
>This intuition can be helpful, but it’s also misleading.
>It is helpful, because the parameterized type List<Integer> does
>indeed have methods that look just like this expansion.
>
>It is misleading, because the declaration of a generic is never
>actually expanded in this way. There aren’t multiple copies of the
>code: not in source, not in binary, not on disk and not in memory.
>If you are a C++ programmer, you’ll understand that this is
>very different than a C++ template.
>
>A generic type declaration is compiled once and for all, and turned
>into a single class file, just like an ordinary class or interface
>declaration. Type parameters are analogous to the ordinary
>parameters used in methods or constructors.
>Much like a method has formal value parameters that describe the
>kinds of values it operates on, a generic declaration has formal
>type parameters. When a method is invoked, actual arguments are
>substituted for the formal parameters, and the method body is
>evaluated. When a generic declaration is invoked, the actual type
>arguments are substituted for the formal type parameters..."
>
Technical Details
Message-ID:
<dfhpf215q4nplra1lnhek4jv0p8kf6dikc@4ax.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.nask.pl!news.nask.org.pl!news.germany.com!feeder.news-service.com!138.199.65.86.MISMATCH!sn-xt-ams-06!sn-xt-ams-10!sn-xt-ams-08!sn-post-ams-02!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mailReferences:
<0elmf2h54pl11i82jrlrjeifeaue4np2i6@4ax.com> <9624a$44fca0f9$57cffbdc$22240@news.chello.pl> <g1hpf2hs913nsgggpv1dntbhpojg98mcts@4ax.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.nask.pl!news.nask.org.pl!news.germany.com!feeder.news-service.com!138.199.65.86.MISMATCH!sn-xt-ams-06!sn-xt-ams-10!sn-xt-ams-08!sn-post-ams-02!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail From: A.L. <alewando@fala2005.com> Newsgroups: pl.comp.objects Subject: Re: Jeszcze o C++ templates i ich zwiazku z .... Date: Mon, 04 Sep 2006 19:36:17 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <dfhpf215q4nplra1lnhek4jv0p8kf6dikc@4ax.com> References: <0elmf2h54pl11i82jrlrjeifeaue4np2i6@4ax.com> <9624a$44fca0f9$57cffbdc$22240@news.chello.pl> <g1hpf2hs913nsgggpv1dntbhpojg98mcts@4ax.com> X-Newsreader: Forte Agent 3.1/32.783 MIME-Version: 1.0 X-Complaints-To: abuse@supernews.com Lines: 47 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit