[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Strange behavior with delayed objects
From: |
Andy Wingo |
Subject: |
Re: Strange behavior with delayed objects |
Date: |
Fri, 21 May 2010 12:59:31 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) |
Hello,
On Fri 14 May 2010 23:53, user8472 <address@hidden> writes:
> The solution is thus to wrap the defines in (lambda () ...)s.
>
> <code>
> (define (solve f y0 dt)
> (define (y) (integral (delay (dy)) y0 dt))
> (define (dy) (stream-map f (y)))
> (y))
>
> (debug-set! stack 2000000)
> (stream-ref (solve (lambda (x) x) 1 0.001) 1000)
> </code>
>
> will produce the correct answer. The downside is that the function calls
> will be wrapped recursively which necessitates increasing the stack size.
> Plus, it's much slower this way. But it works.
The fact that it's slow is an implementation detail. Lambda expressions
are simply abstractions over scope -- they do not necessitate the
creation of closures. Guile 2.0 is already much faster for this case,
I believe, and with a proper inliner, y and dy would not actually be
implemented with functions.
Andy
--
http://wingolog.org/
- Re: Strange behavior with delayed objects, (continued)
- Re: Strange behavior with delayed objects, Linas Vepstas, 2010/05/04
- Re: Strange behavior with delayed objects, user8472, 2010/05/04
- Re: Strange behavior with delayed objects, Linas Vepstas, 2010/05/05
- Re: Strange behavior with delayed objects, user8472, 2010/05/07
- Re: Strange behavior with delayed objects, Linas Vepstas, 2010/05/10
- Re: Strange behavior with delayed objects, Linas Vepstas, 2010/05/10
- Re: Strange behavior with delayed objects, user8472, 2010/05/10
- Re: Strange behavior with delayed objects, Linas Vepstas, 2010/05/10
Re: Strange behavior with delayed objects, Andy Wingo, 2010/05/21
Re: Strange behavior with delayed objects, user8472, 2010/05/14
- Re: Strange behavior with delayed objects,
Andy Wingo <=