Path: csiph.com!news.redatomik.org!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: null checks Date: Sat, 8 Jul 2017 18:28:28 -0400 Organization: Aioe.org NNTP Server Lines: 34 Message-ID: References: <70f5af57-8dc0-416c-b2aa-0bbbb47fc7b5@googlegroups.com> NNTP-Posting-Host: PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:36839 On 7/8/2017 5:14 PM, Martin Gregorie wrote: > On Sat, 08 Jul 2017 22:33:36 +0200, Joerg Meier wrote: >> On Fri, 7 Jul 2017 12:12:04 -0400, Arne Vajhøj wrote: >>> I don't like to rely on IDE/checktool to enforce integrity of >>> application. >> >> Why not ? You presumably let a tool do your type checking for you all >> the time. Where is the difference to null checking ? >> > I'm with Arne here. > > Type checking can generally be done at compile time because its static > w.r.t code statements. > > However, the same doesn't apply to null checks. Whether a reference > variable contains null or not depends on what has been assigned to it > while the code was executing. Whether a null value is valid is entirely > dependent on the logic of the code using it and so often cannot be > checked at compile time. It is very difficult to check for: method requiring non null parameter called with null But I think the typical check is: method requiring non null parameter called with something that is not guaranteed to be non null I don't think I would mind it if it got build into the language and was checked by the compiler. That would just be additional type safety. But I am not keen on relying on some tool having been run with no way to verify if it has. Arne