[mercury-users] maybe(T)

Ralph Becket rafe at cs.mu.OZ.AU
Mon Oct 21 15:52:26 AEST 2002


Michael Day, Monday, 21 October 2002:
> 
> > Using `maybe(T)' does have an extra level of indirection compared to using
> > plain `T' (just as in C, `T *' has an extra level compared to `T').
> 
> Okay, so maybe(int) could be represented as an int pointer in C:
> 
> 	yes(T)		: valid pointer to an integer
> 	no		: NULL
> 
> However the case I am interested in is when T is a pointer itself already,
> for example a string or a structure.
> 
> 	yes(T)		: pointer to a pointer to something
> 	no		: NULL
> 
> It seems that this could be flattened into this:
> 
> 	yes(T)		: pointer to something
> 	no		: NULL
> 
> and save an unnecessary pointer cell. Any thoughts?

What if T = NULL?  How then could you tell the difference between no and
yes(T)?

- Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list