[
https://issues.apache.org/jira/browse/GROOVY-7432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15060305#comment-15060305
]
Peter Ledbrook commented on GROOVY-7432:
----------------------------------------
I had another look at this yesterday with a couple of folks during the GGX hack
session and from the conversations we had, and the things we learned about the
Groovy API, I'm considering retreating from this improvement request.
One significant issue for me is that {{CharSequence}} and {{String}} are not
treated the same by the {{iterator()}} method. A string is treated as a
sequence of single-character strings whereas {{CharSequence}} is treated as a
single object collection (the default behaviour for unknown types). I'd love to
change that, but it would be a pretty significant breaking change I would have
thought.
I looked at the {{CharSequence}} and {{String}} extension methods again and it
seems that the only real 'sequence' methods are the recent {{take()}} and
{{drop()}} variants. This is partly a problem with Java treating
{{CharSequence}}s and {{List}}s differently, but I now think we shouldn't try
to munge these concepts. The API just isn't conducive to it. In hindsight, I
think the addition of {{take()}} and {{drop()}} may have been a mistake.
So my current position is that {{CharSequence}}s should be converted to
{{List}}s or {{Stream}}s if a developer wants to treat them as such. What do
folks think?
> Enhance CharSequence with appropriate Iterable extension methods
> ----------------------------------------------------------------
>
> Key: GROOVY-7432
> URL: https://issues.apache.org/jira/browse/GROOVY-7432
> Project: Groovy
> Issue Type: Improvement
> Components: groovy-jdk
> Reporter: Peter Ledbrook
>
> Groovy enables developers to treat {{CharSequence}}s as if they were true
> sequences. For example, you can use a for loop and the array index operator.
> Some extension methods are missing though. One I was hoping to find was the
> {{count(Closure)}} method. I think it makes sense to incorporate any
> {{Iterable}} extension methods into {{CharSequence}} as well.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)