Some idea on extending Pivot collections

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Some idea on extending Pivot collections

Sandro Martini
Hi all,

I'd like to ask to you a crazy idea I had in last weeks ... you
remember the question of last week on add some methods to Pivot
collections ?
It's here: http://apache-pivot-developers.417237.n3.nabble.com/No-quot-addAll-quot-method-on-ArrayList-td3281354.html

After thinking on it, and trying to expand the idea (and you know that
I'm a great fan of Scala) ... so what do you think (for the 2.1
release) to add some methods to pivot collections to be able to pass a
Function (a Pivot new class to map simple functions, all for Java ...
and the name is only a proposal) and have the collection to apply it
over all their elements ?
Do you think could be interesting/useful, at least for what it's your
experience on Pivot ?

If you have some time/are interested, try to take a look for example
at these articles, just to have some idea:
http://markusjais.com/a-little-functional-java-the-map-function/
http://www.ibm.com/developerworks/java/library/j-scala06278/index.html
http://functionaljava.org/examples/1.5/

And note that Java 8 will have something like this (but less powerful
to Scala, for what I have read ...), and JavaFX 2 will have something
already aligned with it ... so I'm curious to see what will happen
there :-) . But before it I'd like to hear from you what you think ...


On Scala integration I have prototyped something that converts between
Pivot and Scala collections using implicits, but I don't know it this
is enough in a long-term vision (and even from a performance point of
view, and on this I have to ask to some Scala expert), so the
following idea (ok, crazy) but for Pivot 3:
moder JVM language like Scala and Groovy have many types of
collections that are event-enabled (and for example in Scala it's
possible even to add methods to existing classes), so an idea could be
to change Pivot collections to align (for what it's possible) with
more robust/powerful collections (as method names etc), and retrofit
them with interfaces that we will use even to extend/wrap other
collections, and use factory classes to get instance of right
collection, depending on some conditions (technology used,
environment, etc).
And maybe useful even a singleton class the Pivot classes could use to
share settings etc in memory (for example factories, but maybe even
other things) ... this could be useful even in 2.1.
I know, it's a lot of work, but I think could be powerful ... what do
you think ?
You can say to me that I'm crazy, don't worry :-) ...
Note that of course I'm not saying here that Pivot collections aren't
good (without doubt Greg has made a huge/great work, you know I have
maximum respect for it), but only that things are evolving, so maybe
could be good even for us to start to align with new trends ...

To finish, I dropped the pivot-scala project, and the new
pivot-multilang is defined as structure but contains only few things
because hadn't time to migrate existing scala stuff in it ... it's the
first in my TODO list after the bug fixing stuff and the jenkins
builds ...


If you think it's an interesting idea I'll prototype ...
Thank you.

Bye,
Sandro
Reply | Threaded
Open this post in threaded view
|

Re: Some idea on extending Pivot collections

Bill van Melle
I've used these kinds of operations in C# for a long time, and they're
certainly useful.  C# benefits from using Scala's compact syntax (not to
mention real closures), but I think even in the more verbose Java syntax
your proposals could make a programmer's intentions clearer than the
traditional loop style.  I've been porting some C# code to Pivot recently
and wished I had a few of those mapping methods available to me. So I say go
for it.

--Bill

p.s. I really wish the Pivot List implemented a few more of the operations
that java.util.List implements.  You note *addAll*, which is often useful;
even more so I'd like *contains*, which I use often enough that I wrote my
own static utility method for it.

On Thu, Sep 8, 2011 at 4:21 PM, Sandro Martini <[hidden email]>wrote:

> Hi all,
>
> I'd like to ask to you a crazy idea I had in last weeks ... you
> remember the question of last week on add some methods to Pivot
> collections ?
> It's here:
> http://apache-pivot-developers.417237.n3.nabble.com/No-quot-addAll-quot-method-on-ArrayList-td3281354.html
>
> After thinking on it, and trying to expand the idea (and you know that
> I'm a great fan of Scala) ... so what do you think (for the 2.1
> release) to add some methods to pivot collections to be able to pass a
> Function (a Pivot new class to map simple functions, all for Java ...
> and the name is only a proposal) and have the collection to apply it
> over all their elements ?
> Do you think could be interesting/useful, at least for what it's your
> experience on Pivot ?
> ...
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Some idea on extending Pivot collections

Sandro Martini
Hi all,
just created the issue, for the 2.1 :
https://issues.apache.org/jira/browse/PIVOT-799

Bill (and others), if you have some comment/idea/code please post/attach there.

Thank you,
Sandro


2011/10/11 Bill van Melle <[hidden email]>:

> I've used these kinds of operations in C# for a long time, and they're
> certainly useful.  C# benefits from using Scala's compact syntax (not to
> mention real closures), but I think even in the more verbose Java syntax
> your proposals could make a programmer's intentions clearer than the
> traditional loop style.  I've been porting some C# code to Pivot recently
> and wished I had a few of those mapping methods available to me. So I say go
> for it.
>
> --Bill
>
> p.s. I really wish the Pivot List implemented a few more of the operations
> that java.util.List implements.  You note *addAll*, which is often useful;
> even more so I'd like *contains*, which I use often enough that I wrote my
> own static utility method for it.
>
> On Thu, Sep 8, 2011 at 4:21 PM, Sandro Martini <[hidden email]>wrote:
>
>> Hi all,
>>
>> I'd like to ask to you a crazy idea I had in last weeks ... you
>> remember the question of last week on add some methods to Pivot
>> collections ?
>> It's here:
>> http://apache-pivot-developers.417237.n3.nabble.com/No-quot-addAll-quot-method-on-ArrayList-td3281354.html
>>
>> After thinking on it, and trying to expand the idea (and you know that
>> I'm a great fan of Scala) ... so what do you think (for the 2.1
>> release) to add some methods to pivot collections to be able to pass a
>> Function (a Pivot new class to map simple functions, all for Java ...
>> and the name is only a proposal) and have the collection to apply it
>> over all their elements ?
>> Do you think could be interesting/useful, at least for what it's your
>> experience on Pivot ?
>> ...
>>
>>
>