[GitHub] groovy pull request #360: `ObjectRange` and `IntRange` iteration and steppin...

2016-07-15 Thread paulk-asert
Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/360#discussion_r71060369
  
--- Diff: src/main/groovy/lang/IntRange.java ---
@@ -385,26 +385,23 @@ public void step(int step, Closure closure) {
 return; // from == to and step == 0, nothing to do, so return
 }
 
-if (isReverse()) {
-step = -step;
+final long from = getFrom().longValue(), to = getTo().longValue();
+
+final boolean isAscending;
+if (step < 0) {
+step *= -1;
+isAscending = isReverse();
+} else {
+isAscending = !isReverse();
 }
-if (step > 0) {
-int value = getFrom();
-while (value <= getTo()) {
+
+if (isAscending) {
+for (long value = from; value <= to; value += step) {
 closure.call(value);
-if (((long) value + step) >= Integer.MAX_VALUE) {
-break;
-}
-value = value + step;
 }
 } else {
-int value = getTo();
-while (value >= getFrom()) {
+for (long value = to; value >= from; value -= step) {
--- End diff --

The issue with the long value being passed to the closure is that it breaks 
existing code, e.g.:
`(0..3).step(2){ int i -> println i * 2 }
`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Created] (GROOVY-7887) Typo s/now/know/ in core-domain-specific-languages

2016-07-15 Thread Mark Wei (JIRA)
Mark Wei created GROOVY-7887:


 Summary: Typo s/now/know/ in core-domain-specific-languages
 Key: GROOVY-7887
 URL: https://issues.apache.org/jira/browse/GROOVY-7887
 Project: Groovy
  Issue Type: Documentation
  Components: Documentation
Affects Versions: 2.4.7
 Environment: OSX Chrome
Reporter: Mark Wei
Priority: Trivial


http://docs.groovy-lang.org/latest/html/documentation/core-domain-specific-languages.html#TheDelegatesToannotation-Delegatetoparameter

Section 5.3.3 contains the phrase "And in this case, it will now that" which 
should be changed to "And in this case, it will know* that"



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


[GitHub] groovy pull request #:

2016-07-15 Thread paulk-asert
Github user paulk-asert commented on the pull request:


https://github.com/apache/groovy/commit/a903c9e330af224006380af0f56afa98c0cc6b64#commitcomment-18259964
  
In src/main/groovy/lang/ObjectRange.java:
In src/main/groovy/lang/ObjectRange.java on line 237:
You're right. Unfortunately japicmp didn't pick it up. I'll revert.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #:

2016-07-15 Thread melix
Github user melix commented on the pull request:


https://github.com/apache/groovy/commit/a903c9e330af224006380af0f56afa98c0cc6b64#commitcomment-18257989
  
In src/main/groovy/lang/ObjectRange.java:
In src/main/groovy/lang/ObjectRange.java on line 237:
This is a binary breaking change, I think we should avoid this or at least 
discuss on the MLs.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #366: GROOVY-7877: The Range abstraction could support n...

2016-07-15 Thread paulk-asert
Github user paulk-asert commented on a diff in the pull request:

https://github.com/apache/groovy/pull/366#discussion_r70927754
  
--- Diff: src/main/groovy/lang/NumberRange.java ---
@@ -0,0 +1,536 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package groovy.lang;
+
+import org.codehaus.groovy.runtime.InvokerHelper;
+import org.codehaus.groovy.runtime.IteratorClosureAdapter;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.AbstractList;
+import java.util.Iterator;
+import java.util.List;
+
+import static 
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareEqual;
+import static 
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareGreaterThan;
+import static 
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareGreaterThanEqual;
+import static 
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareLessThan;
+import static 
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareLessThanEqual;
+import static 
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareNotEqual;
+import static org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareTo;
+import static org.codehaus.groovy.runtime.dgmimpl.NumberNumberMinus.minus;
+import static org.codehaus.groovy.runtime.dgmimpl.NumberNumberPlus.plus;
+import static 
org.codehaus.groovy.runtime.dgmimpl.NumberNumberMultiply.multiply;
+
+/**
+ * Represents an inclusive list of Numbers from a value to a value with a 
particular step size.
+ */
+public class NumberRange extends AbstractList implements 
Range {
+
+/**
+ * The first value in the range.
+ */
+private final Comparable from;
+
+/**
+ * The last value in the range.
+ */
+private final Comparable to;
+
+/**
+ * The step size in the range.
+ */
+private final Number stepSize;
+
+/**
+ * The cached size, or -1 if not yet computed
+ */
+private int size = -1;
+
+/**
+ * true if the range counts backwards from 
to to from.
+ */
+private final boolean reverse;
+
+/**
+ * true if the range includes the upper bound.
+ */
+private final boolean inclusive;
+
+/**
+ * Creates an inclusive {@link NumberRange} with step size 1.
+ * Creates a reversed range if from  to.
+ *
+ * @param from the first value in the range
+ * @param to   the last value in the range
+ */
+public 
+NumberRange(T from, U to) {
+this(from, to, null, true);
+}
+
+/**
+ * Creates a new {@link NumberRange} with step size 1.
+ * Creates a reversed range if from  to.
+ *
+ * @param from start of the range
+ * @param to   end of the range
+ * @param inclusive whether the range is inclusive
+ */
+public 
+NumberRange(T from, U to, boolean inclusive) {
+this(from, to, null, inclusive);
+}
+
+/**
+ * Creates an inclusive {@link NumberRange}.
+ * Creates a reversed range if from  to.
+ *
+ * @param from start of the range
+ * @param to   end of the range
+ * @param stepSize the gap between discrete elements in the range
+ */
+public >
+NumberRange(T from, U to, V stepSize) {
+this(from, to, stepSize, true);
+}
+
+/**
+ * Creates a {@link NumberRange}.
+ * Creates a reversed range if from  to.
+ *
+ * @param from start of the range
+ * @param to   end of the range
+ * @param stepSize the gap between discrete elements in the range
+ * @param inclusive whether the range is inclusive
+ */
+public 
+NumberRange(T from, U to, V stepSize, boolean inclusive) {
+if (from == null) {
+throw new IllegalArgumentException("Must