From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,38fc011071df5a27 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-09 09:57:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newshosting.com!news-xfer2.atl.newshosting.com!uunet!dca.uu.net!ash.uu.net!spool.news.uu.net!not-for-mail Date: Mon, 09 Jun 2003 12:56:57 -0400 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030529 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ideas for Ada 200X References: <1055173916.550383@master.nyc.kbcfp.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1055177817.528719@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1055177818 1079 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:38864 Date: 2003-06-09T12:56:57-04:00 List-Id: tmoran@acm.org wrote: > I'm confused. You generate a parse tree at runtime, but the compiler > takes this runtime result and generates code? Is this a two-pass process? Yes, sort of. The parse tree is generated at runtime, but the overall type of the result is already known at compile-time. Then inlining generates the code. Let's see if I can code a relatively simple example: template struct add_op { const L &l; const R &r; add_op(const L &l, const R &r) : l(l), r(r) { } double operator()(int i, int j) const { return l(i,j) + r(i,j); } }; template add_op operator+(const L &l, const R &r) { return add_op(l,r); } template struct Matrix { double data[N][N]; template Matrix &operator=(const T &r) { for (int i = 0; i < M; ++i) for (int j = 0; j < N; ++j) data[i][j] = r(i,j); return *this; } double operator()(int i, int j) const { return data[i][j]; } };