bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#17049: Further change ideas.


From: David Kastrup
Subject: bug#17049: Further change ideas.
Date: Sun, 30 Mar 2014 18:36:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

While it does not appear like this patch proposal is going anywhere for
some reason, there is a further opportunity for change.

One thing is to note that scm_srfi1_append_reverse_x does essentially
the same thing but has a different doc string, the second argument
non-optional and a different implementation that creates nonsense on
some arguments and hangs on others:

scheme@(guile-user)> (use-modules (srfi srfi-1))
scheme@(guile-user)> (append-reverse! (circular-list 1 2) '(3 4))
$2 = (4 3 1 2 . #-1#)
scheme@(guile-user)> (append-reverse! (circular-list 1) (circular-list 2))
[hangs uninterruptibly...]

It can also show somewhat inventive error messages:

scheme@(guile-user)> (append-reverse! '(1 2 3 . 4) 5)
ERROR: In procedure append-reverse!:
ERROR: In procedure append-reverse!: Wrong type argument in position 1 
(expecting list): 4

or even
scheme@(guile-user)> (append-reverse! (circular-list 1 2 3) 5)
ERROR: In procedure append-reverse!:
ERROR: In procedure append-reverse!: Wrong type argument in position 1 
(expecting list): 5


It is an obvious candidate to rerouting to reverse!.  However, there is
another difference apart from append-reverse! not really being all too
robust against errors:

scheme@(guile-user) [2]> (reverse! (circular-list 1 2 3) 5)
ERROR: In procedure reverse!:
ERROR: In procedure reverse!: Wrong type argument in position 1: (1 2 3 . #-2#)

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.

Note that with reverse! the "(expecting list)" in the error message is
absent because scm_wrong_type_arg instead of scm_wrong_type_arg_msg is
employed in scm_reverse_x (directly after the patch, indirectly through
SCM_VALIDATE_LIST before the patch).

So if one wants to have identical error behavior, it would likely make
sense to move to the somewhat more specific scm_wrong_type_arg_msg,
possibly even for the whole of SCM_VALIDATE_LIST.

Of course all this is water under the drawbridge if not even the
original patch is going anywhere.

-- 
David Kastrup





reply via email to

[Prev in Thread] Current Thread [Next in Thread]