[mercury-users] Libraries and DCG convenience...

Richard A. O'Keefe ok at atlas.otago.ac.nz
Wed Jun 23 13:45:27 AEST 1999


Thomas Conway asked:
	> > One of the things I like about Clean is not just that it lets
	> > you write a function Start :: *World -> *World, but that it
	> > lets you break a World into pieces and pass the pieces around
	> > *separately*.
	> 
	> Yes, this does seem like a nice idea.  In fact, it's applicable to any
	> type which can be divided into independent bits, eg, destructive
	> arrays.  This would be very nice to have in Mercury.
	
	I thought so too for a while. What happens (or more importantly,
	what are the semantics) where I open a file for reading and
	somewhere else open the same file for writing (for example) -
	assuming that the latter truncates the file, then I care very
	much what ordering of IO operations I get in an absolute
	sense.
	
The answer is that it isn't allowed.  The model is the obvious
N readers XOR 1 writer one.  Yes, that does imply a run-time check
(on UNIX picking up the device and vnode numbers would be the
obvious way to do it, given that the file might be renamed in between
the open calls).  If you *intend* to read and write a file "at the
same time", then you can open it in a mode that allows both reading
and writing.  If you *don't* intend to do that, then accidentally
doing so is an error you are *grateful* to have checked.  I know I'd
have been grateful for it more than once in C.

--------------------------------------------------------------------------
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