Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!lll-lcc!well!jjacobs From: jjacobs@well.UUCP Newsgroups: comp.lang.lisp Subject: Against the Tide of Common LISP Message-ID: <2565@well.UUCP> Date: Tue, 10-Feb-87 22:16:00 EST Article-I.D.: well.2565 Posted: Tue Feb 10 22:16:00 1987 Date-Received: Thu, 12-Feb-87 00:09:28 EST Reply-To: jjacobs@well.UUCP (Jeffrey Jacobs) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 68 In <768@rpics.RPI.EDU>, Bill Yerazunis writes: >Do I really need to keep that there? :-) Only if you reproduce the whole thing somewhere else :-) >Why bother DEFVARing? It says right in CLTL that it won't affect >just efficiency. It says right in CLTL "DEFVAR is the recommended way to declare the use of a special variable". I contend that this does affect correctness (and is also a good reason to refer to the manual even when doing *simple* things). :-) >Common lisp does have an "interior logic" that you can get into. It makes >sense after a while. Things like the scoping DO make a LOT of sense when >you start seriously considering a compiler. Some of it makes sense, but not *good* sense :-) The issue I raise is not "lexical vs dynamic"; it's the godawful mess that CL uses! (As a general rule of language design I agree that lexical is better; dynamic scoping for LISP is both a personal prejudice and a performance issue). > I know my code runs faster >with lexical than with dynamic. Remember, when you scope lexically and >compile, you have an absolute displacement onto the stack. This is >a fast thing. >If you dynamically scope, you have to call a routine >to go into a hash table and find out where whatever-it-is is kept. >This is a not-so-fast thing for a compiled language. On calling >and return, you have to fix up the hash symbol table for each and >every dynamically-scoped argument. This is a very-not-fast thing Say what??????????? The "value cell" is normally statically located at a known address!!! No need to perform hash table lookup at all!!! All references are by address. Access time may possibly be *faster*, i.e. MOV ADDR, dest instead of MOV INDEX(SP),dest.depending on CPU architecture! Simplisticially, dynamic binding becomes: PUSH #SPEC_CELL_ADDR ; save address for later restoral PUSH SPEC_CELL_ADDR ; save current value MOV new_value, SPEC_CELL_ADDR ; set value restoring becomes simply POP R1 ; get address of special cell, R1 assumed to be a reg. POP (R1) ; restore value. Jeffrey M. Jacobs CONSART Systems Inc. Technical and Managerial Consultants P.O. Box 3016, Manhattan Beach, CA 90266 (213)376-3802 CIS:75076,2603 BIX:jeffjacobs USENET: well!jjacobs