[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Strange string-append and string-match behaviour
From: |
Francis Southern |
Subject: |
Strange string-append and string-match behaviour |
Date: |
Thu, 17 Feb 2011 22:11:29 -0600 |
Hello Guilers,
I'm not 100% sure whether this is a bug or not, and it might not even
be legal Scheme code! But it seemed a bit odd to me so I'm reporting
it here.
(I'm currently using 1.9.15, but I believe this to be reproducible on 2.0.)
I was trying to match strings that started with a question mark, what
I wanted was actually `(string-match "\\?.*" "?wibble")', but the
problem is that when I was trying out a few different regexes I got
some odd results.
scheme@(guile-user)> (string-match "?.*" "?wobble")
ERROR: In procedure make-regexp:
ERROR: In procedure make-regexp: Error while printing exception.
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
This may not be a problem at all, but the error message seemed
strange. But worse is yet to come!
scheme@(guile-user)> (string-match "\?.*" "?wobble")
While reading expression:
ERROR: In procedure scm_lreadr: standard input:3:18: illegal character
in escape sequence: #\?
;;; <unknown-location>: warning: possibly unbound variable `.*'
ERROR: In procedure #<procedure 2183020 ()>:
ERROR: In procedure module-lookup: Unbound variable: .*
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
$1 = " "
;;; <unknown-location>: warning: possibly unbound variable `?wobble'
ERROR: In procedure #<procedure 21ac020 ()>:
ERROR: In procedure module-lookup: Unbound variable: ?wobble
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
And then it just hung and I needed to C-c C-c my way out.
While talking to cky in #guile, he pointed out that the problem is
actually with string-append and gave me two examples:
(string-append "\?") which shows the basic error message, and
(string-append "\?" "foo") which shows that after the error Guile
tries to read "foo" as a symbol rather than a string.
I am willing to admit the possibility that these examples are
`malformed' and maybe it's too much to ask to have something graceful
happen here, but I thought I should bring it to your attention and see
what you thought.
Thanks for your time and thanks for Guile!
Francis
- Strange string-append and string-match behaviour,
Francis Southern <=