Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion low-level hacking

Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Edi Weitz <spamt...@agharta.de>
Newsgroups: comp.lang.lisp
Subject: Re: low-level hacking
Date: Wed, 11 Jan 2006 13:02:39 +0100
Organization: No organization
Lines: 58
Message-ID: <upsmz55wg.fsf@agharta.de>
References: <qvfwf.30653$GW1.13862@news-wrt-01.rdc-nyc.rr.com> <slrnds67cr.b4k.spambait@phoenix.clouddancer.com>
 <DJqdncuoKsfQNVneRVn-gA@speakeasy.net> <uk6d76s9p.fsf@agharta.de>
 <G_qdnfy3B944eFnenZ2dnUVZ_v2dnZ2d@speakeasy.net>
 <op.s27ovvqcpqzri1@mjolner.upc.no>
Reply-To: spamt...@agharta.de
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: individual.net Dpn+8zU7/MWWQZF5KPMZ3wPq36sjzepJLh+3HTCRCX5X/G0G8=
X-Home-Page: http://weitz.de/
Mail-Copies-To: never
User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/22.0.50 (windows-nt)
Cancel-Lock: sha1:Dk1OaJnJV/7RcyT4u4YfBiLtzRQ=

On Wed, 11 Jan 2006 12:29:45 +0100, "John Thingstad" <john.things...@chello.no> wrote:

> On Wed, 11 Jan 2006 12:01:57 +0100, Rob Warnock <r...@rpw3.org> wrote:
>
>>       (loop for i fixnum from 0 by 4
>
> Speaking of which the type declarations in the loop variable really
> interested me. If fills a whole which declare can't cover.
> But it dosn't seem to work in LspWorks.

Why do you think that?

  CL-USER 11 > (pprint (macroexpand '(loop for i below 4 collect i)))

  (BLOCK NIL
    (MACROLET ((LOOP-FINISH () '(GO #:|end-loop-7571|)))
      (LET ((#:|to-7574| 4) (#:|by-7575| 1) (I 0))
        (LET ((#:|accumulator-7572| (LIST NIL)))
          (DECLARE (TYPE LIST #:|accumulator-7572|))
          (LET ((#:|aux-var-7577| #:|accumulator-7572|))
            (TAGBODY (PROGN (WHEN (OR (>= I #:|to-7574|)) (GO #:|end-loop-7571|)))
             #:|begin-loop-7570| (SETQ #:|aux-var-7577| (LAST (RPLACD #:|aux-var-7577| (LIST I))))
                     (PROGN
                       (LET ((#:|temp-7576| (+ I #:|by-7575|))) (SETQ I #:|temp-7576|))
                       (WHEN (OR (>= I #:|to-7574|)) (GO #:|end-loop-7571|)))
                     (GO #:|begin-loop-7570|)
             #:|end-loop-7571| (RETURN-FROM NIL (CDR #:|accumulator-7572|))))))))

  CL-USER 12 > (pprint (macroexpand '(loop for i fixnum below 4 collect i)))

  (BLOCK NIL
    (MACROLET ((LOOP-FINISH () '(GO #:|end-loop-7579|)))
      (LET ((#:|to-7582| 4) (#:|by-7583| 1) (I 0))
        (DECLARE (TYPE FIXNUM I))    ;;  <------- LOOK HERE
        (LET ((#:|accumulator-7580| (LIST NIL)))
          (DECLARE (TYPE LIST #:|accumulator-7580|))
          (LET ((#:|aux-var-7585| #:|accumulator-7580|))
            (TAGBODY (PROGN (WHEN (OR (>= I #:|to-7582|)) (GO #:|end-loop-7579|)))
             #:|begin-loop-7578| (SETQ #:|aux-var-7585| (LAST (RPLACD #:|aux-var-7585| (LIST I))))
                     (PROGN
                       (LET ((#:|temp-7584| (+ I #:|by-7583|))) (SETQ I #:|temp-7584|))
                       (WHEN (OR (>= I #:|to-7582|)) (GO #:|end-loop-7579|)))
                     (GO #:|begin-loop-7578|)
             #:|end-loop-7579| (RETURN-FROM NIL (CDR #:|accumulator-7580|))))))))

> Is this a SBCL spesific addition?

It can be found in the ANSI spec.  (Besides, Rob's code was for CMUCL
and not for SBCL, IIRC.)

Cheers,
Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq "spamt...@agharta.de" 5) "edi")