[armedbear-devel] TYPE-ERROR #<java.lang.String foo {BADEAFFE}> cannot be coerced to a string.

Mario Lang mlang at delysid.org
Tue Jun 15 14:49:10 UTC 2010


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.

-- 
Thanks,
  ⡍⠁⠗⠊⠕ | Debian Developer <URL:http://debian.org/>
  .''`. | Get my public key via finger mlang/key at db.debian.org
 : :' : | 1024D/7FC1A0854909BCCDBE6C102DDFFC022A6B113E44
 `. `'
   `-      <URL:http://delysid.org/>  <URL:http://www.staff.tugraz.at/mlang/>




More information about the armedbear-devel mailing list