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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fcc2d88d867060e8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-27 19:28:30 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!freenix!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: load and use a ".o" file? Date: 27 Dec 2003 22:28:04 -0500 Organization: Cuivre, Argent, Or Message-ID: References: <132Fb.3462$I02.2996@newssvr23.news.prodigy.com> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: melchior.cuivre.fr.eu.org 1072582104 84728 80.67.180.195 (28 Dec 2003 03:28:24 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Sun, 28 Dec 2003 03:28:24 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: In-Reply-To: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.3 Precedence: list List-Id: Gateway to the comp.lang.ada Usenet newsgroup List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:3871 Date: 2003-12-27T22:28:04-05:00 j-anthony@rcn.com (Jon S. Anthony) writes: > Stephen Leake writes: > > > j-anthony@rcn.com (Jon S. Anthony) writes: > > > > > This sort of thing is perfectly reasonable and something that is > > > extremely useful in a wide range of applications. > > > > > > What I don't understand is why people don't just use technology that > > > has solved this problem since "for ever". No, dll's and so's are not > > > the answer - they are intended to solve a different (related) problem > > > and are at best a poor mans hack for what you are talking about. > > > > > > What you really "need"[1] here is a true dynamic language. > > > > Ok, I'll bite. What's a "true dynamic language"? > > It is true that many folks will/do have different ideas about what > "true dynamic language" means. In this respect I fear it is a bit > like "true object oriented language". That's why I asked :). > I think most people in the "dynamic community" would say you need at > least the following characteristics to be "truly dynamic": > > 1. Dynamic typing. This is, strong typing on _objects_ as > differentiated from "variables/locations". Ok. I don't think that impacts on the issue of adding new code at runtime. > 2. Complete introspection of the language's computation and type > model. This is directly and explicitly available at the level of the > programmer (not just the implementer). NOTE: This does _not_ mean or > imply access to the underlying _implementation_. > > Some things this _does_ imply: > > * New function objects may be added to a running system at any time > and existing functions may be so modified at any time. Hmm. The English meaning of "introspection" is "to examine oneself"; that's not the same as creating new code. But you get to use the term the way you want to ... > * The ability to create new types and/or classes at runtime; > modify existing classes (with complete instance migration). > > > A couple examples which fully have this would be Common Lisp and > Smalltalk. Neither are "interpreter" based[1]. Most Common Lisp > implementations have optimizing native compilers that typically > produce code within about 1.5-2.5 of well crafted C code[2]. Hmm. Do those compiled versions include the ability to create new code at runtime, where the new code is also compiled, not interpreted? I'd be very surprised if that were true (I have not used a system where that is true, but I have used only a couple Lisps, and no Smalltalks). If it is true, what is the linking mechanism used? > Here are a couple very simple examples concerning the issue > at hand of the OP. These are done in Allegro Common Lisp at the REPL > (read eval print loop), typically this sort of interaction would be > through the IDE. > > CL-USER(1): > (defun foo (l r) > (declare (fixnum l r) (optimize (speed 3 safety 1 debug 1))) > (+ l r)) > => FOO > > CL-USER(2): (compile 'foo) > => FOO > > CL-USER(3): (disassemble 'foo) ; Just to show we are native (on Intel...) > ;; disassembly of # > ;; formals: L R > > ;; code start: #x7140a65c: > 0: 83 f9 02 cmpl ecx,$2 > 3: 74 02 jz 7 > 5: cd 61 int $97 ; EXCL::TRAP-ARGERR > 7: 80 7f 97 00 cmpb [edi-105],$0 ; SYS::C_INTERRUPT > 11: 74 02 jz 15 > 13: cd 64 int $100 ; EXCL::TRAP-SIGNAL-HIT > 15: 03 c2 addl eax,edx > 17: f8 clc > 18: 8b 75 fc movl esi,[ebp-4] > 21: c3 ret Hmm. You don't actually demonstrate calling foo, but I'll grant you that :). Ok, I stand corrected. Interpretation is not necessary for dynamically generated and linked code. But I'd still like to understand what the linking process implied by (compile 'foo). As far as I can see, it must do the equivalent of Windows DLL or Unix so. Just because that mechanism is hidden from the user (as it should be) doesn't mean it isn't there! That was the OP's question; how to get dynamically generated code linked in to a running program. Just saying "use CL" doesn't explain the mechanism. -- -- Stephe