Tuples, Generics, and compiler bugs, oh my!

Tom Kaitchuck <[email protected]> Sat, 9 Jul 2005 22:28:10 -0700
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
I was attempting to create a useful toString() method for Tuples. So I started 
by writing the following:

String toString(( <T>t,<U> u))
{
  return "("+t.toString()+","+u.toString()+")";
}

But that did not work. Apparently generics within tuples don't work. The 
compiler told me:

Encountered "<".
Was expecting one of:
    "(" ...
    "?" ...
    "!" ...
    "alike" ...
    <IDENT> ...
    "unknown" ...
    ")" ...

But I did not know what "unknown" (maybe it was what I was looking for) so I 
replaced <T> and <U> with "unknown" and ran into a compiler error and was 
given a stack dump.

This brings up several questions/bugs/feature requests: 
Please locate the bug that caused the problem. What is "unknown" anyway? Why 
does "encountering a '<' not match a '<IDENT>'"? Can we make it possible to 
enable generics within tuples? 

And finally: Can we make some mechanism for using tuples as more general data 
type and write code that can deal with tuples of arbitrary length, or make it 
clear they are not to be used like this and set some limit on their maximum 
length. (Ether way people should be able to write functions that will work 
with all the tuples there are.) 
 


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP, 
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar