groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Laforge <glafo...@gmail.com>
Subject Re: [VOTE] Inner-project extension methods
Date Wed, 03 Jan 2018 06:44:30 GMT
Things like expliciting the scope: what's the scope of those extensions?
If it's on the classpath, it applies everywhere?
And with Java 9 modules, does it change something in terms of scope?

In the past we've talked about lexical extensions, in the sense that you
had to import those methods so that they could be applied to the local
source file.
Imagine something like import extension com.foo.StringExt.startsWithAny (a
bit like static import of methods)
We could also have an annotation on a per-method level that says that a
particular extension applies to just the scope of that method.
Should(n't) we consider something like this too?
Pros/cons of different approaches?

Still on scope, the categories, the extensions applies to any code that was
running inside the scope of the use {}:
anything that was called like foo() calls bar() calls baz() from other
classes not in the current class or script also had these extensions
applied.
Here, are we just speaking of the scope of the source file, and not what's
being called from there? (which I think I'd prefer anyway)

We can still discuss the syntax, but I'd be interested in seeing one.
Although you can start experimenting with an AST transformation.

On principle, I think I'm in favor of the idea, but as Paul said in another
thread, the devil is always in the details!

Guillaume


On Wed, Jan 3, 2018 at 3:04 AM, Nathan Harvey <nathanwharvey@gmail.com>
wrote:

> What do you guys think is missing from this proposal?
>
>
>
> --
> Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
>



-- 
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform

Blog: http://glaforge.appspot.com/
Social: @glaforge <http://twitter.com/glaforge> / Google+
<https://plus.google.com/u/0/114130972232398734985/posts>

Mime
View raw message