larcenists / larceny

Larceny Scheme implementation
Other
202 stars 32 forks source link

Parameters are incorrectly restored at the exit of the parameterize form #767

Closed mnieper closed 8 years ago

mnieper commented 8 years ago

Larceny currently evaluates

(begin
  (define x (make-parameter 1 (lambda (x) (* x 10))))
  (parameterize ((x 2)) #f)
  (x)

to 100, and not to 10, as expected. Further experiments show that the conversion function (lambda (x) (* x 10) is (incorrectly) applied when the previous parameter value has to be restored. In other words, after further uses of parameterize, (x) gives 1000, 10000, and so on.

mnieper commented 8 years ago

Supposedly, Larceny's internal parameterize evaluates (<parameter-object> <new-value>) to restore the value of the parameter. However, the signature of SRFI 39-parameters is incompatible with Larceny's internal parameters because of the possibility of non-idempotent conversion procedures: https://github.com/larcenists/larceny/blob/master/lib/SRFI/srfi-39.sch#L16.

WillClinger commented 8 years ago

Fixed by changesets 96e000be8d31c84fde7918d599b7df68b85cbda0 and d8a1c3527cdc66ee9c0e31fc3d6cc8d3e8fab0d1

mnieper commented 8 years ago

Thanks a lot for fixing all the bugs that I reported so quickly. I discovered the bugs while using Larceny during development of my expander for R7RS-libraries and -macros. While I could code around most of the bugs, fixing the bug of this issue was crucial.

I would like to make the first release of the expander soon. For this, it would be nice if a precompiled (i.e. a post-0.99) version of Larceny with the latest bug fixes included was available. Otherwise, users of the expander would have to compile the current development version of Larceny by hand.

WillClinger commented 8 years ago

I hope to make the nightly builds available again soon. When you say "soon", how soon do you mean?

mnieper commented 8 years ago

I have released a preview version today and added a note saying that one needs to compile a development version of Larceny by hand in order to use the expander until post-0.99 is out.

I guess that most people will want to wait for the next release of Larceny, though, instead of compiling it by hand. So I am definitely looking forward to the nightly builds of Larceny, but don't feel rushed.

P.S.: As for the problem of reporting line numbers in library and macro expanded code, maybe you can make use of my expander as an R7RS-frontend for Larceny. It takes a lot of care in order to track locations precisely.