[armedbear-devel] Using named classes for primitives

Mark Evenson evenson at panix.com
Tue Oct 20 18:17:35 UTC 2009


On 10/19/09 5:48 PM, Erik Huelsmann wrote:
[…]
>> a bit more verbose, but worth the effort imho.
>
> I think so too. However, there are a few too many of these to start
> changing them over now. Or does anybody feel like hacking up a perl
> script to get it done? :-)
>

It would be better to have a tool that can grok the Abstract Syntax Tree 
for Java, transforming that.  [Jackpot][1] should be the kind of tool 
that would help with this sort of thing, but it seems a little neglected 
since 2007 so it won't easily run in a modern IDE.  Interestingly it has 
an "add overrides" example that would have helped out adding all the 
override statements.

[1]: http://jackpot.netbeans.org/
[2]: 
http://hg.netbeans.org/main/contrib/raw-file/tip/jackpot/src/org/netbeans/modules/jackpot/cmds/AddOverrides.java

There appear to be 768 instances that need transformation, so the task 
is indeed suitable to use some sort of automatic tool.

I'd give this a whack but I simply don't have extra time until the end 
of October due to work constraints.

I would make the following suggestions if someone else takes on this task:

1)  We should name the functions in all lowercase in analogy to the 
various "standalone" extensions of Primitive like 'open_stream_p.java', 
'make_array.java', etc.  This produces a more readable stack trace in my 
opinion.

2) Don't forget to retain the comments with the '###' string in them: 
they form the necessary linkage for SYSTEM::GROVEL-JAVA-DEFINITIONS

3) Use a no argument constructor in the primitive that calls the 
appropriate super with the arguments, e.g.

     // ### packagep
     // packagep object => generalized-boolean
     private static final Primitive PACKAGEP = new Primitive("packagep", 
"object")
     {
         @Override
         public LispObject execute(LispObject arg) throws ConditionThrowable
         {
             return arg instanceof Package ? T : NIL;
         }
     };

becomes

     // ### packagep
     // packagep object => generalized-boolean
     private static final Primitive PACKAGEP = new packagep();

     private static class packagep extends Primitive {
         packagep() {
            super("packagep", "object");
         }
         @Override
         public LispObject execute(LispObject arg) throws ConditionThrowable
         {
             return arg instanceof Package ? T : NIL;
         }
     };




-- 
"A screaming comes across the sky.  It has happened before, but there
is nothing to compare to it now."




More information about the armedbear-devel mailing list