chibi-scheme icon indicating copy to clipboard operation
chibi-scheme copied to clipboard

define-function/define-variable equivalence

Open GoogleCodeExporter opened this issue 9 years ago • 1 comments

What steps will reproduce the problem?
> (define ((f x) y) (+ x y))

What is the expected output?
f should be defined as (lambda (x) (lambda (y) (+ x y)))

What do you see instead?
ERROR on line 1: can't define a non-symbol: (define ((f x) y) (+ x y))

What version of the product are you using? On what operating system?
boran/OS X and Linux

Please provide any additional information below.
I haven't dug into the source code but I assume (define var val) and (define 
(func . args) body) are evaluated differently. If (define (func . args) body) 
expands to (define func (lambda args body)) then it follows that (define ((func 
. args1) . args2) body) should expand to (define (func . args1) (lambda args2 
body)) which expands to (define func (lambda args1 (lambda args2 body))).

I know it's not in the standard, but it is used throughout SICM if that means 
anything to you. Plus it's just a really cool way to write clean higher-order 
functions.

Original issue reported on code.google.com by caseydwyer on 24 Oct 2012 at 11:14

GoogleCodeExporter avatar Mar 16 '15 12:03 GoogleCodeExporter

I'll have to think about this.  I'm trying to keep the
core of Chibi as close to R7RS as possible, so people
can move their programs easily to other implementations.

It's probably better to simply write a library with a
define macro that handles this, so you can import and
use that portably.

Original comment by [email protected] on 24 Oct 2012 at 11:29

  • Changed state: Accepted
  • Added labels: Type-Enhancement, Priority-Low
  • Removed labels: Type-Defect, Priority-Medium

GoogleCodeExporter avatar Mar 16 '15 12:03 GoogleCodeExporter