[antlr-interest] new Tree interfaces
Sam Barnett-Cormack
s.barnett-cormack at lancaster.ac.uk
Mon Sep 5 09:19:53 PDT 2011
On 05/09/2011 17:02, Terence Parr wrote:
> Yeah,First-time cleaning everything up and then slowly thinking about
> how generics get integrated. Is truly astounding just how wide the
> fanout is when you add a generic type. it ripples through all the
> classes. ugh. From the users point of view, however, it should look
> clean.
WHen used sensibly, generics are absolutely wonderful. Many's the
occasion I've used an API that would clearly benefit from genericisation
from the programmer's point of view.
So I guess what I'm saying is, don't hide the generics from the
user-coder unless there's a good reason to. We can always specify things
as ? or Object if we really need to, but if there's no generics we can't
avoid annoying casts. A genericised Tree interface would be a very
sensible way to go, and it could even generate code that has no ? left
in, but rather has specified generics. This will mean code using the
generated code has well-defined return types while still being able to
leverage common runtime code for management. I'm babbling, really, and
this probably isn't telling anyone anything they haven't thought of, but
on the off-chance that it is, I'm hitting 'send' rather than 'delete'...
Sam
> Ter On Sep 4, 2011, at 11:47 PM, Bart Kiers wrote:
>
>> Hi Ter, others,
>>
>> Perhaps generics could be introduced in v4?
>>
>> public interface Tree<T> { Tree<T> getParent(); T getPayload();
>> Tree<T> getChild(int i); int getChildCount(); String
>> toStringTree(); } Regards, Bart
>>
>>
>> On Sun, Sep 4, 2011 at 11:47 PM, Terence Parr<parrt at cs.usfca.edu>
>> wrote: btw,If you want to take a look at the clean new tree
>> interface:
>>
>> http://www.antlr.org/depot/antlr4/main/runtime/Java/src/org/antlr/v4/runtime/tree/Tree.java
>>
>>
>>
then sub interfaces
>>
>> http://www.antlr.org/depot/antlr4/main/runtime/Java/src/org/antlr/v4/runtime/tree/SyntaxTree.java
>>
>>
http://www.antlr.org/depot/antlr4/main/runtime/Java/src/org/antlr/v4/runtime/tree/ParseTree.java
>> http://www.antlr.org/depot/antlr4/main/runtime/Java/src/org/antlr/v4/runtime/tree/AST.java
>>
>>
>>
...
>>
>> Ter
>>
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>
>>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list