Improve #'string of sequence of characters error message

Bug #1314767 reported by Orivej Desh on 2014-04-30
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Medium
Unassigned

Bug Description

Currently (string '(#\a #\b #\c)) reports that it "cannot be coerced to a string", which is not entirely true because (coerce '(#\a #\b #\c) 'string) is allowed.

For the record, CCL reports that "The value (#\a #\b #\c) is not of the expected type (or string symbol character)."

Paul Khuong (pvk) on 2014-06-12
Changed in sbcl:
status: New → Confirmed
importance: Undecided → Medium
tags: added: easy runtime
Tomas Hlavaty (tomas-hlavaty) wrote :

This seems to be allowed, so is there any reason why would the attached patch be a bad idea and being strict like ccl would be prefferable?

http://www.lispworks.com/documentation/HyperSpec/Body/f_string.htm

* string might perform additional, implementation-defined conversions.

Tomas Hlavaty <email address hidden> writes:

> This seems to be allowed, so is there any reason why would the attached
> patch be a bad idea and being strict like ccl would be prefferable?

SBCL is (as a rule-of-thumb) conservative about what it accepts: a
rationale for that is that it is handy to have some kind of assurance
that code which "looks" portable and works under SBCL stands a
reasonable chance of working under other CL implementations. One
problem with extending (string x) to have implementation-defined
meanings (quite apart from the burden of documenting the
implementation-defined meaning, as we'd be required to) is that it is
not immediately obvious to someone writing code that (string x) isn't
portable CL, when X is an arbitrary sequence.

If there were no other convenient and defined way to express conversion
of a sequence of characters to a string, then probably we might consider
the extension anyway, despite those concerns. But since (coerce x
'string) exists, I think it's probably better to have STRING retain only
its mandated behaviour.

Stas Boukarev (stassats) wrote :

In 28f9ea1504afea799e55d56d804d5803006add63.

Changed in sbcl:
status: Confirmed → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers