caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Avoiding shared data
@ 2005-09-25 21:32 Martin Chabr
  2005-09-26  0:23 ` [Caml-list] " Bill Wood
                   ` (2 more replies)
  0 siblings, 3 replies; 45+ messages in thread
From: Martin Chabr @ 2005-09-25 21:32 UTC (permalink / raw)
  To: caml-list

Working with non-shared data structures in OCaml
Deep copy of OCaml structures, marshaling
================================================

Dear group members,

I need to process arrays of pairs of integers and
records ((int * record) array) in which all elements
must be updated individually, which means that
unshared data structures must be used. For arrays of
arrays I can produce unshared data by using the
library functions Array.copy and Array.append to
append the individual arrays into the embedding array.
It works, the low level arrays can be updated
individually. But I cannot use the same scheme to the
array of the (int * record) structures, because I do
not know how to copy these structures to dissolve the
sharing. I do not even know how to copy records. It
seems to me that this problem occurs always when I
want to produce an array of data with a fixed
structure automatically (rather than entering the
array [| ... |] by hand at the top level interpreter
using constants only). How can I produce completely
unshared structures?

What about marshaling and unmarshaling the data? This
should produce a deep copy of data objects. I have
tried it, it works, but it seems to me wasteful to
copy all the data twice only to get rid of the
sharing.

It would be great to know of a completely general (any
nested structures) and fast solution (without copying)
how to produce unshared data structures.

My environment is OCaml 3.08.02 for Windows on Win
2000, New Windows Interface v1.9RC4.

I am looking forward to you reply.

Regards,

Martin

Martin Chabr
Hochstrasse 28
8044 Zürich
Schweiz / Switzerland
Tel.P.: 01-261 17 24


		
___________________________________________________________ 
Was denken Sie über E-Mail? Wir hören auf Ihre Meinung: http://surveylink.yahoo.com/wix/p0379378.aspx


^ permalink raw reply	[flat|nested] 45+ messages in thread
* Re: FP/IP and performance (in general) and Patterns... (Re: [Caml-list] Avoiding shared data)
@ 2005-10-05 13:45 Oliver Bandel
  2005-10-05 23:20 ` William Lovas
  0 siblings, 1 reply; 45+ messages in thread
From: Oliver Bandel @ 2005-10-05 13:45 UTC (permalink / raw)
  To: caml-list


On Tue, Oct 04, 2005 at 07:45:12PM -0500, Brian Hurt wrote:
[...] 
> The big advantage of FP programming IMHO is not performance, but instead 
> *correctness*.  With today's multi-gigahertz machines with multi-gigabytes 
> of memory, performance isn't as critical as it used to be.  But 
> correctness- especially automatically gaurenteed correctness on projects 
> spanning hundreds of thousands of lines of code and dozens of developers 
> maintained over decades of time- starts becoming critical.

Yes, I agree on this.
I get daily messages from an buglist-mailinglist, where most often
things like typical memory-exploits are the reason of why a system
or a process can be exploited.

So, the typical "out of bounds" and "format string" problems
are typical security risks.
(Btw: is OCaml's format-string stuff from the Printf-module save in
this respect?!)


> I'd quite 
> happily trade off 10% performance for correctness, or even 50% 
> performance.

Well, if the code with correctness is nearly as fast as the code without,
it would be best.


> 
> FP is a huge gain in correctness, because it allows me to *control 
> mutability*.  If I pass a mutable data structure to a block of code there 
> is an instant implicit contract between the caller and the callee on how 
> (or wether) to modify the mutable data structure.  It doesn't matter what 
> the contract is- wether it's to not modify the structure at all, to allow 
> optional modification (either unlimited or only in certain ways), or to 
> require certain modifications- a dependency between the two different 
> peices of code exists.  And this dependency, this contract, is probably 
> undocumented and always unchecked by the compiler, which means it's a 
> maintaince nightmare waiting to happen.  One peice of code gets modified 
> to violate the contract, perhaps even unknowingly, or perhaps due to some 
> changing requirement, and untouched code thousands of lines away suddenly 
> breaks.


Yes, this is a very well description of the FP-advantages.
Nevertheless, if a solution is too slow, it hinders
people from adopting FPLs for their programmig, and
software remains unsecure/unsafe, because they again and again
will choose the unsafe langauges... :(


Ciao,
   Oliver


^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2005-10-06 16:54 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-25 21:32 Avoiding shared data Martin Chabr
2005-09-26  0:23 ` [Caml-list] " Bill Wood
2005-09-26  7:57 ` Claudio Sacerdoti Coen
2005-09-26  8:17 ` William Lovas
2005-09-26 21:07   ` Ant: " Martin Chabr
2005-09-26 22:08     ` Jon Harrop
2005-09-30 22:57     ` Oliver Bandel
2005-10-01  0:07       ` Pal-Kristian Engstad
2005-10-01  5:46         ` Bill Wood
2005-10-01  8:27         ` Wolfgang Lux
2005-10-01 18:02           ` Wolfgang Lux
2005-10-01 21:50           ` Ant: " Martin Chabr
2005-10-01 12:34         ` Oliver Bandel
2005-10-01 13:58           ` Bill Wood
2005-10-01 21:05         ` Ant: " Martin Chabr
2005-10-03  0:41           ` skaller
2005-10-03  1:13             ` Seth J. Fogarty
2005-10-03 13:09             ` Thomas Fischbacher
2005-10-03 14:57               ` skaller
2005-10-03 20:03               ` Ant: " Martin Chabr
2005-10-03 20:25                 ` Thomas Fischbacher
2005-10-03 21:08                 ` Jon Harrop
2005-10-04 18:06                   ` Ant: " Martin Chabr
2005-10-04 18:32                     ` Jon Harrop
2005-10-04  2:53                 ` skaller
2005-10-04 16:15                   ` Brian Hurt
2005-10-04 16:47                     ` FP/IP and performance (in general) and Patterns... (Re: [Caml-list] Avoiding shared data) Oliver Bandel
2005-10-04 22:38                       ` Michael Wohlwend
2005-10-05  0:31                         ` Jon Harrop
2005-10-04 22:39                       ` Christopher A. Watford
2005-10-04 23:14                         ` Jon Harrop
2005-10-05 12:10                         ` Oliver Bandel
2005-10-05 13:08                           ` Jon Harrop
2005-10-05 15:28                           ` skaller
2005-10-05 20:52                           ` Ant: " Martin Chabr
2005-10-05 23:21                             ` Markus Mottl
2005-10-06 16:54                               ` brogoff
2005-10-05  0:45                       ` Brian Hurt
2005-10-04 18:09                   ` Ant: Re: Ant: Re: Ant: Re: Ant: Re: [Caml-list] Avoiding shared data Martin Chabr
2005-10-05  8:42                     ` skaller
2005-10-05 11:14               ` Andrej Bauer
2005-10-01 21:36       ` Ant: Re: Ant: " Martin Chabr
2005-10-03 11:51         ` getting used to FP-programming (Re: Ant: Re: Ant: Re: [Caml-list] Avoiding shared data) Oliver Bandel
2005-10-05 13:45 FP/IP and performance (in general) and Patterns... (Re: " Oliver Bandel
2005-10-05 23:20 ` William Lovas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).