Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!aero!srt From: srt@aerospace.aero.org (Scott "TCB" Turner) Newsgroups: comp.lang.lisp Subject: Re: AKCL declarations Message-ID: <93512@aerospace.AERO.ORG> Date: 5 Dec 90 18:04:30 GMT References: <127126@linus.mitre.org> Organization: The Aerospace Corporation, El Segundo, CA Lines: 50 Keywords: Try: (proclaim '(function foo (fixnum) fixnum)) (defun foo (x) (declare (fixnum x)) (the fixnum (* x x))) That should produce what you expect. I went through this whole business a few months ago. It can be tricky to figure out exactly what declarations AKCL needs to perform optimizations, but you rarely can go wrong if you declare everything in sight. Once you get the hang of it, it becomes obvious what you need. In this case, I think you are a little confused over declarations inside a function and outside the function. For example, (defun test4 (x) (declare (fixnum x)) (the fixnum (* x x))) This declaration does *not* tell AKCL that test4 will be called with a fixnum argument. What it says is that *test4* assumes that the argument will be a fixnum. So AKCL generates code on the assumption that x could be anything, and needs to be turned into a fixnum. The proclaim tells AKCL about how a function will be called. The proclamation (proclaim '(function test4 (fixnum) fixnum)) tells AKCL that the arguments to test4 will be fixnums and that the returned result will also be a fixnum. Incidentally, if you are worried about speed, I've found that the three biggest factors in AKCL code are: (1) GC. My personal experience has been that frequent small GCs win *big* over infrequent large GCs. (On a Sun 4/110.) (2) Explicit operations wherever possible. Avoiding object conversions and generic functions is not only much faster, but it greatly reduces the amount of garbage generated. "Foo" with the fixnum declarations above produces *no* garbage. Without it generates three ephemeral objects. (3) Declaration of functions with fixed arguments. In AKCL, function calls of fixed arguments are much faster than generic function calls. -- Scott Turner Brought to you by Super Global Mega Corp .com