#232 make-parameter only accepts one argument

open
nobody
None
5
2007-08-11
2007-08-11
No

SISC (1.16.6)
#;> (define foo (make-parameter 0 (lambda (x) (cond ((< x 0) 0) ((> x 2) 2) (else x)))))
Error in _make-parameter: incorrect number of arguments to procedure.
console:1:13: <from call to @srfi-39::make-parameter>
[previous entry repeated twice]
---------------------------
To enable more detailed stack tracing, set the dynamic parameter max-stack-trace-depth to a non-zero value, e.g. 16.
---------------------------
Some stack trace entries may have been suppressed. To see all entries set the dynamic parameter suppressed-stack-trace-source-kinds to '().

----

Apparently the problem is that init2.scm does contain the correct definition, but srfi-39.scm overwrites that with the native procedure _make-parameter which only accepts one argument.

When I re-evaluate the definition from init2.scm, all is well:

#;> (define (make-parameter value . converter)
(cond [(null? converter)
(_make-parameter value)]
[(null? (cdr converter))
(let ([param (_make-parameter value)]
[converter (car converter)])
(lambda arg
(if (null? arg)
(param)
(param (converter (car arg))))))]
[else (error 'make-parameter "too many arguments.")]))

#;> (define foo (make-parameter 0 (lambda (x) (cond ((< x 0) 0) ((> x 2) 2) (else x)))))
#;>
(foo)
0
#;> (foo -1)
0
#;>

Discussion