|
![](/i/fill.gif) |
Nicolas Alvarez <nic### [at] gmail com> 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
|
![](/i/fill.gif) |