

Fig: Java elegant supplement - ganqiongzi
http://wapatesh.github.io/fig/

======
bcg1
A convenient addition the library would be a Seq/Hash that delegates to a
"regular" List or Map without copying. I haven't had the time yet to look into
how default interface methods work in conjunction with dynamic proxies, but
may be able to easily "figify" a list that way

------
bshimmin
"Fig uses conventions on method names similar with Ruby. If there is a pair of
methods name, name$, method ends with $ means calling this method will change
the object itself, while calling the other won't."

This seems very un-Java - surely the Java way to achieve this would be method
overloading.

~~~
jdmichal
I do agree that this is very un-Java. However, how would method overloading
allow for the simple given example of shuffling a sequence?

    
    
        seq.shuffle(); // copy to a new seq and shuffle it
        seq.shuffle$(); // shuffle the original seq
    

These two methods should have the exact same signature. So using two different
names is necessary. I'm not particularly fond of introducing $ as a substitute
for !. That convention is not existent in Java, and is not at all obvious to
anyone who hasn't studied a functional language.

I would probably solve this by simply making shuffle always in place, and add
a copy constructor and/or copy method:

    
    
        // Copy and shuffle.
        (new Seq(seq)).shuffle();
        seq.copy().shuffle();
    
        // Shuffle in-place.
        seq.shuffle();

~~~
liuyang1204
Great opinion.

I do agree $ is very un-Java, either.

But I don't want "shuffle" to be in-place method by default. I agree with
@jdmichal that it should return new copy.

In this case how to design the in-place way is not obvious.

I'm the main author of fig. This project is started for just a week. All of
your suggestion are very supportive and I'm checking the feedback to make fig
better.

~~~
ramblerman
I would simply not have in place modifiers. Focus your programming efforts
instead on adding other cool high level constructs on lambdas.

See underscore or scala for inspiration.

