Unsubscribe

2018-03-27 Thread OmniTrade
On Tue, Mar 20, 2018, 5:15 PM MG,  wrote:

> With regards to the Groovy 3.0 Release Notes
> (http://groovy-lang.org/releasenotes/groovy-3.0.html) "Nested code
> blocks" section:
> What about in addition supporting two reserved keywords, "block" and
> "eval", as follows:
>
> void foo() {
>block {
>  // Makes nested code block explicit (without it, the block could
> e.g. have a missing if or else construct before it)
>  // Avoids the need to use semicolon before nested code block to
> distinguish code block from a closure
>  // Otherwise no difference to Java nested code block
>}
>
>// equivalent to:
>if(true) { ... }
>
>
>final x = eval {
>   // Nested code block whose final evaluated statement is its return
> value
>}
>
>// semi-equivalent to:
> final x =  true ? (...;...;...) : null
> }
>
>
> The application for these constructs for me lie in cases where one needs
> to create a scope with a local variables, but where one would need to
> pass a large number of parameters to a helper method that coud be
> introduced, or one would really have to try hard to come up with a
> meaningful method name (implying that the functionality is too
> small/specialized to be moved into a seperate method).
>
> Thoughts ?
> mg
>
>
>
>


Unsubscribe

2018-03-27 Thread OmniTrade
On Sat, Mar 10, 2018, 9:50 AM MG,  wrote:

> Hi Groovy enthusiasts !-)
>
> after having thought about the topic of "putting some money where your
> mouth is and help fund Groovy development" some more, and taking into
> consideration what people have suggested, I have created a (somewhat
> experimental) Jira task* where people can pledge bounties for Groovy
> features/fixes they woud like to support:
>
> https://issues.apache.org/jira/browse/GROOVY-8503
>
> I have added bounties for some ares that I would like to see Groovy to
> grow in - feel free to suggest additional features/fixes, or pledge for
> existing ones.
>
> Please make sure beforehand there has been at least some sort of
> discussion about and some tentative agreement on possible ways forward
> for the topic you would like to advance on this mailing list. There is
> not much sense in cluttering the Jira task with pledges for features no
> one of the main contributors think are feasible, a good idea - or who
> have been outright rejected at this point :-)
>
> I think it is easiest for people to pledge in "their" currency (Euro in
> my case), so they do not incur any exchange rate uncertainties.
> I also feel the minimum amount pledged should be in the 10 USD/EUR area,
> based on that if we have a lot of people pledging smaller amounts, the
> Jira task is definitely not the right approach.
> All of this is of course open for discussion... :-)
>
> Regular (monthly) Groovy funding is a topic for another post - for now I
> have added a generic "Make Groovy Java 9 compatible" topic at the top of
> the funding table in https://issues.apache.org/jira/browse/GROOVY-8503.
>
> Cheers,
> mg
>
> *I think we should see if this appoach does not suffice, before going
> down the route of a
> Kickstarter/Indiegogo/
> tribe.taiga.io/bountysource.com/Patroon/fundrequest.io
> - thank you to anyone who suggested/commented on this topic :-)
>
>
>
>
>
>
>
>
>
>


Re: Advanced binding of methods by name in a template via the binding map

2017-02-14 Thread OmniTrade
Another user chimed in on SO and provided this answer that appears to work
in all test scenarios, even nested template scenarios:

String basic = "<%" +
" def mc1=testInstance." +
"println \"mc1 class ${mc1.getClass()}\";" +
"println \"mc1 metaclass ${mc1.getMetaClass()}\";" +
"println mc1.getClass();" +
"mc1();" +
"mc1('var1');" +
"mc1('var1', 'var2');" +
"testMethod();" +
"testMethod('var1');" +
" %>";

TemplateEngine engine = new GStringTemplateEngine();

TestMethodClass instance = new TestMethodClass();

// Prepare binding map
Map<String, Object> bindings = new HashMap<>();
bindings.put("testInstance", instance);

Template t = engine.createTemplate(basic);

Closure make = (Closure) t.make(bindings); // cast as closure

int resolveStrategy = make.getResolveStrategy();
make.setResolveStrategy(Closure.OWNER_FIRST);

// set method closure which you want to invoke directly (without .
// notation). This is more or less same what you pass via binding map
// but too verbose. You can encapsulate this inside a nice static
// method
InvokerHelper.setProperty(make.getOwner(), "testMethod", new
MethodClosure(instance, "test"));

make.setResolveStrategy(resolveStrategy);
String result = make.toString();


On Mon, Feb 13, 2017 at 3:14 AM, Alessio Stalla <alessiosta...@gmail.com>
wrote:

> I answered: http://stackoverflow.com/a/42202684/296025
> But that won't solve your problem, I'm afraid.
>
> On 13 February 2017 at 08:03, OmniTrade <omnitrad...@gmail.com> wrote:
>
>> Hi All,
>>
>> I won't bore you with the gritty details here since they are already well
>> described on StackOverflow.
>>
>> It seems that few people have the chops to tackle this question. It
>> sounds solvable and maybe some of the pros here can attempt it.
>>
>> http://stackoverflow.com/questions/41196600/how-do-i-bind-al
>> l-methods-of-a-certain-name-in-an-object-into-a-template-via-the
>>
>> Rumour has it that there is also a 500 point reward for the canonical
>> answer.
>>
>> Good Luck.
>>
>
>


Advanced binding of methods by name in a template via the binding map

2017-02-12 Thread OmniTrade
Hi All,

I won't bore you with the gritty details here since they are already well
described on StackOverflow.

It seems that few people have the chops to tackle this question. It sounds
solvable and maybe some of the pros here can attempt it.

http://stackoverflow.com/questions/41196600/how-do-i-
bind-all-methods-of-a-certain-name-in-an-object-into-a-template-via-the

Rumour has it that there is also a 500 point reward for the canonical
answer.

Good Luck.