POV-Ray : Newsgroups : povray.off-topic : A question about Java generics (not a flame) : Re: A question about Java generics (not a flame) Server Time
7 Sep 2024 13:25:09 EDT (-0400)
  Re: A question about Java generics (not a flame)  
From: Warp
Date: 9 May 2008 13:41:09
Message: <48248cb5@news.povray.org>
Nicolas Alvarez <nic### [at] gmailcom> wrote:
> Warp wrote:
> >   Is there a way in Java to shorten those long type names?
> > 

> Not that I know of.

  I was thinking if it's not possible even through inheritance.
Something like (iirc Java syntax):

class TheMap extends Map<String, ArrayList<ArrayList<String>>>
{};

  Then just use TheMap? (Of course from a purely OO point of view this
could be seen as a misuse of inheritance, but...)

> In fact, it's even more annoying in that you have to
> type the whole type twice when creating an object.

  I will never understand why they decided to drop 'typedef' when they
designed Java in the first place. It's so handy in C++.

> It's interesting to note that in scripting languages, all that could be a
> one-liner. In Javascript:
> var theMap = {"foo": [["one", "two"], ["three", "four"]]};

  Yeah, but that's only possible in languages with weak typing (I think
that's the term?) In other words, in languages where you don't have to
specify types explicitly, as they are inferred from the values.

> And even more interesting to note that C++0x will allow an initializer
> syntax almost as short as that :)

  I also wonder if the new 'auto' feature in C++0x will help alleviating
this nuisance a bit. At least it will allow writing things like:

auto p = std::make_pair(value1, value2);

  You don't have to even care what is the type returned by std::make_pair
or the types of those values, which is cool.

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.