POV-Ray : Newsgroups : povray.off-topic : Java : Re: Java Server Time
29 Jul 2024 18:29:37 EDT (-0400)
  Re: Java  
From: nemesis
Date: 18 Nov 2011 10:55:29
Message: <4ec67ff1$1@news.povray.org>
Darren New escreveu:
> On 11/17/2011 1:26, Invisible wrote:
>> On 24/09/2011 04:37 PM, Darren New wrote:
>>
>>> What would be in C#
>>>
>>> var z = from y select z where z.id = myID
>>>
>>> in java becomes
>>>
>>> List<OrganizationIndividualRelationshipEntity> z =
>>> Lists.ImmutableCopyOf(
>>> Lists.filter(y, new
>>> Predicate<List<OrganizationIndividualRelationshipEntity>() {
>>> @override boolean apply(OrganizationIndividualRelationshipEntity x) {
>>> return x.id = myID;
>>> }
>>> }
>>> )
>>> }
>>>
>>> I've lost track of closing braces....
>>> )
>>
>> Haskell has crazy type signatures too.
>>
>> Haskell also has mechanisms for defining shortcuts. :-P
> 
> You don't understand. Those *are* the shortcuts in Java.
> No, I am not exaggerating.  For example, "Lists" is nothing but a static 
> class full of static routines that are shortcuts for actually shortcuts 
> for the more full-bodied declarations including all the generic types.

problem is that you're trying to make java look worse than it is (and I 
agree it is bad) by programming it in a functional style it simply is 
not meant to.  Java is all about imperative programming at its worse, 
but at least it makes some sense when programmed that way.

I'm not quite natural to java, but I guess the correct way to program:

var z = from y select z where z.id = myID

in it would be something like:

List<OrganizationIndividualRelationshipEntity> y, z;
for (OrganizationIndividualRelationshipEntity x : y)
   if (x.id = myID) z.add(x);

that doesn't look half as bad as trying to program C in Object-Oriented 
fashion.  Still, not as fun as without type declarations.  I suppose if 
the code snippet was inside some generics method you could call 
"OrganizationIndividualRelationshipEntity" "T" and have:

List<T> y, z;
for (T x : y)
   if (x.id = myID) z.add(x);


Post a reply to this message

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