Browse thread
RE: [Caml-list] Operator overloading
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-03-10 (03:23) |
From: | skaller <skaller@u...> |
Subject: | Re: [Caml-list] Operator overloading |
On Fri, 2007-03-09 at 11:02 -0500, Brian Hurt wrote: > considering wether to add a feature to a language, you have to consider > *BOTH* the valid uses of that feature *AND* the probable ways the > feature will be misused and the problems it will cause. You don't get > to ignore the downsides. Because, if you do, then there's no real > reason why introducing pointer arithmetic into Ocaml is not a good idea. Actually, using your criteria, it might a good idea IF it is possible to limit abuse in a way compatible with Ocaml philosophy. For example if you could ensure pointers always remained in bounds, or at least threw an exception when an out of bound dereference occurred. The latter seems acceptable because it is already what happens with an out of bounds access to an array. Array pointers seem easy to represent .. it's just a pair 'a Array.t * int Offset addition is statically safe, so you can throw that in too. That can be implemented with composition of closures which access record fields. However it isn't clear any of this is worth it: pointer arithmetic is used in C because it is fast, in Ocaml it probably wouldn't be, an other techniques would provide the same functionality. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net