I'm keen to add clearly-described examples for every little thing I have stumbled over including things like "return an argument after processing" or "wrap a call with try/finally". These simple patterns are going to be the most important ones.
Google id is [email protected]. I will add as much as i can. - Charlie (mobile) On Jun 11, 2011, at 5:18, Rémi Forax <[email protected]> wrote: > On 06/11/2011 02:18 AM, Charles Oliver Nutter wrote: >> John Rose to the rescue... by reversing the order of foldArguments, >> you can post-process the arguments *and* return value of the target. >> See the other thread for an example. >> >> SOLVED. Put it in the cookbook, Rémi! (or allow me to put it in the cookbook) >> >> - Charlie > > Send me a google id, I will allow you to have write access to the repository. > > In fact, this pattern is already hidden in the cookbook, take a look to the > memoize pattern > http://code.google.com/p/jsr292-cookbook/source/browse/trunk/memoize/src/jsr292/cookbook/memoize/RT.java > near line 31. > > Rémi > >> On Fri, Jun 10, 2011 at 6:25 PM, Charles Oliver Nutter >> <[email protected]> wrote: >>> On Fri, Jun 10, 2011 at 6:14 PM, Robert Fischer<[email protected]> >>> wrote: >>>> How is the assignment itself implemented in terms of MethodHandles? >>>> What do you have to work with? >>>> >>>> What I'm thinking is that you could implement the side-effect as part >>>> of a MethodHandles#filterArguments call (one that doesn't actually >>>> change the argument)? Just wrap that around a MethodHandles#identity >>>> call. Won't that do it for you? >>> filterArguments replaces the argument at the given offset with the >>> result of the filter handle. It doesn't allow you to alter the return >>> value of the target. filterReturn allows you to change the return >>> value, but does not have access to arguments. >>> >>>> If you have the assignment implementation, but it returns >>>> null/void/whatever, then use MethodHandles#foldArguments to insert a >>>> second copy in front, and have the assignment be the map to the right. >>>> I think that'll work. >>> foldArguments reinserts the results of passing all arguments to the >>> folding handle back into the parameter list, but does not do anything >>> to return value. >>> >>> So far I've not been able to come up with a way to alter the return >>> value using the argument values. It only seems possible to do that >>> with an intermediate Java call that wraps everything else, and I stil >>> believe that defeats inlining the rest of the chain. >>> >>> - Charlie >>> > > -- > You received this message because you are subscribed to the Google Groups > "JVM Languages" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/jvm-languages?hl=en. > -- You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en.
