Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!news.mathworks.com!tank.news.pipex.net!pipex!uknet!newsfeed.ed.ac.uk!edcogsci!jeff
From: jeff@cogsci.ed.ac.uk (Jeff Dalton)
Subject: Re: CL Pitfalls list
Message-ID: <DGJy6p.GBp@cogsci.ed.ac.uk>
Organization: Centre for Cognitive Science, Edinburgh, UK
References: <813378905.21273@iiltd.demon.co.uk> <45q5g8$mum@metro.ucc.su.OZ.AU>
Distribution: inet
Date: Mon, 16 Oct 1995 17:34:34 GMT
Lines: 36

thorsten@Rincewindarch.su.edu.au (Thorsten Schnier) writes:

>In article <813378905.21273@iiltd.demon.co.uk>, jeff@interactive.co.uk (Jeff Dalton) writes:

>|>   * Declaring the iteration variable of a DOTIMES to have type FIXNUM
>|>     does not guarantee that fixnum arithmetic will be used.  [...]

>You might add that the type of the result of (the ...) declarations is not
>checked, even with optimization for safety. 

Thanks.  I should add something about that, and about
declarations-and-checking in general.  I'll have to look
at the standard to see what the current rules are...

>For fixnum dotimes loops, I wrote the following macro (the only way of getting
>the internal variable used in GCL for dotimes declared as well):

>(defmacro dofix ((var count) . body)
>  (let ((max (gensym))
>	(loopstart (gensym)))
>    `(block ()
>	(let* ((,max ,count) (,var 0))
>	  (declare (fixnum ,max ,var))
>	  (tagbody ,loopstart
>	     (if (>= ,var ,max) (return nil))
>	     (tagbody ,@body)
>	     (setq ,var (1+ ,var))
>	     (go ,loopstart))))))

It's good to see it can be done in GCL with only one declaration.

>(Incidentially, 'fix' means quick in german...)

Cool.

-- jeff
