[armedbear-devel] TYPE-ERROR #<java.lang.String foo {BADEAFFE}> cannot be coerced to a string.
Alessio Stalla
alessiostalla at gmail.com
Wed Jun 16 18:47:11 UTC 2010
On Tue, Jun 15, 2010 at 4:49 PM, Mario Lang <mlang at delysid.org> wrote:
> Erik Huelsmann <ehuels at gmail.com> writes:
>
>> On Tue, Jun 15, 2010 at 8:47 AM, Ville Voutilainen
>> <ville.voutilainen at gmail.com> wrote:
>>> On 15 June 2010 00:26, Alessio Stalla <alessiostalla at gmail.com> wrote:
>>>>> If there is consensus, I can prepare an update patch if need be (its
>>>>> simple enough anyways).
>>>> +1 :)
>>>
>>> +1 as well.
>>
>> Completely fine by me. So, it looks like we are completely in agreement :-)
>
> OK, here is a new patch that implements the suggested behaviour:
>
> Index: src/org/armedbear/lisp/JavaObject.java
> ===================================================================
> --- src/org/armedbear/lisp/JavaObject.java (revision 12752)
> +++ src/org/armedbear/lisp/JavaObject.java (working copy)
> @@ -108,6 +108,12 @@
> return super.typep(type);
> }
>
> + @Override
> + public LispObject STRING()
> + {
> + return new SimpleString(obj != null? obj.toString(): "null");
> + }
> +
> public final Object getObject()
> {
> return obj;
>
>
>
> Alternatively, here is a version that still emits a type error if
> the wrapped object is null. I am really not sure whats better,
> so I offer both versions.
>
> Index: src/org/armedbear/lisp/JavaObject.java
> ===================================================================
> --- src/org/armedbear/lisp/JavaObject.java (revision 12752)
> +++ src/org/armedbear/lisp/JavaObject.java (working copy)
> @@ -108,6 +108,14 @@
> return super.typep(type);
> }
>
> + @Override
> + public LispObject STRING()
> + {
> + if (obj != null)
> + return new SimpleString(obj.toString());
> + return super.STRING();
> + }
> +
> public final Object getObject()
> {
> return obj;
>
>
> Please apply what you like the most.
I applied and committed the first one, on the basis that Java does the
same conversion when using the + operator.
Thanks,
Alessio
More information about the armedbear-devel
mailing list