[Gambas-user] Feature request: Use key- (and index-)accessor in a With clause

Benoît Minisini gambas at ...1...
Tue Aug 13 01:31:02 CEST 2013


Le 11/08/2013 13:33, Tobias Boege a écrit :
> Hi Benoit,
>
> what bothers me from time to time is that With is *so* handy but can't be
> used to access Array or Collection elements like:
>
> With hCollection ' or hArray
>    Print ["key"]  ' or Print [0]
> End With
>
> I see that this would be a syntactical problem because ["key"] and [0] may
> equivalently well be recognised as inline arrays. But we have another
> option, right? There is still the ! operator which is unambiguous:
>
> With hCollection
>    Print !key
> End With
>
> Should be no problem if implemented. What do you think? And while we are at
> it, couldn't the ! operator at the same time get the capability to support
> integers, so that the above will also work with an array:
>
> With hArray
>    Print !0
> End With
>
> Regards,
> Tobi
>

The '!' can't be used, because a!b is just syntactic sugar for a["b"].

Maybe a syntax like .[x] = y could be used, as at the moment .[x] is a 
syntax error... I will think about it.

-- 
Benoît Minisini




More information about the User mailing list