Uh... destructors?

Kevin Bealer kevindangerbealer at removedanger.gmail.com
Wed Feb 23 20:31:41 PST 2011


== Quote from Kevin Bealer (kevindangerbealer at removedanger.gmail.com)'s article
> == Quote from bearophile (bearophileHUGS at lycos.com)'s article
> ...
> > Currently you are able to write functions like:
> > pure bool randomPure() {
> >     int[] a1 = new int[1];
> >     int[] a2 = new int[2];
> >     return a1.ptr > a2.ptr;
> > }
> Is it possible to fix this by disallowing using the value of a pointer,
> except allowing them to be compared for equality (only)?  In other words,
> within a pure function, only 'is' '!is', ==, != are permitted as tests
> of pointers?  Other arithmetic forbidden... this sort of matches the Java
> model where you can't fiddle with references except to check if they are
> the same.
> Kevin

I wanted to add something I just realized -- malloc is essentially pure if
you can't compare the pointers it returns.  Of course if you can't do either
casting or arithmetic on these pointers I'm not sure how to use malloc.

Kevin


More information about the Digitalmars-d mailing list