groovy

.. as a new binary operator

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: None
  • Fix Version/s: 1.1-beta-2
  • Component/s: lexer
  • Labels:
    None
  • Number of attachments :
    0

Description

Rather than having a special RangeExpression 0..5 we could just make .. an operator.

Then the .. operator on numbers could create a range and we can use this operator to do a 'traverse' on other objects. E.g. we can use .. to be like // in XPath.

e.g.

node = builder.foo() {
bar() { x("a") x("b") }
}
node..x

would yield [ x("a"), x("b") ]

We could also use .. to invoke methods on collections of objects too.

node..x..name() would yield ["a", "b"]

Issue Links

Activity

Hide
james strachan added a comment -

Hmm, I'm not so sure about this now.

Show
james strachan added a comment - Hmm, I'm not so sure about this now.
Hide
Jörg Gottschling added a comment -

Seems as if this is implemented in the new ECMAScript4XML (E4X). I thing it would be nice to have this here.

Show
Jörg Gottschling added a comment - Seems as if this is implemented in the new ECMAScript4XML (E4X). I thing it would be nice to have this here.
Hide
John Wilson added a comment -

GPath expressions use '.' for this functionality now. So node.x yields [x("a"), x("b")]

Show
John Wilson added a comment - GPath expressions use '.' for this functionality now. So node.x yields [x("a"), x("b")]
Hide
Paul King added a comment -

Syntax not required as GPath handles this use case.

Show
Paul King added a comment - Syntax not required as GPath handles this use case.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: