Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.21.MISMATCH!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe11.iad.POSTED!8ad76e89!not-for-mail From: Arved Sandstrom User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Call by Result References: <95e4uuF3cvU1@mid.individual.net> <8CtIp.4644$PA5.4578@newsfe01.iad> <4df5290c$0$49183$e4fe514c@news.xs4all.nl> <4df77a95$0$49041$e4fe514c@news.xs4all.nl> <_XPJp.2060$g12.487@newsfe20.iad> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Lines: 48 Message-ID: <6XRJp.10628$5v5.8742@newsfe11.iad> X-Complaints-To: abuse@newsgroups-download.com NNTP-Posting-Date: Tue, 14 Jun 2011 23:14:10 UTC Organization: Public Usenet Newsgroup Access Date: Tue, 14 Jun 2011 20:14:10 -0300 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5315 On 11-06-14 06:18 PM, Andreas Leitgeb wrote: > Arved Sandstrom wrote: >> It's way more concise than Java, and another advantage still remains >> that we're not looking for a special value (null). > > I'm not yet sure, whether null in Java counts as a "String value", or not. > > I think it is not (whereas the empty string of course is). As such, a > variable (or field) "s" (or even an expression) of type String really > happens to be implicitly the pendant of Haskell's "Option"al String: > > Either it is "Null"... (ahem, "null"), or it holds an actual String value. > > Ditto for all the non-primitive types. > I know what you're saying, but the JLS says that a variable of a class type can hold a null reference or a reference to an object whose type is that class type or any subclass of that class type. There are similar comments for variables of interface and array types. The JLS also says that the null reference can be cast to any reference type. The JLS says that we can pretend that 'null' is a special literal that can be of any reference type. Furthermore, the default value for all reference types is null. All that JLS language - but particularly that last statement from the JLS - tells me that we consider 'null' to be a permitted value of reference types. A String variable can refer to 'null' just as it can refer to "" or "Arved", so from that perspective 'null' is a String value; albeit a special one. It's not the same notion as Option or Maybe, although I believe I sense what you were getting at. The difference being, if I were to use, as an example, Option[java.lang.String] in Scala, legitimate values of a variable of that type would be Some("Arved") Some(null) None That is, Scala Option is like a container. "Some" means that a value of a certain type (like java.lang.String) is contained; "None" means that the container is empty. In the case of Scala Option, a reference value contained by Some may be 'null' - this is qualitatively not the same thing as None. AHS