Re: [Chicken-hackers] [PATCH] Capture length in case-lambda to make it hygienic

2012-03-25 Thread Christian Kellermann
* Moritz Heidkamp  [120325 16:38]:
> Thanks a bunch! I have another small patch which renames the regression
> test module to be slightly more descriptive. I already have the need for
> yet another hygiene regression test so I guess it makes sense to
> properly name those modules :-)

Trivial. And pushed.

-- 
9 out of 10 voices in my head say, that I am crazy,
one is humming.

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] [PATCH] Capture length in case-lambda to make it hygienic

2012-03-25 Thread Moritz Heidkamp
Christian Kellermann  writes:
> I have amended your test's commit message and comment to reflect
> the correct commit hashes (I hope). Other than that these are fine
> and I've pushed them.

Thanks a bunch! I have another small patch which renames the regression
test module to be slightly more descriptive. I already have the need for
yet another hygiene regression test so I guess it makes sense to
properly name those modules :-)

Moritz
>From 12aa01799de4baa6dae5ef223a9783b1f85e7889 Mon Sep 17 00:00:00 2001
From: Moritz Heidkamp 
Date: Sun, 25 Mar 2012 16:36:27 +0200
Subject: [PATCH] give the #805 regression test module a more descriptive name

---
 tests/syntax-tests.scm |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm
index 82a3850..c1a2fa8 100644
--- a/tests/syntax-tests.scm
+++ b/tests/syntax-tests.scm
@@ -970,7 +970,7 @@ take
 
 
 ;; #805: case-lambda is unhygienic (as well as ensure, see 4706afb4 and bc5cc698)
-(module foo ()
+(module case-lambda-and-ensure-hygiene ()
   (import (prefix chicken c/) (prefix scheme s/))
   (c/case-lambda ((a) a))
   (c/ensure s/even? 2))
-- 
1.7.9.4

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] [PATCH] Capture length in case-lambda to make it hygienic

2012-03-25 Thread Christian Kellermann
* Moritz Heidkamp  [120325 14:26]:
> Hi Christian,
> 
> Christian Kellermann  writes:
> > the attached patch fixes #805, by capturing the core length procedure
> > correctly. Thanks go to Moritz for finding and reporting this issue.
> 
> I found yet another hygiene issue in `case-lambda' in the meantime and a
> similar one in `ensure'. The attached patches address these also add
> some regression tests.
> 
> Thanks again for your help!

I have amended your test's commit message and comment to reflect
the correct commit hashes (I hope). Other than that these are fine
and I've pushed them.

Cheers,

Christian

-- 
9 out of 10 voices in my head say, that I am crazy,
one is humming.

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


Re: [Chicken-hackers] [PATCH] Capture length in case-lambda to make it hygienic

2012-03-25 Thread Moritz Heidkamp
Hi Christian,

Christian Kellermann  writes:
> the attached patch fixes #805, by capturing the core length procedure
> correctly. Thanks go to Moritz for finding and reporting this issue.

I found yet another hygiene issue in `case-lambda' in the meantime and a
similar one in `ensure'. The attached patches address these also add
some regression tests.

Thanks again for your help!

Moritz
>From a441b07473a93f5216c31ae23dd993ff61958f15 Mon Sep 17 00:00:00 2001
From: Moritz Heidkamp 
Date: Sun, 25 Mar 2012 14:24:07 +0200
Subject: [PATCH 1/3] Fix hygiene issues in `case-lambda'

This adresses bug #805
---
 chicken-syntax.scm |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/chicken-syntax.scm b/chicken-syntax.scm
index 08bede2..b634d1f 100644
--- a/chicken-syntax.scm
+++ b/chicken-syntax.scm
@@ -764,7 +764,8 @@
  `((>= . ,(##sys#primitive-alias '>=))
(car . ,(##sys#primitive-alias 'car))
(cdr . ,(##sys#primitive-alias 'cdr))
-   (eq? . ,(##sys#primitive-alias 'eq?)))
+   (eq? . ,(##sys#primitive-alias 'eq?))
+   (length . ,(##sys#primitive-alias 'length)))
  (##sys#er-transformer
   (lambda (form r c)
 (##sys#check-syntax 'case-lambda form '(_ . _))
@@ -785,11 +786,12 @@
 	   (%>= (r '>=))
 	   (%eq? (r 'eq?))
 	   (%car (r 'car))
-	   (%cdr (r 'cdr)))
+	   (%cdr (r 'cdr))
+	   (%length (r 'length)))
   `(##core#lambda
 	,(append minvars rvar)
 	(##core#let
-	 ((,lvar (length ,rvar)))
+((,lvar (,%length ,rvar)))
 	 ,(fold-right
 	   (lambda (c body)
 	 (##sys#decompose-lambda-list
@@ -820,7 +822,7 @@
  bindings
  `(##core#let ,(map list vars1 minvars) ,bindings) ) ) )
 			,body) ) ) )
-	   '(##core#check (##sys#error (##core#immutable '"no matching clause in call to 'case-lambda' form")))
+	   '(##core#check (##sys#error (##core#immutable (##core#quote "no matching clause in call to 'case-lambda' form"
 	   (cdr form
 
 
-- 
1.7.9.4

>From 7ef5a447cfdde5214b95a8648501e1483c33a805 Mon Sep 17 00:00:00 2001
From: Moritz Heidkamp 
Date: Sun, 25 Mar 2012 14:24:19 +0200
Subject: [PATCH 2/3] Fix hygiene issue in `ensure'

---
 chicken-syntax.scm |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/chicken-syntax.scm b/chicken-syntax.scm
index b634d1f..2ea7072 100644
--- a/chicken-syntax.scm
+++ b/chicken-syntax.scm
@@ -208,8 +208,8 @@
 		#:type-error
 		,@(if (pair? args)
 			  args
-			  `((##core#immutable '"argument has incorrect type")
-			,tmp ',pred) ) ) ) ) ) ) ) )
+			  `((##core#immutable (##core#quote "argument has incorrect type"))
+			,tmp (##core#quote ,pred)) ) ) ) ) ) ) ) )
 
 (##sys#extend-macro-environment
  'fluid-let '()
-- 
1.7.9.4

>From 75a09261c6ae737f6f42dd44bc737fcaa060186c Mon Sep 17 00:00:00 2001
From: Moritz Heidkamp 
Date: Sun, 25 Mar 2012 14:24:35 +0200
Subject: [PATCH 3/3] Add regression tests for fixes introduced in a441b074
 and 7ef5a447

---
 tests/syntax-tests.scm |7 +++
 1 file changed, 7 insertions(+)

diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm
index 21f57e5..bb2e2d2 100644
--- a/tests/syntax-tests.scm
+++ b/tests/syntax-tests.scm
@@ -967,3 +967,10 @@
 
 (use (prefix srfi-1 list-))
 take
+
+
+;; #805: case-lambda is unhygienic (as well as ensure, see c1160ca7 and 7fe07e9c)
+(module foo ()
+  (import (prefix chicken c/) (prefix scheme s/))
+  (c/case-lambda ((a) a))
+  (c/ensure s/even? 2))
-- 
1.7.9.4

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


[Chicken-hackers] [PATCH] Capture length in case-lambda to make it hygienic

2012-03-25 Thread Christian Kellermann
Hi,

the attached patch fixes #805, by capturing the core length procedure
correctly. Thanks go to Moritz for finding and reporting this issue.

Kind regards,

Christian

-- 
9 out of 10 voices in my head say, that I am crazy,
one is humming.
>From 2fdeaab6f1f3f240a6e45427d8ccd590d9e7e612 Mon Sep 17 00:00:00 2001
From: Christian Kellermann 
Date: Sun, 25 Mar 2012 13:58:25 +0200
Subject: [PATCH] Capture length in case-lambda to make it hygienic

This fixes bug #805 as reported by Moritz.
---
 chicken-syntax.scm |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/chicken-syntax.scm b/chicken-syntax.scm
index 08bede2..a47763f 100644
--- a/chicken-syntax.scm
+++ b/chicken-syntax.scm
@@ -764,7 +764,8 @@
  `((>= . ,(##sys#primitive-alias '>=))
(car . ,(##sys#primitive-alias 'car))
(cdr . ,(##sys#primitive-alias 'cdr))
-   (eq? . ,(##sys#primitive-alias 'eq?)))
+   (eq? . ,(##sys#primitive-alias 'eq?))
+   (length . ,(##sys#primitive-alias 'length)))
  (##sys#er-transformer
   (lambda (form r c)
 (##sys#check-syntax 'case-lambda form '(_ . _))
@@ -785,11 +786,12 @@
   (%>= (r '>=))
   (%eq? (r 'eq?))
   (%car (r 'car))
-  (%cdr (r 'cdr)))
+  (%cdr (r 'cdr))
+  (%length (r 'length)))
   `(##core#lambda
,(append minvars rvar)
(##core#let
-((,lvar (length ,rvar)))
+((,lvar (,%length ,rvar)))
 ,(fold-right
   (lambda (c body)
 (##sys#decompose-lambda-list
-- 
1.7.6

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers