Jochen Theodorou | 17 Jul 17:06
Gravatar

Re: [groovy-user] referencing a binding variables that's not passed

Jim White schrieb:
> Jochen Theodorou wrote:
> 
>> Jim White schrieb:
>>
>>> ty that missing indicies don't get an array index OOB exception.  In 
>>> fact it is the inconsistency with Groovy's normal property access 
>>> (Binding throws a missing variable exception for missing keys) that 
>>> makes this workaround necessary.
>>
>>
>> inconsistency or not depends on your view. Let's say from a PHP view 
>> it might not make much sense, but if you think about accessing a 
>> variable that is not yet defined, then it makes sense to throw an 
>> exception, because in almost all cases it is an error.
> 
> Which is also the case with array inidices.  Hence the inconsistency.

when you access an array index that does not exist, you get an 
exception... so what is the inconsistency? Of course in a language that 
allows you to access variables that do not exist yet, it makes sense to 
allow the access to an array index that does not access too... for 
example why should "print a" succeed even though a does not exist, but 
"print a[1]" fail if a does not exist?

bye blackdrag

--

-- 
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Gmane