References in D

Timon Gehr timon.gehr at gmx.ch
Mon Sep 17 06:49:21 PDT 2012


On 09/17/2012 03:33 AM, Jonathan M Davis wrote:
> On Monday, September 17, 2012 03:27:10 Timon Gehr wrote:
>> On 09/17/2012 02:23 AM, Jonathan M Davis wrote:
>>> ...  That might make sense for an int, since
>>> it can't be null, but pointers and references _can_ be and are in every
>>> type system that I've ever used.
>>>
>>> ...
>>
>> You have claimed multiple times to have used Haskell.
>
> I have, but I've never used pointers in haskell, so if they're non-nullable, I
> wouldn't know about it. I believe that everything in Haskell is an immutable
> value type as far as what I've dealt with goes.
>
> - Jonathan M Davis
>

In effect, everything is a non-null reference to mutable, but as
mutation is constrained rather specifically, it is possible to reason
about the behaviour of Haskell programs on a higher level of
abstraction.

 > let fib n = if n<2 then n else fib (n-1) + fib (n-2)
 > let x = fib 30
 > let y = x
 > let z = x
 > y
(delay)
832040
 > z
(no delay)
832040



More information about the Digitalmars-d mailing list