Date: Thu, 22 Apr 2004 20:23:54 -0700 From: Joshua Lokken <joshua@twobirds.us> To: ben@twobirds.us Subject: Fw: Re: Beginning C++ in FreeBSD Message-ID: <20040423032354.GC57928@freebsd.jolok.org>
next in thread | raw e-mail | index | archive | help
--KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline -- Joshua "It's like being married to my best friend (and he lets me feel his boobs.)" -- Homer Simpson --KsGdsel6WgEHnImy Content-Type: message/rfc822 Content-Disposition: inline Received: from localhost (localhost.jolok.org [127.0.0.1]) by freebsd.jolok.org (8.12.11/8.12.11) with ESMTP id i3MLkIfV020230 for <joshua@localhost>; Thu, 22 Apr 2004 14:46:18 -0700 (PDT) (envelope-from owner-freebsd-chat@freebsd.org) Envelope-to: joshua@twobirds.us Delivery-date: Thu, 22 Apr 2004 14:43:45 -0700 Received: from twobirds.us [24.18.214.102] by localhost with POP3 (fetchmail-6.2.5) for joshua@localhost (single-drop); Thu, 22 Apr 2004 14:46:18 -0700 (PDT) Received: from [216.136.204.119] (helo=mx2.freebsd.org) by voyager.twobirds.us with esmtp (Exim 4.31; FreeBSD) id 1BGlyz-0001tY-Ak for joshua@twobirds.us; Thu, 22 Apr 2004 14:43:45 -0700 Received: from hub.freebsd.org (hub.freebsd.org [216.136.204.18]) by mx2.freebsd.org (Postfix) with ESMTP id 50D6957836; Thu, 22 Apr 2004 14:43:25 -0700 (PDT) (envelope-from owner-freebsd-chat@freebsd.org) Received: from hub.freebsd.org (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 3F32516A4CF; Thu, 22 Apr 2004 14:43:25 -0700 (PDT) Delivered-To: freebsd-chat@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D588E16A4CE for <freebsd-chat@freebsd.org>; Thu, 22 Apr 2004 14:43:12 -0700 (PDT) Received: from castle.comp.uvic.ca (castle.comp.uvic.ca [142.104.5.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id B14FA43D3F for <freebsd-chat@freebsd.org>; Thu, 22 Apr 2004 14:43:12 -0700 (PDT) (envelope-from chrisa@uvic.ca) Received: from uvic.ca (S01060050bab00fcb.gv.shawcable.net [24.68.226.164]) i3MLhB5w4989020; Thu, 22 Apr 2004 14:43:11 -0700 Message-ID: <40883C6F.5090602@uvic.ca> Date: Thu, 22 Apr 2004 14:43:11 -0700 From: Chris Ashlee <chrisa@uvic.ca> User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: DoubleF <doublef@tele-kom.ru> References: <200404202124.50967.dgw@liwest.at> <FGEIJLCPFDNMGDOKNBABCEAICKAA.flowers@users.sourceforge.net> <20040421110548.20d8e75c.cpressey@catseye.mine.nu> <6.0.1.1.1.20040421191223.03ed1a88@imap.sfu.ca> <p06002031bcac75b028c1@[10.0.1.5]> <20040421124817.5811bddb.cpressey@catseye.mine.nu> <20040422030636.GA444@Shark.localdomain> In-Reply-To: <20040422030636.GA444@Shark.localdomain> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-UVic-Virus-Scanned: OK - Passed virus scan by Sophos (sophie) on castle X-UVic-Spam-Scan: castle.comp.uvic.ca Not_scanned_LOCAL X-Scanned-By: MIMEDefang 2.33 (www . roaringpenguin . com / mimedefang) Cc: freebsd-chat@freebsd.org Subject: Re: Beginning C++ in FreeBSD X-BeenThere: freebsd-chat@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Non technical items related to the community <freebsd-chat.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-chat>, <mailto:freebsd-chat-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/freebsd-chat> List-Post: <mailto:freebsd-chat@freebsd.org> List-Help: <mailto:freebsd-chat-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-chat>, <mailto:freebsd-chat-request@freebsd.org?subject=subscribe> Sender: owner-freebsd-chat@freebsd.org Errors-To: owner-freebsd-chat@freebsd.org X-UIDL: 'R["!oJ>!!;B-"!!nP"! DoubleF wrote: > [etc] If you think C++ can be translated to C, just translate this: > > // one module > > class A > { > public: > A(); > }; > > A::A() > { > /* some code here */ > } > > static A a; > > // another module, which doesn't know about the former's existance > > int > main(void) > { > /* some other code here */ > } > Based on my (limited) knowledge of C++, the constructor for the object 'a' of type A will be called before main... So if you were to translate this to C, the other module, which doesn't know about the A module, would have to have a call to the constructor inserted before any other code in main, and 'a' would have to be referenced from the module containing main. So it seems that some information would be lost in the translation to C, namely that some details of other modules should not be visible. However, the compiled code for both the C++ program and the C translation could well wind up the same. Any high-level optimizations that can be done on C++ but not C could probably be done in the translation itself. Remember, C is basically a glorified, portable assembly language, and just about anything can be translated to it - even machine code. It's translating to a more high-level language that's hard. Chris _______________________________________________ freebsd-chat@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-chat To unsubscribe, send any mail to "freebsd-chat-unsubscribe@freebsd.org" --KsGdsel6WgEHnImy--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040423032354.GC57928>