groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul King <pa...@asert.com.au>
Subject Re: Constructor call short-hand syntax
Date Tue, 04 Sep 2018 22:22:05 GMT
On Wed, Sep 5, 2018 at 2:52 AM Jochen Theodorou <blackdrag@gmx.org> wrote:

> Am 04.09.2018 um 06:49 schrieb Daniel Sun:
> > Hi Paul,
> >
> >       Safe index is only for accessing the elements of collections and
> object
> > properties, but not for creating instance. The collections and objects
> may
> > be null, so we designed the "safe" index.
> >
> >       To sum up, I vote -1 to support syntax like `Date[time:0]`, the
> class
> > instance will not be null.
>
> I think you actually miss the point a little. Let me rephrase... should
> we support
>
> somMap?[x:y]
>
> for example. I personally think we can take supporting things like
> x[y:z] and x?[y:z] as future project... if we find a nice use case for
> this.
>

We certainly could ... but we don't have such a proposal in front of us
right now, so it's
whether we'd like to cater for the current situation in the meantime with
an improved
error message. We could remove such an error message at a future point if
we have
an acceptable proposal.

Having said that, it's hard to pick up this error case here without also
making the
missing : within a ternary error message look more complex. You'd basically
need
an error message that coped with both cases. Hence my suggestion to close as
"Won't fix". (But fix up the empty Map edge case only - without safe
decorator).

bye Jochen
>

Mime
View raw message