unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] `any' and `every' in `(oop goops util)'
@ 2005-10-20  9:16 Ludovic Courtès
  2005-10-20 19:47 ` Kevin Ryde
  0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2005-10-20  9:16 UTC (permalink / raw)


Hi,

The `(oop goops util)' module currently exports its own version of `any' and
`every', which is unnecessary and causes warnings to be issued when
`(srfi srfi-1)' is being used.  The patch below fixes this.

Thanks,
Ludovic.


2005-10-20  Ludovic Courtès  <ludovic.courtes@laas.fr>

	* oop/goops/util.scm: Don't export custom versions of `any' and
	  `every'; re-export those of `(srfi srfi-1)' instead.


--- orig/oop/goops/util.scm
+++ mod/oop/goops/util.scm
@@ -17,9 +17,9 @@
 \f
 
 (define-module (oop goops util)
-  :export (any every
-	   mapappend find-duplicate top-level-env top-level-env?
+  :export (mapappend find-duplicate top-level-env top-level-env?
 	   map* for-each* length* improper->proper)
+  :use-module (srfi srfi-1)
   :no-backtrace
   )
 
@@ -28,37 +28,7 @@
 ;;; {Utilities}
 ;;;
 
-(define (any pred lst . rest)
-  (if (null? rest) ;fast path
-      (and (not (null? lst))
-           (let loop ((head (car lst)) (tail (cdr lst)))
-             (if (null? tail)
-                 (pred head)
-                 (or (pred head)
-                     (loop (car tail) (cdr tail))))))
-      (let ((lsts (cons lst rest)))
-        (and (not (any null? lsts))
-             (let loop ((heads (map car lsts)) (tails (map cdr lsts)))
-               (if (any null? tails)
-                   (apply pred heads)
-                   (or (apply pred heads)
-                       (loop (map car tails) (map cdr tails)))))))))
-
-(define (every pred lst . rest)
-  (if (null? rest) ;fast path
-      (or (null? lst)
-          (let loop ((head (car lst)) (tail (cdr lst)))
-            (if (null? tail)
-                (pred head)
-                (and (pred head)
-                     (loop (car tail) (cdr tail))))))
-      (let ((lsts (cons lst rest)))
-        (or (any null? lsts)
-            (let loop ((heads (map car lsts)) (tails (map cdr lsts)))
-              (if (any null? tails)
-                  (apply pred heads)
-                  (and (apply pred heads)
-                       (loop (map car tails) (map cdr tails)))))))))
+(re-export any every)
 
 (define (mapappend func . args)
   (if (memv '()  args)
@@ -67,7 +37,7 @@
 	      (apply mapappend func (map cdr args)))))
 
 (define (find-duplicate l)	; find a duplicate in a list; #f otherwise
-  (cond 
+  (cond
     ((null? l)			#f)
     ((memv (car l) (cdr l))	(car l))
     (else 			(find-duplicate (cdr l)))))



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] `any' and `every' in `(oop goops util)'
  2005-10-20  9:16 [PATCH] `any' and `every' in `(oop goops util)' Ludovic Courtès
@ 2005-10-20 19:47 ` Kevin Ryde
  2005-10-21  7:54   ` Ludovic Courtès
  2005-12-06 23:11   ` Marius Vollmer
  0 siblings, 2 replies; 9+ messages in thread
From: Kevin Ryde @ 2005-10-20 19:47 UTC (permalink / raw)


ludovic.courtes@laas.fr (Ludovic Courtès) writes:
>
> Hi,
>
> The `(oop goops util)' module currently exports its own version of `any' and
> `every', which is unnecessary and causes warnings to be issued when
> `(srfi srfi-1)' is being used.

When using (oop goops) ?  I'm not sure (oop goops util) is meant to be
used outside the goops implementation.

(There's a non-tail recursive mapappend which could probably benefit
from srfi-1 append-map too, incidentally.)


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] `any' and `every' in `(oop goops util)'
  2005-10-20 19:47 ` Kevin Ryde
@ 2005-10-21  7:54   ` Ludovic Courtès
  2005-10-21 20:38     ` Kevin Ryde
  2005-12-06 23:11   ` Marius Vollmer
  1 sibling, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2005-10-21  7:54 UTC (permalink / raw)


Kevin Ryde <user42@zip.com.au> writes:

> When using (oop goops) ?  I'm not sure (oop goops util) is meant to be
> used outside the goops implementation.

And what difference does/would it make?

> (There's a non-tail recursive mapappend which could probably benefit
> from srfi-1 append-map too, incidentally.)

Right.  But this requires modifying all the users of `(oop goops util)'.

Thanks,
Ludovic.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] `any' and `every' in `(oop goops util)'
  2005-10-21  7:54   ` Ludovic Courtès
@ 2005-10-21 20:38     ` Kevin Ryde
  2005-10-24  7:45       ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Ryde @ 2005-10-21 20:38 UTC (permalink / raw)


ludovic.courtes@laas.fr (Ludovic Courtès) writes:
>
> Kevin Ryde <user42@zip.com.au> writes:
>
>> When using (oop goops) ?  I'm not sure (oop goops util) is meant to be
>> used outside the goops implementation.
>
> And what difference does/would it make?

If you're not supposed to use it then any warnings it provokes when
you do aren't a big deal :).

Now that srfi-1 has a lot more C code it's probably worth using for
performance.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] `any' and `every' in `(oop goops util)'
  2005-10-21 20:38     ` Kevin Ryde
@ 2005-10-24  7:45       ` Ludovic Courtès
  0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2005-10-24  7:45 UTC (permalink / raw)


Hi,

Kevin Ryde <user42@zip.com.au> writes:

> If you're not supposed to use it then any warnings it provokes when
> you do aren't a big deal :).

Right.  ;-)

> Now that srfi-1 has a lot more C code it's probably worth using for
> performance.

Yes, that's the point I was trying to make: this module had better use
SRFI-1 as much as possible (also for maintainability and consistency
reasons).

Thanks,
Ludovic.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] `any' and `every' in `(oop goops util)'
  2005-10-20 19:47 ` Kevin Ryde
  2005-10-21  7:54   ` Ludovic Courtès
@ 2005-12-06 23:11   ` Marius Vollmer
  2005-12-07  9:59     ` Ludovic Courtès
  1 sibling, 1 reply; 9+ messages in thread
From: Marius Vollmer @ 2005-12-06 23:11 UTC (permalink / raw)


>> The `(oop goops util)' module currently exports its own version of `any' and
>> `every', which is unnecessary and causes warnings to be issued when
>> `(srfi srfi-1)' is being used.
>
> When using (oop goops) ?  I'm not sure (oop goops util) is meant to be
> used outside the goops implementation.

(oop goops util) is not meant to be used outside the goops
implementation.  I'd rather not touch it for cosmetic purposes
only... :-)

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] `any' and `every' in `(oop goops util)'
  2005-12-06 23:11   ` Marius Vollmer
@ 2005-12-07  9:59     ` Ludovic Courtès
  2005-12-07 19:41       ` Neil Jerram
  0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2005-12-07  9:59 UTC (permalink / raw)
  Cc: guile-devel

Marius Vollmer <mvo@zagadka.de> writes:

> (oop goops util) is not meant to be used outside the goops
> implementation.  I'd rather not touch it for cosmetic purposes
> only... :-)

Sure, but why re-implement a subset of SRFI-1 in there, especially
non-tail-recursive variants?

Thanks,
Ludovic.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] `any' and `every' in `(oop goops util)'
  2005-12-07  9:59     ` Ludovic Courtès
@ 2005-12-07 19:41       ` Neil Jerram
  2005-12-08  7:51         ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: Neil Jerram @ 2005-12-07 19:41 UTC (permalink / raw)
  Cc: guile-devel

ludovic.courtes@laas.fr (Ludovic Courtès) writes:

> Marius Vollmer <mvo@zagadka.de> writes:
>
>> (oop goops util) is not meant to be used outside the goops
>> implementation.  I'd rather not touch it for cosmetic purposes
>> only... :-)
>
> Sure, but why re-implement a subset of SRFI-1 in there, especially
> non-tail-recursive variants?

Couldn't we then remove any and every from util.scm, and change
goops.scm to use (srfi srfi-1)?  This will catch anyone who has used
(oop goops util) to get any/every, but that's an odd thing to do and
we can cover it in a NEWS item.

Regards,
        Neil



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] `any' and `every' in `(oop goops util)'
  2005-12-07 19:41       ` Neil Jerram
@ 2005-12-08  7:51         ` Ludovic Courtès
  0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2005-12-08  7:51 UTC (permalink / raw)
  Cc: guile-devel

Neil Jerram <neil@ossau.uklinux.net> writes:

> Couldn't we then remove any and every from util.scm, and change
> goops.scm to use (srfi srfi-1)?  This will catch anyone who has used
> (oop goops util) to get any/every, but that's an odd thing to do and
> we can cover it in a NEWS item.

Agreed.  I might give it a try next week if nobody did it by then.

Thanks,
Ludovic.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-12-08  7:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-20  9:16 [PATCH] `any' and `every' in `(oop goops util)' Ludovic Courtès
2005-10-20 19:47 ` Kevin Ryde
2005-10-21  7:54   ` Ludovic Courtès
2005-10-21 20:38     ` Kevin Ryde
2005-10-24  7:45       ` Ludovic Courtès
2005-12-06 23:11   ` Marius Vollmer
2005-12-07  9:59     ` Ludovic Courtès
2005-12-07 19:41       ` Neil Jerram
2005-12-08  7:51         ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).