[GSoC] Parameter protocols in CL
Charles Turner
chturne@gmail.com
Sat Jul 21 20:41:00 GMT 2012
On 19 July 2012 23:56, Per Bothner <per@bothner.com> wrote:
> So what you need to do is add a method to LispPackage like:
>
> public static LispPackage(String uri, SimpleSymbol prefix) { ... }
>
> or better, override writeExternal:
>
> public void writeExternal(ObjectOutput out) throws IOException
> {
> out.writeObject(getName());
> out.writeObject(prefix);
> }
>
> and then implement:
>
> public static LispPackage(String name) { ... }
>
> where the ... should be the equivalent of find-package-or-error.
I assume you mean public static LispPackage {make,valueOf}. I've tried
both approaches, as well as a constructor approach. All with the
writeExternal() method as you sent. I still get the Literals error
though. I'm setting my *package* variable up like this now:
LispPackage:
public static ThreadLocation<LispPackage> currentPackage
= new ThreadLocation<LispPackage>("package");
static { currentPackage.setGlobal(CLNamespace); }
CommonLisp:
defAliasStFld("*package*", "gnu.kawa.lispexpr.LispPackage",
"currentPackage");
I tried the LList approach of just empty constructor & writeExternal
method. This worked in that the Literals error went away, so I must be
misunderstanding something else. I tried
public LispPackage(String name) { // do nothing for now }
public void writeExternal(ObjectOutput out) throws IOException
{
out.writeObject(getName());
out.writeObject(prefix);
}
As I think you suggested, but that still have the error, as well as
what I thought was the correct method:
public LispPackage(String name, SimpleSymbol prefix) { // do nothing for now }
writeExternal as before.
I do have to declare an empty constructor in addition to the ones
above, because I use it in other places initializing a new package,
new LispPackage();
And in fact, I implemented a valueOf method in LispPackage some time
ago, which hasn't seemed to solve the problem either:
public static LispPackage valueOf (String name)
{
if (name == null)
name = "";
synchronized (nsTable)
{
Namespace ns = (Namespace) nsTable.get(name);
if (ns != null)
return (LispPackage) ns;
ns = new LispPackage ();
ns.setName(name.intern());
Namespace.nsTable.put(name, ns);
return (LispPackage) ns;
}
}
> Now there is still a mystery to me why you sometimes get this error
> and sometimes not.
Oh no, it's reproducible. I always get it after a recompilation of the
source file containing (setq *package* package). Not for the first
compilation, which if I've absored any of the discussion from the
internals page, is understandable.
Thanks,
Charles.
More information about the Kawa
mailing list