[Caml-list] Bug? Constraints get ignored in methods

2009-03-31 Thread Goswin von Brederlow
Hi, I want to keep a linked list of structures that have a common subset of functionality. I thought this would be a good use of ocaml objects. A base class with the common subset of functionality and methods to link them. And then derived classes for the specific types. Most simplified it looks l

Re: [Caml-list] Bug? Constraints get ignored in methods

2009-03-31 Thread Goswin von Brederlow
Martin Jambon writes: > Goswin von Brederlow wrote: >> Hi, >> >> I want to keep a linked list of structures that have a common subset >> of functionality. I thought this would be a good use of ocaml objects. > > It is not a good use of objects. You'll

Re: [Caml-list] Bug? Constraints get ignored in methods

2009-03-31 Thread Goswin von Brederlow
Hi, small add on to my last mail. Think of it as having a set of work queues: clean, dirty, reading, writing, write_prepare. The objects need to be able to quickly jump from one queue to the back of another when the objects internal state changes. And is not only the objects at the head of the qu

Re: [Caml-list] Bug? Constraints get ignored in methods

2009-03-31 Thread Goswin von Brederlow
Peng Zang writes: > Hi, > > Here's an example of how constraints are specified for polymorphic methods. > In this example I define a list type which can compare to anything that is > foldable. > > class type ['a] foldable = object > method foldl : 'z. ('z -> 'a -> 'z) -> 'z -> 'z > end

Re: [Caml-list] Bug? Constraints get ignored in methods

2009-04-01 Thread Goswin von Brederlow
Martin Jambon writes: > Would the following work for you: No. Not just like this. > type 'a linked = { > data : 'a; > mutable next : < > linked option > } > (* constraint 'a = < .. > *) > > let create data next = { > data = data; > next = (next :> < > linked option) > } > > let set_next

Re: [Caml-list] Bug? Constraints get ignored in methods

2009-04-03 Thread Goswin von Brederlow
Jacques GARRIGUE writes: > From: Goswin von Brederlow > >> I want to keep a linked list of structures that have a common subset >> of functionality. I thought this would be a good use of ocaml objects. >> A base class with the common subset of functionality and methods t

[Caml-list] Execution order in class construction

2009-04-03 Thread Goswin von Brederlow
Hi, I'm wondering if the execution order is defined during class construction. For example: let n = ref 0 let next () = incr n; !n class foo = object val x = next () val y = next () val z = next () method print = Printf.printf "%d %d %d\n" x y z end Will that always give x < y < z or cou

Re: [Caml-list] Strings

2009-04-03 Thread Goswin von Brederlow
Daniel Bünzli writes: > Le 3 avr. 09 à 18:52, Martin Jambon a écrit : > >> I love this recurrent discussion! > > I love your carefully argumented response ! > >> - I see absolutely no practical advantage of having an immutable >> "character >> string" type. > > In fact I find the result of the fo

Re: [Caml-list] 64 bits ocamlopt to generate 32 bits code

2009-04-03 Thread Goswin von Brederlow
Jean Guyader writes: > Hello, > > Is it possible to generate 32 bits assembly code with a 64 bits ocamlopt? > > Thanks, > -- > Jean Guyader Afaik no. MfG Goswin ___ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-b

Re: [Caml-list] Strings

2009-04-04 Thread Goswin von Brederlow
David Rajchenbach-Teller writes: > I personally can't remember the last time I've needed mutable strings in > OCaml. Only for byte arrays or a buffering module where I String.blit to the string itself instead of into a new string. Saves a mutable. MfG Goswin ___

Re: [Caml-list] Strings

2009-04-04 Thread Goswin von Brederlow
Alp Mestan writes: > I think providing both capabilities is the best solution. Phantom types solvethis beautifully with not truntime penalty. GO BATTERIES! > However, let's study Haskell's strings. > They simply are a list of characters. This let the ability to use heavily > list-related funct

Re: [Caml-list] Strings

2009-04-04 Thread Goswin von Brederlow
Jon Harrop writes: > On Saturday 04 April 2009 22:51:50 Goswin von Brederlow wrote: >> The beauty of ocaml strings is that they are really compact. An ocaml >> string on 32bit is 5-8 bytes longer than the contained string and 9-16 >> bytes on 64bit. > > The ugliness i

Re: [Caml-list] Strings

2009-04-05 Thread Goswin von Brederlow
Edgar Friendly writes: > Jon Harrop wrote: >> On Saturday 04 April 2009 22:51:50 Goswin von Brederlow wrote: >>> The beauty of ocaml strings is that they are really compact. An ocaml >>> string on 32bit is 5-8 bytes longer than the contained string and 9-16 >

Re: [Caml-list] Strings

2009-04-05 Thread Goswin von Brederlow
Romain Beauxis writes: > Le Saturday 04 April 2009 11:14:34 David Rajchenbach-Teller, vous avez > écrit : >> Note that Batteries provides >> * regular OCaml strings >> * strings with capabilities (i.e. strings which, depending on their >> type, can be read-only/write-only/read-write) -- someti

Re: [Caml-list] Strings

2009-04-05 Thread Goswin von Brederlow
David Rajchenbach-Teller writes: > On Sat, 2009-04-04 at 19:35 -0400, Yaron Minsky wrote: >> On Sat, Apr 4, 2009 at 5:51 PM, Goswin von Brederlow >> wrote: >> Mutable/Immutable can really nicely done with phantom types >> and is >> indep

Re: [Caml-list] Strings

2009-04-05 Thread Goswin von Brederlow
Alp Mestan writes: > By the way, what would be the use case of lazy strings ? Strings larger than available memory or where only some small part of the string are used at any one execution. MfG Goswin ___ Caml-list mailing list. Subscription

Re: [Caml-list] Execution order in class construction

2009-04-05 Thread Goswin von Brederlow
Jacques Garrigue writes: > From: Goswin von Brederlow > >> I'm wondering if the execution order is defined during class >> construction. For example: >> >> let n = ref 0 >> let next () = incr n; !n >> class foo = object >> val x = next ()

[Caml-list] Re: Strings

2009-04-06 Thread Goswin von Brederlow
David Rajchenbach-Teller writes: > On Sun, 2009-04-05 at 12:06 +0200, Zheng Li wrote: >> With phantom type alone, the abstraction can still leak. > > Ok, it's actually not *immutable* strings but *read-only* strings. The > objective is to be able to distribute a text and make sure that the > cli

Re: [Caml-list] Re: Instance variables can't be polymorphic? {a few more annoyances on "val" syntax}

2009-04-06 Thread Goswin von Brederlow
Zheng Li writes: > [OT]: Here are a few more annoyances on the syntax of instance > variable I've encountered. I recorded it here for comments: > > Why it can't just copy the common "let" syntax in OCaml? Even though > it's possible to just lift the awkward "val" definitions out of > objects and

[Caml-list] Subtyping

2009-04-06 Thread Goswin von Brederlow
Hi, In the last 2 weeks I've been playing around with lots of different ways to do the same thing to get a feel for what style suites me best. If you have improvements or alternative ways of doing the two things below let me know. One of the things was trying to build a type hierachy with coerci

Re: [Caml-list] Subtyping

2009-04-07 Thread Goswin von Brederlow
David MENTRE writes: > Hello, > > On Tue, Apr 7, 2009 at 07:48, Goswin von Brederlow wrote: >> In the last 2 weeks I've been playing around with lots of different >> ways to do the same thing to get a feel for what style suites me >> best. If you have improveme

Re: [Caml-list] Subtyping

2009-04-07 Thread Goswin von Brederlow
Peng Zang writes: > On Tuesday 07 April 2009 03:41:32 am David MENTRE wrote: >> Hello, >> >> On Tue, Apr 7, 2009 at 07:48, Goswin von Brederlow > wrote: >> > In the last 2 weeks I've been playing around with lots of different >> > ways to do the

Re: [Caml-list] Subtyping

2009-04-07 Thread Goswin von Brederlow
Goswin von Brederlow writes: > So what other ways are there of doing this? Records. Idealy I would > like to do this: > > type base = { x : int } > let make_base x = { x = x } > let print_x r = print_int r.x > type foo = { base with y : int } > let make_foo x y

Re: [Caml-list] Subtyping

2009-04-07 Thread Goswin von Brederlow
Jacques Garrigue writes: > type 'a base = {x : 'a; fn : 'a -> unit} > type 'b base_op = {bop: 'a. 'a base -> 'b} > type base_wrapper = {base: 'b. 'b base_op -> 'b} > > let l = > let a = {x = 1; fn = print_int} > and b = {x = 1.2; fn = print_float} in > [{base = fun x -> x.bop a}; {base = fu

Re: [Caml-list] OCaml and Boehm

2009-04-11 Thread Goswin von Brederlow
Jon Harrop writes: > On Saturday 11 April 2009 20:17:58 Ed Keith wrote: >> --- On Sat, 4/11/09, Jon Harrop wrote: >> > From: Jon Harrop >> > Subject: Re: [Caml-list] OCaml and Boehm >> > To: caml-list@yquem.inria.fr >> > Date: Saturday, April 11, 2009, 10:27 AM >> > >> > Also, don't forget that

Re: [Caml-list] OCaml and Boehm

2009-04-11 Thread Goswin von Brederlow
Basile STARYNKEVITCH writes: > Lukasz Stafiniak wrote: >> Hi, >> >> Is the OCaml runtime Boehm-safe? That is, can it be run with Boehm >> turned on and traversing OCaml's heap? (So that the OCaml heap can >> provide roots to Boehm.) And if not, could it be patched to make it >> Boehm-safe in this

Re: [Caml-list] OCaml and Boehm

2009-04-13 Thread Goswin von Brederlow
Lukasz Stafiniak writes: > On Mon, Apr 13, 2009 at 11:42 AM, Christoph Bauer > wrote: >> Basile STARYNKEVITCH writes: >> >>> My advice is always to avoid mixing several garbage collection >>> techniques or implementations inside the same program. >>> >> >> TCL uses refcounted Tcl_Objs. We use t

Re: [Caml-list] pattern matching and records vs tuples

2009-04-14 Thread Goswin von Brederlow
Yoann Padioleau writes: > Hi, > > I've found that while records provide advantages over tuples, > they also have disadvantages when it comes to evolution issues. > If I decide to evolve code using a tuple type, for instance adding > new information and so extend a 4-uple in a 5-uple, then the

Re: [Caml-list] pattern matching and records vs tuples

2009-04-16 Thread Goswin von Brederlow
Pal-Kristian Engstad writes: > Honestly, I'd prefer to have to annotate non-exhaustive records: >     let { foo = foo; bar = bar } = x > should only match { foo; bar }, but >     let { foo = foo; bar =  bar; .. } = x, > can match records with more labels. > PKE. > Yaron Minsky wrote: I would act

Re: [Caml-list] pattern matching and records vs tuples

2009-04-17 Thread Goswin von Brederlow
"David Allsopp" writes: > Goswin von Brederlow wrote: >> I would actually like to propose that to work on a type >> level. Currently we have: >> >> I propose that records can be subtyped if their prefix matches and >> ".." would be used to

Re: [Caml-list] Extending modules and signatures

2009-04-17 Thread Goswin von Brederlow
Peter Hawkins writes: > Hi... > > I have a quick question. I want to extend the List module with various > functions that I want that aren't present in the standard library, > much as the Batteries ExtList library does. > > I might write the following code in "mylibrary.ml": > module MyList = str

Re: [Caml-list] Extending modules and signatures

2009-04-19 Thread Goswin von Brederlow
Jon Harrop writes: > On Sunday 19 April 2009 22:36:12 Ashish Agarwal wrote: >> Having the compiler introduce module type names automatically from mli >> files would be very helpful, and I don't see any disadvantages. > > Some people contest the idea that files should automatically convey module

Re: [Caml-list] Extending modules and signatures

2009-04-19 Thread Goswin von Brederlow
Martin Jambon writes: > OK, but I think the real issue is inheritance. In order to truly extend an > existing module, one needs to access the private items of the inherited module > implementation. In order to avoid messing up with the original module's > global variables, the inherited "module

Re: [Caml-list] what is the "best" block structure to code a tree structure?

2009-04-19 Thread Goswin von Brederlow
Arkady Andrukonis writes: > Hi, > > I would like to find the easiest block structure to represent nested leaves > and nodes in a tree structure that works for OCaml. In Common Lisp there is > the help of indentation, but I haven't found one for OCaml. > > We have one parent node composed of one

Re: [Caml-list] mixed functional / object style

2009-04-19 Thread Goswin von Brederlow
Guillaume Hennequin writes: > Dear list, > this is a somewhat naive question > let's define > class a = object >  val mutable v = ... >  method v = v >  method m = something that uses v > end ;; > now assume that I want to create a lot of those a objects, so many that I may > encounter memory pro

Re: [Caml-list] Ocamlopt x86-32 and SSE2

2009-05-09 Thread Goswin von Brederlow
"CUOQ Pascal" writes: > Xavier Leroy wrote: >>2- Declare pre-SSE2 processors obsolete and convert the current >> "i386" port to always use SSE2 float arithmetic. >> >>3- Support both x87 and SSE2 float arithmetic within the same i386 >> port, with a command-line option to activate SSE2, like

[Caml-list] How to do thread save callbacks from C to ocaml?

2009-05-30 Thread Goswin von Brederlow
Hi, for my fuse bindings I have a number (~20) of callbacks from C code to ocaml that I want to make sure behave correctly when multithreaded. The libfuse runs with enter_blocking_section() so other ocaml threads can run while it blocks. That means I need to call leave_blocking_section() before I

Re: [Caml-list] C wrappers and callbacks from Ocaml to C and back to Ocaml

2009-08-06 Thread Goswin von Brederlow
Erik de Castro Lopo writes: > Hi all, > > I'm wrapping some C code that requires me to define a struct in Ocaml > like this: > > type xt = { f : xt -> a } > > and then pass the struct to C which stores it, and later the C needs > to find function f, call it from C, passing it the Ocaml xt str

Re: [Caml-list] Re: ocaml sefault in bytecode: unanswered questions

2009-08-09 Thread Goswin von Brederlow
"ivan chollet" writes: > :v="urn:schemas-microsoft-com:vml" > xmlns:o="urn:schemas-microsoft-com:office:office" > xmlns:w="urn:schemas-microsoft-com:office:word" > xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"; > xmlns="http://www.w3.org/TR/REC-html40";> > > Definitely.:p> > > Actual

Re: [Caml-list] Sets and home-made ordered types

2009-09-23 Thread Goswin von Brederlow
Matthias Puech writes: > David Allsopp a écrit : >> Is it not possible to model your requirement using Map.Make instead - where >> the keys represent the equivalence classes and the values whatever data >> you're associating with them? > > Yes, that's exactly the workaround I ended up using, alth

Re: [Caml-list] OC4MC : OCaml for Multicore architectures

2009-09-23 Thread Goswin von Brederlow
Philippe Wang writes: > This is some additional "noise" about "OCaml for Multicore > architectures" (or "Ok with parallel threads GC"). > > > Dear list, > > We have implemented an alternative runtime library for OCaml, one that > allows threads to compute in parallel

Re: [Caml-list] Constructors are not functions

2009-10-08 Thread Goswin von Brederlow
"David Allsopp" writes: > Jon Harrop wrote: >> David Allsopp wrote: >> > I think it would be possible to simulate the SML behaviour in OCaml >> > using camlp4 (if you assume that for [type foo = Bar of int] that future >> > unbound references to [bar] are interpreted as [fun x -> bar x] instead o

Re: [Caml-list] Constructors are not functions

2009-10-09 Thread Goswin von Brederlow
"David Allsopp" writes: > Goswin von Brederlow wrote: > >> Then what about >> >> type t1 = Bar of int * int >> type t2 = Foo of (int * int) >> >> If you treat constructors as functions taking one argument then > > But why (so arbitrari

Re: [Caml-list] Linking mutually dependent modules for fun

2009-10-19 Thread Goswin von Brederlow
"Damien Guichard" writes: > Hi Dawid, > >   > > Have you ever considered recursive modules ? > > [[http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html#toc75]] The problem there is that that places everything in one file. >> The following is what I got when studying OCaml's linking issues:

[Caml-list] How to read different ints from a Bigarray?

2009-10-28 Thread Goswin von Brederlow
Hi, I'm working on binding s for linux libaio library (asynchron IO) with a sharp eye on efficiency. That means no copying must be done on the data, which in turn means I can not use string as buffer type. The best type for this seems to be a (int, int8_unsigned_elt, c_layout) Bigarray.Array1.t.

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-10-28 Thread Goswin von Brederlow
Sylvain Le Gall writes: > Hello, > > On 28-10-2009, Goswin von Brederlow wrote: >> Hi, >> >> I'm working on binding s for linux libaio library (asynchron IO) with >> a sharp eye on efficiency. That means no copying must be done on the >> data, which

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-10-28 Thread Goswin von Brederlow
Sylvain Le Gall writes: > On 28-10-2009, Goswin von Brederlow wrote: >> Sylvain Le Gall writes: >> >>> Hello, >>> >>> On 28-10-2009, Goswin von Brederlow wrote: >>>> Hi, >>>> >>> >>> Well, we talk about this

Re: [Caml-list] How to read different ints from a Bigarray?

2009-10-28 Thread Goswin von Brederlow
Gerd Stolpmann writes: > Am Mittwoch, den 28.10.2009, 14:54 +0100 schrieb Goswin von Brederlow: >> Hi, >> >> I'm working on binding s for linux libaio library (asynchron IO) with >> a sharp eye on efficiency. That means no copying must be done on the >> d

Re: [Caml-list] How to read different ints from a Bigarray?

2009-10-28 Thread Goswin von Brederlow
Xavier Leroy writes: > Goswin von Brederlow wrote: > >> I'm working on binding s for linux libaio library (asynchron IO) with >> a sharp eye on efficiency. That means no copying must be done on the >> data, which in turn means I can not use string as buffer type.

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-10-28 Thread Goswin von Brederlow
Sylvain Le Gall writes: > On 28-10-2009, Goswin von Brederlow wrote: >> Sylvain Le Gall writes: >>> On 28-10-2009, Goswin von Brederlow wrote: >>>> Sylvain Le Gall writes: >>>>> On 28-10-2009, Goswin von Brederlow wrote: >> >>>>

Re: [Caml-list] Binding C libraries which use variable arguments (stdarg.h)

2009-10-29 Thread Goswin von Brederlow
Basile STARYNKEVITCH writes: > Adrien wrote: >> Hi, >> >> I am currently trying to bind a C function that takes variables >> arguments, like foo(int a, ...). I can't find how to make a C stub for >> that function. > > I am assuming that the a is the number of actual arguments, so you call > foo(

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-10-29 Thread Goswin von Brederlow
blue storm writes: > On Wed, Oct 28, 2009 at 6:57 PM, Goswin von Brederlow > wrote: >> Maybe ideal would be a format string based interface that calls C with >> a format string and a record of values. Because what I really need is >> to read/write records in an arch

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-10-29 Thread Goswin von Brederlow
Goswin von Brederlow writes: > blue storm writes: > >> On Wed, Oct 28, 2009 at 6:57 PM, Goswin von Brederlow >> wrote: >>> Maybe ideal would be a format string based interface that calls C with >>> a format string and a record of values. Because what I real

Re: [Caml-list] How to read different ints from a Bigarray?

2009-10-29 Thread Goswin von Brederlow
Xavier Leroy writes: > Goswin von Brederlow wrote: > >> I'm working on binding s for linux libaio library (asynchron IO) with >> a sharp eye on efficiency. That means no copying must be done on the >> data, which in turn means I can not use string as buffer type.

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-10-29 Thread Goswin von Brederlow
Richard Jones writes: > On Thu, Oct 29, 2009 at 10:50:31AM +0100, Goswin von Brederlow wrote: >> but no >> >> let unparse_foo (x, y) = >> bitmake { x : 16 : littleendian; y : 16 : littleendian } x y > > See: > > http://et.redhat.co

Re: [Caml-list] How to read different ints from a Bigarray?

2009-10-29 Thread Goswin von Brederlow
Christophe TROESTLER writes: > On Thu, 29 Oct 2009 18:05:37 +0100, Goswin von Brederlow wrote: >> >> get an int out of a string: >> C Ocaml >> uint8 le 19.496 17.433 >>int8 le 19.298 17.850 >>

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-10-29 Thread Goswin von Brederlow
Sylvain Le Gall writes: > On 29-10-2009, Goswin von Brederlow wrote: >> Xavier Leroy writes: >>> Goswin von Brederlow wrote: >> >> Here are some benchmark results: >> >> get an int out of a string: >> C Ocaml >

Re: [Caml-list] Binding C libraries which use variable arguments (stdarg.h)

2009-10-29 Thread Goswin von Brederlow
Adrien writes: > On 29/10/2009, Goswin von Brederlow wrote: >> Basile STARYNKEVITCH writes: >> >>> Adrien wrote: >>>> Hi, >>>> >>>> I am currently trying to bind a C function that takes variables >>>> arguments, like f

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-10-29 Thread Goswin von Brederlow
Florian Weimer writes: > * Goswin von Brederlow: > >> - The data is passed to libaio and needs to be kept alive and unmoved >> as long as libaio knows it. > > It also has to be aligned to a 512-byte boundary, so you can use > O_DIRECT. Linux does not support true

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-10-29 Thread Goswin von Brederlow
Gerd Stolpmann writes: > Am Donnerstag, den 29.10.2009, 21:40 +0100 schrieb Florian Weimer: >> * Goswin von Brederlow: >> >> > - The data is passed to libaio and needs to be kept alive and unmoved >> > as long as libaio knows it. >> >> It also has

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-11-01 Thread Goswin von Brederlow
Richard Jones writes: > On Thu, Oct 29, 2009 at 06:07:59PM +0100, Goswin von Brederlow wrote: >> I still can reuse a lot of this. Esspecially the syntax extension >> seems like a good idea. Maybe reduced to bytes instead of bits >> though. I don't intend to use such

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-11-02 Thread Goswin von Brederlow
Richard Jones writes: > On Sun, Nov 01, 2009 at 04:11:52PM +0100, Goswin von Brederlow wrote: >> But C calls are still 33% slower than direct access in ocaml (if one >> doesn't use the polymorphic functions). > > Are you using noalloc calls? > > http://camltastic.

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-11-02 Thread Goswin von Brederlow
Mauricio Fernandez writes: > On Mon, Nov 02, 2009 at 05:11:27PM +0100, Goswin von Brederlow wrote: >> Richard Jones writes: >> >> > On Sun, Nov 01, 2009 at 04:11:52PM +0100, Goswin von Brederlow wrote: >> >> But C calls are still 33% slower than direct acces

Re: [Caml-list] Re: How to read different ints from a Bigarray?

2009-11-03 Thread Goswin von Brederlow
Richard Jones writes: > On Mon, Nov 02, 2009 at 05:33:24PM +0100, Mauricio Fernandez wrote: >> It might be possible to hack support for C-- expressions in external >> declarations. That'd be a sort of portable assembler. > > To be honest I'm far more interested in x86-64-specific instructions > (

[Caml-list] Compiler bug with bigarray

2009-11-04 Thread Goswin von Brederlow
Hi, I just finished adding a (int, int31_elt) Bigarray.kind for 4 byte taged integers independent of the architecture to Bigarray. While testing it I noticed that the generated assembler consists of this: open Bigarray let get_foo (a : (int, int31_elt, c_layout) Array1.t) x = Array1.unsafe_get a

[Caml-list] How to write a GC for size > memory

2009-11-12 Thread Goswin von Brederlow
Hi, as I might have mentioned in the past I'm writing C bindings for libaio and libfuse to write a filesystem in ocaml. The problem I'm now facing is freeing blocks on the filesystem when they are no longer used. The filesystem has a huge B-Tree containing inodes, file attributes, directory entri

Re: [Caml-list] How to write a GC for size > memory

2009-11-13 Thread Goswin von Brederlow
Richard Jones writes: > On Fri, Nov 13, 2009 at 06:10:03AM +0100, Goswin von Brederlow wrote: >> Normaly the GC would switch between defrag and freeing chunk >> mode. Both would be concurrent to normal filesystem >> operations. Possibly only run when the filesystem is idle.

Re: [Caml-list] The lexer hack

2009-11-14 Thread Goswin von Brederlow
Micha writes: > On Tuesday, 10. November 2009 15:42:52 Dario Teixeira wrote: >> Hi, >> >> I'm creating a parser for a LaTeX-ish language that features verbatim >> blocks. To handle them I want to switch lexers on-the-fly, depending on the >> parsing context. Therefore, I need the state from the

Re: [Caml-list] Polymorphic functors / modules and OCaml-R

2009-11-16 Thread Goswin von Brederlow
Guillaume Yziquel writes: > Hello. > > I've been trying stuff like these: > >> # module type 'a A = sig >> Error: Parse error: [a_UIDENT] expected after "type" (in [str_item]) >> # module type ['a] A = sig >> Error: Parse error: [a_UIDENT] expected after "type" (in [str_item]) >> # module type A

Re: [Caml-list] New: cppo, C preprocessor for OCaml

2009-11-17 Thread Goswin von Brederlow
Martin Jambon writes: > Dear list, > > It is my pleasure to announce the first release of cppo, an OCaml-friendly > equivalent of the C preprocessor (cpp). > > Cppo provides the classic #include, #define and conditionals (#ifdef, ...) > which are occasionally useful. Cppo can be used on OCaml fi

Re: [Caml-list] Same name fields

2009-11-21 Thread Goswin von Brederlow
Mykola Stryebkov writes: > Hi, > > I'm trying to declare to record types with fields having the same name > but different types. > Something like this: > > > > type ta = { a : int; b : string } > type tb = { a : float; b : s

multicore wish [Was: Re: [Caml-list] Re: OCaml is broken]

2009-12-21 Thread Goswin von Brederlow
Jon Harrop writes: > We've discussed the problems with that before. Writing a parallel generic > quicksort seems to be a good test of a decent multicore capable language > implementation. Currently, F# is a *long* way ahead of everything open > source. How do you implement it? 1) divide at t

Re: [Caml-list] obj.magic for polymorphic record fields

2009-12-21 Thread Goswin von Brederlow
"Damien Guichard" writes: >> I once faced this situation and the solution is to use modules. > That is one good practical solution. > > The simpler solution that immediatly came to my mind is eta-expansion. > > type foo = {bar : 'a. 'a -> 'a} > let a : int -> int = fun x -> x > let baz = {b

[Caml-list] Re: multicore wish

2009-12-22 Thread Goswin von Brederlow
Jon Harrop writes: > Cilk pioneered wait-free work-stealing task deques and Microsoft's Task > Parallel Library (which will be part of .NET 4 in March 2010) copied the > idea. You have a separate deque of tasks for each core. A core tries to pop a > task off its deque. If there are no tasks on

Re: [Caml-list] obj.magic for polymorphic record fields

2009-12-22 Thread Goswin von Brederlow
Boris Yakobowski writes: > On Mon, Dec 21, 2009 at 2:44 PM, Goswin von Brederlow > wrote: >>> However it issues a warning so i acknowledge it's less elegant. >> >> Which I don't quite understand. > > The warning is based on the results of the type in

Re: [Caml-list] obj.magic for polymorphic record fields

2009-12-24 Thread Goswin von Brederlow
Boris Yakobowski writes: > On Tue, Dec 22, 2009 at 2:35 PM, Goswin von Brederlow > wrote: >> But the type inference should deduce that in >> >> (Obj.magic fn) x >> >> the 'a is actually 'b -> 'c as I am applying an argument to it. > &g

Re: [Caml-list] Re: multicore wish

2009-12-24 Thread Goswin von Brederlow
Jon Harrop writes: > On Tuesday 22 December 2009 18:02:32 Edgar Friendly wrote: >> On 12/22/2009 01:12 PM, Jon Harrop wrote: >> > On Tuesday 22 December 2009 13:09:27 Goswin von Brederlow wrote: >> >> The advantage with ocaml though is that you never have pointers

Re: [Caml-list] Re: multicore wish

2009-12-24 Thread Goswin von Brederlow
Jon Harrop writes: > On Tuesday 22 December 2009 13:09:27 Goswin von Brederlow wrote: >> Jon Harrop writes: >> > 1. The array "a" is just an ordinary array of any type of values on the >> > shared heap in F# but, for generality in OCaml, this must be both th

Re: [Caml-list] Re: multicore wish

2009-12-27 Thread Goswin von Brederlow
Jon Harrop writes: > On Thursday 24 December 2009 13:19:52 Goswin von Brederlow wrote: >> Jon Harrop writes: >> > No, in OCaml I fork every child. That is the only transparent way to give >> > the child a coherent view of the heap but it is extremely slow (~1ms): >

Re: [Caml-list] 2147483648l < 2147483647l

2010-01-19 Thread Goswin von Brederlow
"David Allsopp" writes: > Matej Kosik wrote: >> I am sorry, I have a stupid question. >> I would like to ask if this: >> >> # 2147483648l < 2147483647l;; >> - : bool = true > > The bug is in fact: > > # 2147483648l;; > - : int32 = -2147483648l > > and given that behaviour, the above re

Re: [Caml-list] Unable to reach fixpoint building ocaml 3.11.2 on cygwin

2010-01-26 Thread Goswin von Brederlow
Ed Keith writes: > I am trying to build ocaml 3.112 on cygwin. Make world seems to work fine, > but when I make bootstrap I do not get any errors, but I get the following > message: > > make[2]: warning: Clock skew detected. Your build may be incomplete. > make[2]: Leaving directory `/usr/src

Re: [Caml-list] Alignment of data

2010-01-27 Thread Goswin von Brederlow
Christophe Papazian writes: > Dear users and developers of OCAML, > > I am working on some ppc architecture, and I realize that I have a > (very) big slowdown due to bad alignment of data by ocamlopt. I need > to have my data aligned in memory depending of the size of the data : > floats are to b

Re: [Caml-list] Alignment of data

2010-01-27 Thread Goswin von Brederlow
Pascal Cuoq writes: > Goswin von Brederlow wrote: > > > You need to write a new function > > CAMLextern value caml_alloc_double_array (mlsize_t), > > or similar that ensures alignment on 8 byte for double even for 32bit > systems. > > You

Re: [Caml-list] Ocaml implementation and low level details

2010-01-28 Thread Goswin von Brederlow
Richard Jones writes: > On Thu, Jan 28, 2010 at 01:42:15PM +0100, Konstantin Tcholokachvili wrote: >> I am writing an operating system kernel and I am considering the idea of >> rewritting it in Ocaml or make a wrapper. >> As I don't know how Ocaml is implemented in detail so I have the followin

[Caml-list] Problem correlating input and output type

2010-01-31 Thread Goswin von Brederlow
Hi, last night I had a crazy idea for a better GUI framework. In a GUI you have objects that react to events (being clicked, being dragged, covered/uncovered, resized ...). Oftent basic objects (e.g. buttons) are then combined to build higher level objects (e.g. dialog boxes). Each object now has

Re: [Caml-list] Problem correlating input and output type

2010-02-01 Thread Goswin von Brederlow
Tiphaine Turpin writes: > Goswin von Brederlow a écrit : >> Hi, >> >> last night I had a crazy idea > Definitely :-). > >> [...] >> >> >> Can anyone think of a way to express this so that the type system keeps >> track of which callback

Re: [Caml-list] Re: Being aware of memory overuse

2010-02-10 Thread Goswin von Brederlow
Sylvain Le Gall writes: > On 05-02-2010, David Rajchenbach-Teller wrote: >>Dear list, >> I'm writing some code that needs to be able to cope nicely with >> memory exhaustion. That is, it should be able to detect at some point >> if it is getting close to exhausting memory, and take th

Re: [Caml-list] Preventing values from escaping a context

2010-02-10 Thread Goswin von Brederlow
Rich Neswold writes: > On Tue, Feb 9, 2010 at 12:45 PM, Tiphaine Turpin > wrote: > > Here is an adaptation of your example. > > > Thank you! I'll experiment with your example to see if I can use it (like you > said, it may be too complicated to add to the API.) Regardless, it was an > intere

Re: [Caml-list] Re: Being aware of memory overuse

2010-02-10 Thread Goswin von Brederlow
Dario Teixeira writes: > Hi, > >> I always wanted to have kernel spport for this. Some way for aplication >> to tell the kernel about freeable memory and for the kernel to request >> some memory to be freeed instead of swapping it out. > > If I recall correctly, there was an Lwn.net article repor

Re: [Caml-list] Preventing values from escaping a context

2010-02-10 Thread Goswin von Brederlow
Rich Neswold writes: > On Wed, Feb 10, 2010 at 2:55 AM, Goswin von Brederlow > wrote: > > Why not make the context a custom block with finalizer? The finalizer > then frees the resources. If the context escapes then it remains alive > and the finalizer will not

Re: [Caml-list] range of hash function

2010-02-20 Thread Goswin von Brederlow
Grégoire Seux writes: > hello ! > > i would like to use the polymorhpic hash function on strings. But i would like > to know what is the probability of a collision between two hashes.  > > my first question is about the range of the Hashtbl.hash function: what is its > range ? ( string -> [1..N

[Caml-list] Question about ocaml threads and TLS (on linux)

2010-02-24 Thread Goswin von Brederlow
Hi, I'm having a little problem for my libfuse-ocaml bindings for the threaded interface. For those that don't want to read all of the mail my question is: Will every ocaml thread have its own thread-local-storage in the C stubs? I have the following calling sequence: User ocaml code | Fuse

Re: [Caml-list] Question about ocaml threads and TLS (on linux)

2010-02-24 Thread Goswin von Brederlow
Philippe Wang writes: > Hi, > > I'm not sure I understand (though I've read the whole text), but maybe > this will answer your question: > On Linux, OCaml threads (with the native compiler "ocamlopt") are > implemented with POSIX threads (in C), so when your OCaml thread runs > the C stub, it's t

Re: [Caml-list] Recursive subtyping issue

2010-02-27 Thread Goswin von Brederlow
Guillaume Yziquel writes: > Andreas Rossberg a écrit : >> On Feb 27, 2010, at 02:52, Guillaume Yziquel wrote: >>> >>> I've been struggling to have a type system where I could do the >>> following subtyping: >>> >>> 'a t1 :> t2 and t2 :> 'a t1 >> >> Hm, what do you mean? Subtyping ought to be r

Re: [Caml-list] Recursive subtyping issue

2010-02-28 Thread Goswin von Brederlow
Guillaume Yziquel writes: > Goswin von Brederlow a écrit : >> Guillaume Yziquel writes: >> >>> My goal is to implement a type inference barrier. >>> >>> You can do >>> >>>> type 'a q = private w >>> and from the typ

Re: [Caml-list] How to pass C pointers to Caml

2010-03-01 Thread Goswin von Brederlow
Florent Monnier writes: > Le lundi 1 mars 2010 04:55:00, Jianzhou Zhao a écrit : >> I have been calling OCaml code from C in my project. >> The C code has some pointers to C structures. >> I got 'seg fault' when calling the OCaml function receiving >> C structure pointers. >> >> 18.7 at http://c

Re: [Caml-list] Recursive subtyping issue

2010-03-01 Thread Goswin von Brederlow
"David Allsopp" writes: > external foo_of_bar : bar -> foo = "%identity" > > in *both* the .ml and .mli file for the module in question. I'm virtually > certain that ocamlopt eliminates calls to the %identity primitive. Where is that documented? I would have written let foo_of_bar (x : bar) =

Re: [Caml-list] How to pass C pointers to Caml

2010-03-02 Thread Goswin von Brederlow
Florent Monnier writes: > Le lundi 1 mars 2010 14:24:45, Goswin von Brederlow a écrit : >> Florent Monnier writes: >> > Le lundi 1 mars 2010 04:55:00, Jianzhou Zhao a écrit : >> >> I have been calling OCaml code from C in my project. >> >> The C code

Re: [Caml-list] Recursive subtyping issue

2010-03-02 Thread Goswin von Brederlow
"David Allsopp" writes: > Goswin von Brederlow wrote: >> "David Allsopp" writes: >> >> > external foo_of_bar : bar -> foo = "%identity" >> > >> > in *both* the .ml and .mli file for the module in question. I'm &

Re: [Caml-list] How to pass C pointers to Caml

2010-03-03 Thread Goswin von Brederlow
Florent Monnier writes: > Le mardi 2 mars 2010 11:19:58, vous avez écrit : >> Florent Monnier writes: >> > Le lundi 1 mars 2010 14:24:45, Goswin von Brederlow a écrit : >> >> Florent Monnier writes: >> >> > Le lundi 1 mars 2010 04:55:00, Jianzho

  1   2   >