[ nice-Feature Requests-671444 ] Enhanced Null testing with class or instance variables

"SourceForge.net" <[email protected]> Tue, 14 Apr 2009 15:29:30 +0000
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
Feature Requests item #671444, was opened at 2003-01-20 22:52
Message generated for change (Comment added) made by nobody
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=362788&aid=671444&group_id=12788

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Priority: 5
Private: No
Submitted By: Bryn Keller (xoltar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Enhanced Null testing with class or instance variables

Initial Comment:
Background:

Nice currently allows local variables which are of
option types to be tested using simple &quot;if&quot; statements:

?String foo = null;
// ...
if (foo != null) {
   //Here foo is of type String, not ?String.
}

Within the body of a (foo != null) block, foo is
considered to be a String, not a ?String, since it is
known not to be null. 

Feature:

A useful feature would be to extend this behavior to
class and instance variables:

class Foo {
    ?String bar;

    String baz() = bar != null ? bar : &quot;default&quot;;
}

However this is not possible due to the fact that bar
may be modified by another thread (set to null) between
the time of the test and the time bar is used where a
(non-null) String is expected.

It would be possible to do this when the variable is
final. For example (thanks to Daniel for the example):

class Name
{
 // Everybody has first and last names.
  final String first;
  final String last;

 // Not everybody has a middle name.
  final ?String middle;

 toString() {
   if (middle != null)
     ...
 }
} 

It might also be safe to do this in the event that a
variable is only ever accessed via methods or code
which is synchronized on the given object...






----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2009-04-14 15:29

Message:
http://deluxclubca.com/cp/porno/index.html <a
href=http://deluxclubca.com/cp/porno/index.html>daily porn star</a>
http://deluxclubca.com/cp/porno/daily-porn-thumb.html <a
href=http://deluxclubca.com/cp/porno/daily-porn-thumb.html>daily porn
thumb</a> http://deluxclubca.com/cp/porno/daily-porn-video-clips.html <a
href=http://deluxclubca.com/cp/porno/daily-porn-video-clips.html>daily porn
video clips</a> http://deluxclubca.com/cp/porno/daily-porn-vids.html <a
href=http://deluxclubca.com/cp/porno/daily-porn-vids.html>daily porn
vids</a> 

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2009-04-13 22:55

Message:
QJo9wv 

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2005-02-10 23:55

Message:
Logged In: NO 

I should have added that I don't understand this restriction
as any guard can be defeated. If synchronization is poor all
guarantees are void.
e.g. if (x >= 3) {
           // Someone changes x here to 2 in another thread.
           A[x -3] = "abc"; // Whoops();
       }
So why is this a reason not to implement null testing for
class members?




----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2005-01-29 20:05

Message:
Logged In: NO 

Forgive my ignorance, but why is the operation of another
thread an issue here. Surely typing (nullness) is checked at
compile time not at run time?  If it happens at run time
Java already has a perfectly valid mechanism - the program
crashes.




----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=362788&aid=671444&group_id=12788

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com