From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,839916f6ca3b6404 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!t3g2000yqa.googlegroups.com!not-for-mail From: Harald Korneliussen Newsgroups: comp.lang.ada Subject: Re: not null Date: Fri, 6 Mar 2009 08:59:41 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <49ae93bc$0$31872$9b4e6d93@newsspool3.arcor-online.net> <761a4fb8-de91-43b3-b420-55dbc06a61e7@k9g2000prh.googlegroups.com> <3234a1e2-5f7a-4a26-8b7b-65e3ac67d65f@s20g2000yqh.googlegroups.com> <1so528ceh38jq$.uws9l96ursub.dlg@40tude.net> NNTP-Posting-Host: 81.167.17.12 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1236358781 27304 127.0.0.1 (6 Mar 2009 16:59:41 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 6 Mar 2009 16:59:41 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t3g2000yqa.googlegroups.com; posting-host=81.167.17.12; posting-account=S7g0VAoAAAAdFBi5JmasOpOeJipGobpl User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.7) Gecko/2009030422 Ubuntu/8.10 (intrepid) Firefox/3.0.7,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:4965 Date: 2009-03-06T08:59:41-08:00 List-Id: On Mar 6, 4:21=A0pm, "Dmitry A. Kazakov" wrote: > On Fri, 6 Mar 2009 04:01:45 -0800 (PST), Harald Korneliussen wrote: > > On Mar 4, 5:09=A0pm, Adam Beneschan wrote: > > >> I'm having difficulty understanding the point. =A0You have to have the > >> idea of the lack of a reference. =A0How else would you implement a > >> linked list abstraction? > > > You can use algebraic data types to do that in a type safe manner. > > No, you cannot, if safe =3D static. The nodes of the list have contracts = to > support certain operations. The only problem with null is that the virtua= l > object corresponding to null does not fulfill the contract: I don't understand your code example. But kind of like some Java functions won't compile unless they're surrounded by an appropriate try/catch block, you can make in Haskell a linked list get_next function that causes the compiler to protest - at compile time, naturally - if used in a context where the possibility of returning Nothing (null) isn't considered. (Embarrassingly enough, the built-in linked list of Haskell does not do this, for historical reasons. Instead it uses the more old- fashioned and unsafe way of throwing an exception, and unlike in Java you don't have to catch or explicitly say that you won't. But it's easy to write a list that does it right)