Re: Python and Scheme



namekuseijin escreveu:
namekuseijin escreveu:
Michele Simionato escreveu:
On Apr 23, 6:19 pm, Sam TH <sam...@xxxxxxxxx> wrote:
[samth@punge:~/work/teaching/current] cat tailcall.ss
(import (rnrs))
(let loop ([n 1000]) (if (zero? n) #f (begin (/ 1 (- n 12)) (loop (- n
1)))))
But the best is Larceny:

$/home/micheles/packages/larceny_src/scheme-script tailcall2.ss

no error here (!!???)

This issues an error:
(let loop ((n 1000) (r #f)) (if (zero? n) r (loop (- n
1) (/ 1 (- n 12)))))

I guess the error is just ignored being in the head of begin since it
affects no further computation...

Perhaps it even simply removes the useless computation when compiling
down to native code?...

Damn, should test first before posting: yes, it does seem to simply
remove the useless declaration from the generated native code, because
this consumes the resulted computation and thus issues the error:

(let loop ((n 1000))
(if (zero? n) #f
(begin (display (/ 1 (- n 12)))
(loop (- n 1)))))


--
a game sig: http://tinyurl.com/d3rxz9
.



Relevant Pages

  • Re: Processor question
    ... I'm sure the compiler is awfully naieve though, ... Count exactly how many instructions it has to execute to get around the loop once. ... Old x86 code has to compute 32 bit operations as two 16 bit native code ops so it will be slower. ... Cache structure really matters when you are handling bulk data that is large compared to the cache sizeof the processor. ...
    (sci.electronics.design)
  • Re: VBA end if without block if and loop without do errors on code
    ... ' blah blah blah ... It's not like you can force an outer loop to iterate by specifying its ... I had the app compiled 3 times: native code, ... no difference between both native code compilations, ...
    (microsoft.public.vb.general.discussion)
  • Re: Native Code vs PCode
    ... >I've got some activex dlls that access a database, retrieve recordsets, loop ... >Would it make a big difference if I compiled to PCode instead of Native Code ...
    (microsoft.public.vb.general.discussion)
  • Native Code vs PCode
    ... I've got some activex dlls that access a database, retrieve recordsets, loop ... Would it make a big difference if I compiled to PCode instead of Native Code ...
    (microsoft.public.vb.general.discussion)