bug#13741: guile-2.0: optimize, and eq-ness of literals (test-suite)

2013-02-18 Thread Ludovic Courtès
Daniel Hartwig  skribis:

>   scheme@(guile-user)> (define x 1/2)
>   scheme@(guile-user)> (eq? x 2/4)
>   $7 = #f
>   scheme@(guile-user)> ,optimize (eq? x 2/4)
>   $8 = (eq? x 1/2)
>   scheme@(guile-user)> (define y 2/4)
>   scheme@(guile-user)> (eq? x y)
>   $9 = #f
>   scheme@(guile-user)> ,optimize (define y 2/4)
>   $10 = (define y 1/2)

Quoth R5RS:

 `Eq?''s behavior on numbers and characters is
 implementation-dependent, but it will always return either true or
 false, and will return true only when `eqv?' would also return
 true.  `Eq?' may also behave differently from `eqv?' on empty
 vectors and empty strings.

What we may get wrong is that it looks as if it doesn’t always return
either true or false, because the behavior depends on whether one of the
operands is a literal.

However, it’s fundamentally wrong to rely on eq? to compare numbers.  So
the test case you mention seems buggy, to start with.

WDYT?

Ludo’.





bug#13741: guile-2.0: optimize, and eq-ness of literals (test-suite)

2013-02-18 Thread Andy Wingo
On Mon 18 Feb 2013 10:16, l...@gnu.org (Ludovic Courtès) writes:

> Daniel Hartwig  skribis:
>
>>   scheme@(guile-user)> (define x 1/2)
>>   scheme@(guile-user)> (eq? x 2/4)
>>   $7 = #f
>>   scheme@(guile-user)> ,optimize (eq? x 2/4)
>>   $8 = (eq? x 1/2)
>>   scheme@(guile-user)> (define y 2/4)
>>   scheme@(guile-user)> (eq? x y)
>>   $9 = #f
>>   scheme@(guile-user)> ,optimize (define y 2/4)
>>   $10 = (define y 1/2)
>
> Quoth R5RS:
>
>  `Eq?''s behavior on numbers and characters is
>  implementation-dependent, but it will always return either true or
>  false, and will return true only when `eqv?' would also return
>  true.  `Eq?' may also behave differently from `eqv?' on empty
>  vectors and empty strings.
>
> What we may get wrong is that it looks as if it doesn’t always return
> either true or false, because the behavior depends on whether one of the
> operands is a literal.
>
> However, it’s fundamentally wrong to rely on eq? to compare numbers.  So
> the test case you mention seems buggy, to start with.

Agreed, FWIW.  Fractions are allocated on the heap, and eq? picks out
the difference between heap objects.  Sometimes two values are the same
object, and sometimes not.

Closing the bug, but please follow up with any questions.

Cheers,

Andy
-- 
http://wingolog.org/





bug#10474: Building guile 2.x under mingw + msys

2013-02-18 Thread Andy Wingo
Hi Eli,

I'm terribly sorry for the delay here.  I realize you've probably paged
out all of these patches from memory, but I would like to pick up the
loose ends.

On Thu 02 Feb 2012 18:34, Eli Zaretskii  writes:

>  . lib/canonicalize-lgpl.c -- does not support Windows absolute file
>   names.  Will be fixed in gnulib.

I see you got this into gnulib in November
(http://lists.gnu.org/archive/html/bug-gnulib/2012-11/msg00090.html).
I just updated our Gnulib so we have it now.  Thanks!

>  . libguile/dynl.c -- lacks setenv.  Gnulib's setenv should be used.

This change was made in Guile on 25 January 2012.

>  . libguile/expand.c -- Defines CONST and VOID.  Should define
> SCM_CONST and SCM_VOID (or some other, less
> ubiquitous, symbols) instead.

Fixed in Guile on July 6 2012.

>  . libguile/fports.c -- Doesn't implement fport_input_waiting when
> neither poll nor select nor FIONREAD are
> available, without which interactive guile
> won't start.  Should use the gnulib select
> module.

Just added the module; thanks.

>  . libguile/socket.c -- Lacks implementation of `times' for
> MS-Windows, without which guile.exe aborts
> during startup.  Should use the gnulib times
> module.

Added; thanks.

I'll deal with the patches in a separate mail.

Cheers,

Andy
-- 
http://wingolog.org/





bug#13741: guile-2.0: optimize, and eq-ness of literals (test-suite)

2013-02-18 Thread Mark H Weaver
l...@gnu.org (Ludovic Courtès) writes:
> However, it’s fundamentally wrong to rely on eq? to compare numbers.  So
> the test case you mention seems buggy, to start with.

Agreed.  I removed the buggy test.

Thanks,
  Mark





bug#13741: [PATCH] test-suite: eq-ness of numbers, characters is unspecified

2013-02-18 Thread Daniel Hartwig
* test-suite/tests/00-socket.test:
* test-suite/tests/alist.test:
* test-suite/tests/elisp.test:
* test-suite/tests/encoding-iso88591.test:
* test-suite/tests/encoding-iso88597.test:
* test-suite/tests/encoding-utf8.test:
* test-suite/tests/hash.test:
* test-suite/tests/i18n.test:
* test-suite/tests/modules.test:
* test-suite/tests/ports.test:
* test-suite/tests/srfi-35.test: Make tests use eqv? instead of eq? when
  comparing numbers, characters.  Checked also for similar uses of
  assq[-ref].

* test-suite/tests/vlist.test ("vhash-delete honors HASH"): Change test
  to use eqv-ness, not eq-ness, which should not impact its purpose as
  these two are equivalent for strings.
---
 test-suite/tests/00-socket.test |6 +++---
 test-suite/tests/alist.test |4 ++--
 test-suite/tests/elisp.test |8 
 test-suite/tests/encoding-iso88591.test |   10 +-
 test-suite/tests/encoding-iso88597.test |   10 +-
 test-suite/tests/encoding-utf8.test |   10 +-
 test-suite/tests/hash.test  |6 +-
 test-suite/tests/i18n.test  |   20 ++--
 test-suite/tests/modules.test   |2 +-
 test-suite/tests/ports.test |8 
 test-suite/tests/srfi-35.test   |   16 
 test-suite/tests/vlist.test |8 
 12 files changed, 52 insertions(+), 56 deletions(-)

diff --git a/test-suite/tests/00-socket.test b/test-suite/tests/00-socket.test
index 6deb285..8079cf5 100644
--- a/test-suite/tests/00-socket.test
+++ b/test-suite/tests/00-socket.test
@@ -336,7 +336,7 @@
  (if (not server-pid)
  (throw 'unresolved)
  (let ((status (cdr (waitpid server-pid
-   (eq? 0 (status:exit-val status)
+   (eqv? 0 (status:exit-val status)
 
(false-if-exception (delete-file path))
 
@@ -409,7 +409,7 @@
   (if (not server-pid)
   (throw 'unresolved)
   (let ((status (cdr (waitpid server-pid
-(eq? 0 (status:exit-val status)
+(eqv? 0 (status:exit-val status)
 
 (false-if-exception (delete-file path))
 
@@ -505,7 +505,7 @@
  (if (not server-pid)
  (throw 'unresolved)
  (let ((status (cdr (waitpid server-pid
-   (eq? 0 (status:exit-val status)
+   (eqv? 0 (status:exit-val status)
 
#t)))
 
diff --git a/test-suite/tests/alist.test b/test-suite/tests/alist.test
index 699c10e..0ed5d22 100644
--- a/test-suite/tests/alist.test
+++ b/test-suite/tests/alist.test
@@ -124,8 +124,8 @@
   (pass-if "assoc-ref"
   (let ((x (assoc-ref b "one")))
 (and (list? x)
- (eq? (car x) 2)
- (eq? (cadr x) 3
+ (eqv? (car x) 2)
+ (eqv? (cadr x) 3
 
 
   (pass-if-not "assoc-ref not" (assoc-ref a 'testing))
diff --git a/test-suite/tests/elisp.test b/test-suite/tests/elisp.test
index 41800fd..baf8546 100644
--- a/test-suite/tests/elisp.test
+++ b/test-suite/tests/elisp.test
@@ -124,8 +124,8 @@
 (with-fluids* (cons f (cons g #nil))
   '(3 4)
   (lambda ()
-(and (eq? (fluid-ref f) 3)
- (eq? (fluid-ref g) 4))
+(and (eqv? (fluid-ref f) 3)
+ (eqv? (fluid-ref g) 4))
 
 (pass-if "append!"
   (let ((a (copy-tree '(1 2 3)))
@@ -150,11 +150,11 @@
   '(5 4 3 2 1))); Ditto.
 
 (pass-if "list-ref"
-  (eq? (list-ref '(0 1 2 3 4 . #nil) 4) 4))
+  (eqv? (list-ref '(0 1 2 3 4 . #nil) 4) 4))
 
 (pass-if-exception "list-ref"
exception:out-of-range
-   (eq? (list-ref '(0 1 2 3 4 . #nil) 6) 6))
+   (eqv? (list-ref '(0 1 2 3 4 . #nil) 6) 6))
 
 (pass-if "list-set!"
   (let ((l (copy-tree '(0 1 2 3 4 . #nil
diff --git a/test-suite/tests/encoding-iso88591.test 
b/test-suite/tests/encoding-iso88591.test
index f7bec5e..8265ff1 100644
--- a/test-suite/tests/encoding-iso88591.test
+++ b/test-suite/tests/encoding-iso88591.test
@@ -106,16 +106,16 @@
 (with-test-prefix "string length"
 
   (pass-if "�ltima"
-  (eq? (string-length s1) 6))
+  (eqv? (string-length s1) 6))
 
   (pass-if "c�dula"
-  (eq? (string-length s2) 6))
+  (eqv? (string-length s2) 6))
 
   (pass-if "a�os"
-  (eq? (string-length s3) 4))
+  (eqv? (string-length s3) 4))
 
   (pass-if "�C�mo?"
-  (eq? (string-length s4) 6)))
+  (eqv? (string-length s4) 6)))
 
 (with-test-prefix "internal encoding"
 
@@ -168,7 +168,7 @@
   (pass-if "1"
   (let ((� 1)
 (� 2))
-(eq? (+ � �) 3
+(eqv? (+ � �) 3
 
 (with-test-prefix "output errors"
 
diff --git a/test-suite/t

bug#13741: guile-2.0: optimize, and eq-ness of literals (test-suite)

2013-02-18 Thread Daniel Hartwig
On 18 February 2013 17:16, Ludovic Courtès  wrote:
> Daniel Hartwig  skribis:
>
>>   scheme@(guile-user)> (define x 1/2)
>>   scheme@(guile-user)> (eq? x 2/4)
>>   $7 = #f
>>   scheme@(guile-user)> ,optimize (eq? x 2/4)
>>   $8 = (eq? x 1/2)
>>   scheme@(guile-user)> (define y 2/4)
>>   scheme@(guile-user)> (eq? x y)
>>   $9 = #f
>>   scheme@(guile-user)> ,optimize (define y 2/4)
>>   $10 = (define y 1/2)
>
> Quoth R5RS:
>
>  `Eq?''s behavior on numbers and characters is
>  implementation-dependent, but it will always return either true or
>  false, and will return true only when `eqv?' would also return
>  true.  `Eq?' may also behave differently from `eqv?' on empty
>  vectors and empty strings.
>
> What we may get wrong is that it looks as if it doesn’t always return
> either true or false, because the behavior depends on whether one of the
> operands is a literal.

I took that to mean only that eq? always returns a boolean, rather
than requiring it to return the same boolean given the same numeric
arguments.  It would be fine to simplify some rationals and not
others, as this action does not affect the outcome of eqv?.

> However, it’s fundamentally wrong to rely on eq? to compare numbers.  So
> the test case you mention seems buggy, to start with.
>
> WDYT?
>
> Ludo’.

Right, the test cases involving eq-ness of numbers are broken, should
be removed.  Patch to follow.





bug#13741: [PATCH] test-suite: eq-ness of numbers, characters is unspecified

2013-02-18 Thread Daniel Hartwig
On 19 February 2013 09:55, Daniel Hartwig  wrote:
> * test-suite/tests/00-socket.test:
> * test-suite/tests/alist.test:
> * test-suite/tests/elisp.test:
> * test-suite/tests/encoding-iso88591.test:
> * test-suite/tests/encoding-iso88597.test:
> * test-suite/tests/encoding-utf8.test:
> * test-suite/tests/hash.test:
> * test-suite/tests/i18n.test:
> * test-suite/tests/modules.test:
> * test-suite/tests/ports.test:
> * test-suite/tests/srfi-35.test: Make tests use eqv? instead of eq? when
>   comparing numbers, characters.  Checked also for similar uses of
>   assq[-ref].
>
> * test-suite/tests/vlist.test ("vhash-delete honors HASH"): Change test
>   to use eqv-ness, not eq-ness, which should not impact its purpose as
>   these two are equivalent for strings.

Located using grep and inspecting each occurance of eq?, assq, consq.
The tests weren't necessarily failing, just incorrect for their
reliance on unspecified results.  Most checks involving numbers were
already using eqv?, equal?, or =.

The following were spotted but have been left alone for now:

* list.test (diff-unrolled): Uses eq? internally, called on lists
  with numbers.

* tree-il.test:

* elisp.test ("assq"): Is that correct for Guile's elisp?  _(elisp)
  Comparison of Numbers_ says that each integer does have a unique
  object in Emacs Lisp, and using ‘eq’ is valid though not
  recommended.

Regards





bug#13741: [PATCH] test-suite: eq-ness of numbers, characters is unspecified

2013-02-18 Thread Mark H Weaver
Daniel Hartwig  writes:
> * test-suite/tests/00-socket.test:
> * test-suite/tests/alist.test:
> * test-suite/tests/elisp.test:
> * test-suite/tests/encoding-iso88591.test:
> * test-suite/tests/encoding-iso88597.test:
> * test-suite/tests/encoding-utf8.test:
> * test-suite/tests/hash.test:
> * test-suite/tests/i18n.test:
> * test-suite/tests/modules.test:
> * test-suite/tests/ports.test:
> * test-suite/tests/srfi-35.test: Make tests use eqv? instead of eq? when
>   comparing numbers, characters.  Checked also for similar uses of
>   assq[-ref].
>
> * test-suite/tests/vlist.test ("vhash-delete honors HASH"): Change test
>   to use eqv-ness, not eq-ness, which should not impact its purpose as
>   these two are equivalent for strings.

I think we should apply this patch.  Although we can currently rely on
'eq?' working properly for fixnums and characters in Guile, misuse of
'eq?' is widespread, and our misuse of it in our own code contributes to
the confusion.  IMO we should set a better example.

What do other people think?

  Mark





bug#10474: Building guile 2.x under mingw + msys

2013-02-18 Thread Eli Zaretskii
> From: Andy Wingo 
> Cc: l...@gnu.org,  10...@debbugs.gnu.org,  commander.si...@googlemail.com
> Date: Mon, 18 Feb 2013 19:10:41 +0100
> 
> I'm terribly sorry for the delay here.  I realize you've probably paged
> out all of these patches from memory, but I would like to pick up the
> loose ends.

Thanks.

> On Thu 02 Feb 2012 18:34, Eli Zaretskii  writes:
> 
> >  . lib/canonicalize-lgpl.c -- does not support Windows absolute file
> >   names.  Will be fixed in gnulib.
> 
> I see you got this into gnulib in November
> (http://lists.gnu.org/archive/html/bug-gnulib/2012-11/msg00090.html).
> I just updated our Gnulib so we have it now.  Thanks!
> 
> >  . libguile/dynl.c -- lacks setenv.  Gnulib's setenv should be used.
> 
> This change was made in Guile on 25 January 2012.
> 
> >  . libguile/expand.c -- Defines CONST and VOID.  Should define
> > SCM_CONST and SCM_VOID (or some other, less
> > ubiquitous, symbols) instead.
> 
> Fixed in Guile on July 6 2012.
> 
> >  . libguile/fports.c -- Doesn't implement fport_input_waiting when
> > neither poll nor select nor FIONREAD are
> > available, without which interactive guile
> > won't start.  Should use the gnulib select
> > module.
> 
> Just added the module; thanks.
> 
> >  . libguile/socket.c -- Lacks implementation of `times' for
> > MS-Windows, without which guile.exe aborts
> > during startup.  Should use the gnulib times
> > module.
> 
> Added; thanks.

Thanks again.  Glad Guile is now more friendly to MinGW.