groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Winnebeck (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7957) Allow static compilation of builders that implement methodMissing / propertyMissing
Date Thu, 06 Oct 2016 15:51:20 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-7957?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15552299#comment-15552299
] 

Jason Winnebeck commented on GROOVY-7957:
-----------------------------------------

methodMissing/propertyMissing seems like it could apply to more situations than just the Builder
one. Perhaps if a marker interface is needed, it does not need to reference builder?

I like the idea that the standard methodMissing signature is expanded so it can match something
more specific than (name, args). But if the original class implemented the original signature
(String, Object), how does that interact with the more specific signature matching, or is
the original methodMissing signature (described at http://groovy-lang.org/metaprogramming.html#_methodmissing)
no longer allowed once the marker interface is implemented?

> Allow static compilation of builders that implement methodMissing / propertyMissing
> -----------------------------------------------------------------------------------
>
>                 Key: GROOVY-7957
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7957
>             Project: Groovy
>          Issue Type: New Feature
>          Components: GEP
>            Reporter: Graeme Rocher
>
> Similar to Scala's {{Dynamic}} http://www.scala-lang.org/api/current/index.html#scala.Dynamic
> We should be able to write builders that are usable from statically compiled code. To
achieve this I recommend the following:
> {code}
> // if the object implements methodMissing dispatch to it
> foo.bar("blah")      ~~> foo.methodMissing("bar", "blah")
> // if the object implements propertyMissing dispatch to it
> foo.var1           ~~> foo.propertyMissing("var1")
> // if the object implements propertyMissing dispatch to it
> foo.var1 = 10      ~~> foo.propertyMissing("var1", 10)
> {code}
> When combined with GROOVY-7956 it would then be possibly to fully implement builders
that are compatible with {{@CompileStatic}} and certain existing builders could be enhanced
to take advantage of this feature {{JsonBuilder}}, {{MarkupBuilder}} etc.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message