suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
Gentlemen, some NPE-related problems of today brought me to re-interate one of my older suggestions. We have the so-called “safe navigation”[*], which in some cases allows a null to be propagated out of an expression instead of throwing a NPE. At the moment, it can be triggered for a particula

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
thing :) Thanks and all the best, OC > Den 2018-08-14 13:28, skrev ocs@ocs: >> Gentlemen, >> some NPE-related problems of today brought me to re-interate one of my >> older suggestions. >> We have the so-called “safe navigation”[*], which in some cases allows >> a

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
Just a followup: > On 14 Aug 2018, at 2:25 PM, ocs@ocs wrote: > > what I would like to see in Groovy would be a way to intentionally switch to > the non-NPE null-propagating behaviour where needed by very explicit using of > an appropriate annotation. ... considering tha

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
p://www.linkedin.com/in/aalmiray> > -- > What goes up, must come down. Ask any system administrator. > There are 10 types of people in the world: Those who understand binary, and > those who don't. > To understand recursion, we must first understand recursion. > > On

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
rException npe) { null } } === happens to be now. Thanks and all the best, OC > On 14 Aug 2018, at 2:50 PM, h...@abula.org wrote: > > Den 2018-08-14 14:25, skrev ocs@ocs: >> H2, >>> On 14 Aug 2018, at 1:38 PM, h...@abula.org wrote: >>> IMHO, there is an e

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
Jochen, > On 14 Aug 2018, at 6:25 PM, Jochen Theodorou wrote: > Am 14.08.2018 um 15:23 schrieb ocs@ocs: >> H2, >>> However, “a+b” should work as one would expect >> Absolutely. Me, I very definitely expect that if a happens to be null, the >> result is null to

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
Jochen, > On 14 Aug 2018, at 6:34 PM, Jochen Theodorou wrote: > [...] >> For the moment, the best solution — far as I have been able to ascertain — >> consists of [*] >> (a) at launch, setting own DelegatingMetaClass subclass for a >> Null.metaclass; it essentially would return null from invoke

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 268 /tmp> === Thanks and all the best, OC > On 14 Aug 2018, at 7:10 PM, ocs@ocs wrote: > >

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
for some people it definitely is better, and that Groovy should support those times and people just as well as it supports the NPE-based approach of Java. Thanks and all the best, OC > Ursprüngliche Nachricht > Von: "ocs@ocs" > Datum: 14.08.18 17:46 (GMT+00:

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
s and all the best, OC > > On Tue, Aug 14, 2018 at 1:28 PM, ocs@ocs mailto:o...@ocs.cz>> > wrote: > Gentlemen, > > some NPE-related problems of today brought me to re-interate one of my older > suggestions. > > We have the so-called “safe navigation”[*], which in

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
e quick, efficient and convenient null-propagation instead) :) Thanks and all the best, OC > Ursprüngliche Nachricht > Von: "ocs@ocs" > Datum: 14.08.18 23:14 (GMT+00:00) > An: dev@groovy.apache.org > Betreff: Re: suggestion: ImplicitSafeNavigation ann

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-14 Thread ocs@ocs
all said, it definitely is an interesting idea worth checking; myself, though, I do fear it would quickly lead to a real mess (unlike my suggestion, which is considerably less flexible, but at the same moment, very simple and highly intuitive). Thanks and all the best, OC > Ursp

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-15 Thread ocs@ocs
Jochen, > On 15 Aug 2018, at 10:13 AM, Jochen Theodorou wrote: > Am 14.08.2018 um 19:10 schrieb ocs@ocs: >> Jochen, >>> On 14 Aug 2018, at 6:34 PM, Jochen Theodorou >> <mailto:blackd...@gmx.org>> wrote: > [...] >>> are you saying x?.foo will NPE if

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-15 Thread ocs@ocs
t; I also think any assumption about the semantics of null values are > problematic. In particular, assuming that any null value in an expression > should be propagated is not obvious to me. To me, it seems very obvious, completely natural and quite intuitive — especially in Groovy where (un

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-15 Thread ocs@ocs
x27;?' gently and sport a weird results, from an insane (though understandable) runtime behaviour like “null?.is(null)" sports up through exceptions compile-time to (at least to me not understandable) Verity Error caused by super?.anything. Thanks and all the best, OC > > From:

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-15 Thread ocs@ocs
overlooking something of importance. All the best., OC > > Ursprüngliche Nachricht > Von: "ocs@ocs" > Datum: 15.08.18 19:53 (GMT+00:00) > An: dev@groovy.apache.org > Betreff: Re: suggestion: ImplicitSafeNavigation annotation > > Eric, >

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-15 Thread ocs@ocs
mp;& null == false // Groovy-truth-null > > ? > > > > Ursprüngliche Nachricht > Von: "ocs@ocs" > Datum > > Ursprüngliche Nachricht > Von: mg > Datum: 15.08.18 13:07 (GMT+00:00) > An: dev@groovy.apache.org > Betreff:

metaclass getProperty does not work at all (2.4) (was: suggestion: ImplicitSafeNavigation annotation)

2018-08-16 Thread ocs@ocs
Jochen, > On 15 Aug 2018, at 10:13 AM, Jochen Theodorou wrote: > have to do the same treatment for get/setProperty I have tried repeatedly, but the thing simply does not work :( Any idea why? === 585 /tmp> /usr/local/groovy-2.4.15/bin/groovy q WARNING: An illegal reflective access operation ha

static block called too late for installing a propertyMissing (sans indy only)

2018-08-18 Thread ocs@ocs
Ladies and gentlemen, I have bumped into another suspicious behaviour: is this all right? Happens both with 2.4 and 3.0 same way. Thanks and all the best, OC === 717 /tmp> /usr/local/groovy-3.0.0-alpha-3/bin/groovy q WARNING: Using incubator modules: jdk.incubator.httpclient Caught: gro

Re: suggestion: ImplicitSafeNavigation annotation

2018-08-18 Thread ocs@ocs
e of someone explicitely > throwing an NPE in a method... ;-) > > @null.each { ... } : That would be my expectation also, but afaik null.each > behavior in dynamic Groovy has been around long before Elvis entered the > building... > > Cheers, > mg > > > > Urspr

Inconsistent overriding of Interger methods

2018-08-19 Thread ocs@ocs
Ladies and gentlemen, the debate of null-propagation led me to bumping into a wildly inconsistent behaviour when one overrides Integer methods through the metaclass. To me, this looks like a bug; even if this mess happens to be an intended behaviour, it is pretty weird (in this case, is it docu

Re: Inconsistent overriding of Interger methods

2018-08-20 Thread ocs@ocs
ding of Interger methods > > It appears to be most (all?) primitive/wrapper types not just Integer. > > On Sun, Aug 19, 2018 at 11:00 PM ocs@ocs mailto:o...@ocs.cz>> > wrote: > Ladies and gentlemen, > > the debate of null-propagation led me to bumping into a wildly inconsi

looks like a compiler bug?

2018-08-24 Thread ocs@ocs
Ladies and gentlemen, I've just bumped into the problem shown below. Whilst it is arguable whether the situation should be valid or not (myself, I strongly believe it should be valid and compiled without a glitch), even if invalid, it should not cause an uncaught exception, but simply report a

Re: looks like a compiler bug?

2018-08-25 Thread ocs@ocs
row new RuntimeException('Boom!')} > try { > new Foo().baz() > println 'ERROR: Should not get here!' > } catch(RuntimeException ex) { > println ex.message > } > > So instead of the weird "runtime" error during parsing, we could throw

another weird parser case

2018-09-30 Thread ocs@ocs
Hi there, lately, I got bit in my tender parts by this catch, sorta similar to the debate of the more-line-expression of late -- this time, though, a line which I presumed to be compiled separately is considered a part of the previous command: === 20 /tmp> } } } foo.baz() 21 /tmp> /usr/local

Re: DGM for first or default

2018-10-18 Thread ocs@ocs
Myself, I am not a huge fan of adding not-often-needed functionalities (and actually would add almost none of those discussed lately); nevertheless... > On 18 Oct 2018, at 6:48 PM, Paolo Di Tommaso > wrote: > > -1, it can be easily done as: > list.first() ?: defaultValue ... this won't work

Re: DGM for first or default

2018-10-18 Thread ocs@ocs
P.S. Oh, and when I am writing anyway — please, do not abuse the “overloaded” methods which differ just by their argument lists (myself, I consider them always at best suspicious; mostly plain wrong). Instead of the suggestion below, if something like that is accepted, it would be much better to

Re: DGM for first or default

2018-10-18 Thread ocs@ocs
I suppose this is the equivalent now > that I think about it: > > list ? list.first() : defaultValue > > > From: ocs@ocs mailto:o...@ocs.cz>> > Sent: Thursday, October 18, 2018 12:07 PM > To: dev@groovy.apache.org <mailto:dev@groovy.apache.org> > Subje

Re: DGM for first or default

2018-10-18 Thread ocs@ocs
mailto:dev@groovy.apache.org> > Subject: Re: DGM for first or default > > "list?.first() ?: defaultValue" is not the equivalent. If the collection is > empty, first() throws an IndexOutOfBoundsException is thrown. That's why I'm > asking if there is a s