[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Now this is a nightmare...
From: |
David Kastrup |
Subject: |
Re: Now this is a nightmare... |
Date: |
Wed, 04 Jul 2018 13:37:12 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
David Kastrup <address@hidden> writes:
> Werner LEMBERG <address@hidden> writes:
>
>>> We probably need some ly_is_integer instead that also checks for
>>> scm_exact_p or so? Guile-2.0 has scm_is_exact_integer but Guile-1
>>> apparently not.
>>
>> What about emulating `scm_is_exact_integer', either in Scheme or in
>> C++? This should make transition to Guile-2 simple.
>
> You mean, complex. Get it wrong, and our private version is getting
> linked and the Guile-2 version left out. Or we get double-definition
> link-time errors. So we want an autoconf test and so on.
>
> Having our own ly_is_integer variant map to the Guile-2 version
> conditionally is simple, and when we do it wrong, there is an obvious
> missing symbol at link time. Or stuff works without complaint.
It may be an upstream battle. Guile-1.8 does it the same:
address@hidden:~$ lilypond scheme-sandbox
GNU LilyPond 2.21.0
Processing `/usr/local/share/lilypond/2.21.0/ly/scheme-sandbox.ly'
Parsing...
guile> (define xxx '(1 2 3))
guile> (list-ref xxx 1.0)
ERROR: Wrong type (expecting exact integer): 1.0
ABORT: (wrong-type-arg)
guile> (list-ref xxx 1)
2
guile> (list-ref xxx 1.5)
standard input:4:1: In procedure list-ref in expression (list-ref xxx 1.5):
standard input:4:1: Wrong type (expecting exact integer): 1.5
ABORT: (wrong-type-arg)
Type "(backtrace)" to get more information or "(debug)" to enter the debugger.
guile>
Notice how the error message for 1.5 is much more specific than for 1.0?
Same reason.
Guile-2 is more consistent:
address@hidden:~$ guile
GNU Guile 2.0.13
Copyright (C) 1995-2016 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> (define xxx '(1 2 3))
scheme@(guile-user)> (list-ref xxx 1.0)
ERROR: In procedure list-ref:
ERROR: Wrong type (expecting exact integer): 1.0
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,q
scheme@(guile-user)> (list-ref xxx 1.5)
ERROR: In procedure list-ref:
ERROR: Wrong type (expecting exact integer): 1.5
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,q
scheme@(guile-user)>
It's probably more than less incentive not to let bad values get down
into the Scheme level...
--
David Kastrup