Re: a bug or my fault?

2025-02-06 Thread o...@ocs.cz
MG, > On 6. 2. 2025, at 21:05, MG wrote: > I was talking about an ideal world, as a starting point on how things imho > should behave (and why), as the point towards which one should try to move as > far as constraints such as backward compatibility allows. In ideal world there should be compi

Re: a bug or my fault?

2025-02-06 Thread MG
On 06/02/2025 20:48, o...@ocs.cz wrote: P.S. Besides, a decent implementation of size-extend in case of too big gaps should automatically switch the underlying implementation to a sparse list, of which the programmer does not need to be expliticly aware :) This would e.g. mean that index acce

Re: a bug or my fault?

2025-02-06 Thread MG
On 06/02/2025 20:37, o...@ocs.cz wrote: Well but again, making List throw in future would break a vast codebase, which is a big no-no. I was talking about an ideal world, as a starting point on how things imho should behave (and why), as the point towards which one should try to move as far

Re: a bug or my fault?

2025-02-06 Thread o...@ocs.cz
P.S. Besides, a decent implementation of size-extend in case of too big gaps should automatically switch the underlying implementation to a sparse list, of which the programmer does not need to be expliticly aware :) P.P.S. I've tried array.withDefault and found it is not supported, and one is

Re: a bug or my fault?

2025-02-06 Thread o...@ocs.cz
Well but again, making List throw in future would break a vast codebase, which is a big no-no. Far as I know, there's no auto-extending unless you explicitly ask for that by withDefault. Thanks and all the best, OC > On 6. 2. 2025, at 20:16, MG wrote: > > My take on this for list-like struct

Re: a bug or my fault?

2025-02-06 Thread MG
My take on this for list-like structures: 1. Since the potential for hard to track errors is so high - and for least surprise - default behavior should always be to throw on out-of-bounds access. 2. Returning a default value for out of bound access can be very conventient, but should be

Re: a bug or my fault?

2025-02-06 Thread Jochen Theodorou
Hi, lists and arrays are different in Groovy. As already pointed out a array is strictly limited by a certain length, while a List is not necessarily. This behavior is quite old, from I think even before I joined the project back in the pre Groovy 1.0 phase. Groovy is actually using a mix from o

Re: a bug or my fault?

2025-02-06 Thread o...@ocs.cz
Mauro, > On 6. 2. 2025, at 18:24, Mauro Molinari wrote: > Isn't the contract of List requiring to throw an IndexOutOfBoundsException > though, in case index is invalid? Far as the API contract goes, I guess it would be probably an undocumented behaviour (which actually makes sense, allowing ea

Re: a bug or my fault?

2025-02-06 Thread Mauro Molinari
Isn't the contract of List requiring to throw an IndexOutOfBoundsException though, in case index is invalid? Mauro Molinari mauro...@tiscali.it In data 6 Febbraio 2025 18:00:36 OCsite ha scritto: Eric, I know of no oficial documentation explaining this (which does not mean there's none; perh

Re: a bug or my fault?

2025-02-06 Thread OCsite
Eric, I know of no oficial documentation explaining this (which does not mean there's none; perhaps I've just missed it). Some time ago Paul wrote unofficially that a list can be sort of seen as a map from indices to values, and as such, it is expected that non-existing indices return null ins

Re: a bug or my fault?

2025-02-06 Thread Milles, Eric (TR Technology) via dev
Is there any explicit statement about how indexing beyond the end of a collection should work? Does it extend the collection or just return null. Does a withDefault collection do something different? In general, arrays and collections should work the same, so the statement in the working with

Re: a bug or my fault?

2025-02-06 Thread OCsite
The overall intention is that whether you are using an array or a collection, the code for working with the aggregate remains the same . In this particular case alas that good and noble intention does not quite work,

Re: a bug or my fault?

2025-02-06 Thread Søren Berg Glasius
You assign 'b' as an Array, and arrays works differently than lists. Arrays are bound to their length, so 'a[2]' should report out of bounds as it is not 3 elements long, whereas a list b[2] would report null IMO it's working as intended. Den tors. 6. feb. 2025 kl. 10.20 skrev OCsite : > Hi ther

a bug or my fault?

2025-02-06 Thread OCsite
Hi there, is this inconsistence intentional and the proper Groovy behaviour, or is that a bug and should I add a jira ticket? Thanks! === groovy:000> a=[1,2] ===> [1, 2] groovy:000> b=a as Object[] ===> [1, 2] groovy:000> a[2] ===> null groovy:000> b[2] ERROR java.lang.ArrayIndexOutOfBoundsExce