Open GoogleCodeExporter opened 9 years ago
Original comment by kandpwel...@gmail.com
on 15 Jun 2012 at 3:48
I'm not sure I see the usefulness in this. You may have to flesh this one out
some more before I consider it: I would want usefulness, and sample API on what
it would look like, and whether this is truly something that would get used a
lot by FJ users, or is it rather just something that might get used once in a
blue moon.
I will be honest that I am not actually an FJ user, and so I don't understand
how the higher-arity F's (F2, F3) get used in practice, and why in the world
you would use one for a specific constructor of a specific type with specific
arg types when you could just use the constructor itself... maybe when several
classes in a hierarchy have the same constructor signature? I am sure I have
just not been initiated into the mysteries of the much more advanced FJ library
:-) Please enlighten me.
Original comment by kandpwel...@gmail.com
on 18 Jun 2012 at 10:59
A constructor is a function from its arguments to the constructed type. Let's
assume, that I can easily use a constructor instead of that constructing
function, then by extension, I can as well easily use methods instead of their
wrapped functions, so Funcito is not useful as a result. But since it is
useful, there should be something useful about wrapped ctors :).
Attached is a Main.java (add fj 3.0 as dependency), highlighting 3 different
use-cases of FNs (here F2, for simplicity). These are not exclusively useful
for constructors, but I find the outlined pattern (Validation especially)
common (YMMV).
If interested in these patterns more generally, you may find more info about
Monads and Applicative functors (here, Option was used as a Monad, and
Validation as an Applicative). My main sources were learnyouahaskell and
realworldhaskell (both free online) and scalaz.
Original comment by palotai....@gmail.com
on 19 Jun 2012 at 1:32
Attachments:
Interesting. Thanks, I will consider.
Original comment by kandpwel...@gmail.com
on 19 Jun 2012 at 2:56
This may also be linked to the same/similar challenge as I just added to Issue
33: there is no constructor polymorphism, so normal bytecode provider
(cglib/javassist) proxy factories cannot intercept constructor calls. Once
again, I might need to look at PowerMock code, or directly use Objenesis.
Original comment by kandpwel...@gmail.com
on 19 Jul 2012 at 8:34
Looking into Powermock led me into JMockit, which is using Java instrumentation
API. This would force the use of an agent, which can be automatic in Java 6+,
or force a command line option in Java 5, and also require some classpath
ordering.
I'm concerned that such a solution might affect runtime speed. Not sure if I
could limit the scope of *when* method interception happened. If not, this may
not be feasible. Same thing for wrapping static methods(see Issue 31).
Good news is, that if this is do-able, it may open up the door to wrapping
methods/chains that are final or final classes.
Original comment by kandpwel...@gmail.com
on 24 Aug 2012 at 3:52
Original issue reported on code.google.com by
palotai....@gmail.com
on 15 Jun 2012 at 12:42