From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28453 invoked by alias); 25 Oct 2015 17:59:40 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 28383 invoked by uid 89); 25 Oct 2015 17:59:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.6 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f179.google.com Received: from mail-ig0-f179.google.com (HELO mail-ig0-f179.google.com) (209.85.213.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 25 Oct 2015 17:59:37 +0000 Received: by igbdj2 with SMTP id dj2so43336496igb.1 for ; Sun, 25 Oct 2015 10:59:36 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.41.74 with SMTP id d10mr15424958igl.94.1445795976023; Sun, 25 Oct 2015 10:59:36 -0700 (PDT) Received: by 10.36.202.132 with HTTP; Sun, 25 Oct 2015 10:59:35 -0700 (PDT) Date: Sun, 25 Oct 2015 17:59:00 -0000 Message-ID: Subject: learning scheme with kawa From: Debabrata Pani To: kawa@sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-q4/txt/msg00017.txt.bz2 Hi, I was reading The Scheme Programming Language 4th Edition and practicing on Kawa. I wanted to use kawa because it sits atop jvm and this can help in leveraging my experience in using java apis. I ran into some issues while solving the following exercise Exercise 2.7.2 had you use length in the definition of shorter, which returns the shorter of its two list arguments, or the first if the two have the same length. Write shorter without using length. [Hint: Define a recursive helper, shorter?, and use it in place of the length comparison.] (reference : http://scheme.com/tspl4/start.html#./start:h2) I wrote up the following(see below) in a file reciprocal.ss . The expectation was that the out of order definition (of shorter and shorter?) should not matter. (define shorter ;; (shorter =E2=80=98(a b c) =E2=80=98(d e f g)) =3D> (a b c) ;; (shorter =E2=80=98(a b c) =E2=80=98(d e f)) =3D> (a b c) ;; (shorter =E2=80=98(a b c) =E2=80=98(d e)) =3D> (d e) ;; don=E2=80=99t use the length function (lambda (l1 l2) (let ((val (shorter? l1 l2))) (if (=3D 0 val) l1 l2)))) (define shorter? (lambda (l1 l2) (if (null? l1) 0 (if (null? l2) 1 (shorter? (cdr l1) (cdr l2)))))) But in KAWA it does matter. I got the following error: |kawa:1|# (load =E2=80=9Creciprocal.ss=E2=80=9D) reciprocal.ss:67:20: call to =E2=80=98shorter?=E2=80=99 has too many argume= nts (2; must be 1) |kawa:2|# (shorter =E2=80=98(a b) =E2=80=98(d e f)) /dev/stdin:2:1: warning - no declaration seen for shorter /dev/stdin:2:1: unbound location: shorter at gnu.mapping.SharedLocation.get(SharedLocation.java:22) at gnu.mapping.DynamicLocation.get(DynamicLocation.java:28) at atInteractiveLevel$13.run(stdin:2) at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:317) at gnu.expr.ModuleExp.evalModule(ModuleExp.java:219) at kawa.Shell.run(Shell.java:291) at kawa.Shell.run(Shell.java:203) at kawa.Shell.run(Shell.java:184) at kawa.repl.main(repl.java:892) |kawa:3| But in Chicken scheme, I am able to go through : ;4> (load =E2=80=9Creciprocal.ss=E2=80=9D) ; loading reciprocal.ss =E2=80=A6 ;5> (shorter =E2=80=98(a b) =E2=80=98(d e f)) (a b) ;6> I get the same error when executing the script using kawa java -cp "/usr/local/Cellar/kawa/2.0/kawa-2.0.jar" kawa.repl -f reciprocal.= ss reciprocal.ss:67:20: call to 'shorter?' has too many arguments (2; must be = 1) reciprocal.ss:80:10: warning - no declaration seen for shorter reciprocal.ss:80:10: unbound location: shorter at gnu.mapping.SharedLocation.get(SharedLocation.java:22) at gnu.mapping.DynamicLocation.get(DynamicLocation.java:28) at atInteractiveLevel$11.run(reciprocal.ss:80) at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:317) at gnu.expr.ModuleExp.evalModule(ModuleExp.java:219) at kawa.Shell.run(Shell.java:291) at kawa.Shell.runFile(Shell.java:523) at kawa.Shell.runFileOrClass(Shell.java:447) at kawa.repl.processArgs(repl.java:260) at kawa.repl.main(repl.java:871) Query Is this a known discrepancy in the behavior of kawa? Are we violating any RNRS rule when we do this ? Regards, Debabrata Pani