Re: [Caml-list] Controlling module loading order.

2010-01-09 Thread Stéphane Glondu
Guillaume Yziquel a écrit :
 My question is: do I have to put a line like module X = OCamlR in
 quantmod.ml, [...]

Sounds good. But in case the compiler is too smart and discards this,
I'd rather export explicitly an initialization function (or some dummy
value to force the dependency order) in OCamlR and call it when needed.

 [...] is there a way to load OCamlR beforehand just by
 tweaking the build process, order of modules when linking, etc...

I wouldn't rely on this.


Cheers,

-- 
Stéphane

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


[Caml-list] [ANNOUNCE] OCaml Bitstring 2.0.2

2010-01-09 Thread Richard Jones

Bitstring is a syntax extension which adds Erlang-style bit matching
and construction to OCaml programs.  You can use this to efficiently
and safely parse communication protocols and binary file formats.

Bitstring handles integers, booleans, strings, sub-bitstrings, big-,
little- and native-endianness, signed and unsigned types,
variable-width fields, fields whose width depends on values in
previous fields, fields with arbitrary bit alignment, forward offsets,
when-clauses, checked expressions, security against buffer overflows
and DoS, and lots more.

Example:

  let bits = Bitstring.bitstring_of_file image.gif in
  bitmatch bits with
  | { (GIF87a|GIF89a) : 6*8 : string; (* GIF magic. *)
  width : 16 : littleendian;
  height : 16 : littleendian } -
  printf %s: GIF image is %d x %d pixels filename width height
  | { _ } -
  eprintf %s: Not a GIF image\n filename

The latest version is 2.0.2 which fixes a number of compilation
problems related to OCaml 3.11, and incorporates some unofficial
patches which were floating around.  (Note that bitstring 2.0.0 is
known to be broken on Debian).

  Home page:
http://code.google.com/p/bitstring/
  API documentation:
http://people.redhat.com/~rjones/bitstring/html/Bitstring.html

Rich.

-- 
Richard Jones
Red Hat

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] [ANNOUNCE] OCaml Bitstring 2.0.2

2010-01-09 Thread Matthieu Dubuget
For those who would want to use bitstring on mingw, I had it compiled ok 
with the following:

cp byteswap.in.h byteswap.h
sed -i -e 's/-Werror -fPIC//' Makefile.in
sed -i -e 's/open_in/open_in_bin/' pa_bitstring.ml 
create_test_pattern.ml bitstring_objinfo.ml

./configure CFLAGS=-mno-cygwin
make



The test target is also buggy on mingw.

But the library is working ok

Salutations

Matt



___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] memory profiling

2010-01-09 Thread Jon Harrop
On Tuesday 05 May 2009 13:45:18 dmitry grebeniuk wrote:
 2009/5/5 Christoph Bauer christoph.ba...@lmsintl.com:
  what is the best option to do memory profiling with ocaml?
  Is there a patch of ocaml-memprof for 3.11.0? What about
  objsize?

   If you want to use objsize with ocaml 3.11, you should get
 the new version of objsize -- 0.12:
 http://forge.ocamlcore.org/frs/?group_id=3
   OCaml has new heap since 3.11...

Can anyone elaborate on this?

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] memory profiling

2010-01-09 Thread Richard Jones
On Sat, Jan 09, 2010 at 01:25:52PM +, Jon Harrop wrote:
 On Tuesday 05 May 2009 13:45:18 dmitry grebeniuk wrote:
  2009/5/5 Christoph Bauer christoph.ba...@lmsintl.com:
   what is the best option to do memory profiling with ocaml?
   Is there a patch of ocaml-memprof for 3.11.0? What about
   objsize?
 
If you want to use objsize with ocaml 3.11, you should get
  the new version of objsize -- 0.12:
  http://forge.ocamlcore.org/frs/?group_id=3
OCaml has new heap since 3.11...
 
 Can anyone elaborate on this?

Not sure about new heap, but the way that heap pages are tracked
changed from 3.10 - 3.11.  In 3.10 a flat bitmap was used.  This was
unsuitable for 64 bit address spaces[1] and in 3.11 a sparse structure
is used (a hash table).

Rich.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=445545#c9

-- 
Richard Jones
Red Hat

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] problem creating .cma library

2010-01-09 Thread Richard Jones
On Sat, Jan 09, 2010 at 12:33:08PM +0100, Guillaume Yziquel wrote:
 David Allsopp a écrit :
 Guillaume Yziquel:
 
 So, no allocation of OCaml values (or in place modification, either, I
 guess) implies no need for CAMLparam/CAMLreturn stuff?
 
 Chapter 18 of the manual in Section 18.5 describes pretty much everything 
 you need to know about writing safe stubs that work with the garbage 
 collector.  
 
 Yes. It is all I need to know to write safe stubs. But it does not 
 answer the question above. It does state that you do not need 
 registration of the result value if there's no allocation going on 
 between the moment result get its value and the return statement. But it 
 does not say when you can avoid CAMLparam macros.

The basic problem is that whenever you do an allocation, the allocator
might need to run the garbage collector.  Allocations from the minor
heap are normally quick (just comparing and decrementing a pointer),
but once the minor heap runs out a minor heap collection has to be
done, and that implies a slice of major heap collection too.

Why is this a problem?  Because you might in your C code have some
value on the stack.  'value' is (or can be) a pointer.  The OCaml
garbage collector can move pointed-to-objects around, firstly from the
minor heap to the major heap, secondly when compacting the major heap.
So your C value (pointer) *could* become an invalid pointer if what it
was pointing to got moved.

The way to avoid this small chance is to register the value with the
garbage collector, which is essentially what the CAMLparam* and
CAMLlocal* macros do.  So if the GC needs to move that object, it will
update the pointer for you.

If your function never allocates (and never calls anything which
allocates), then you don't need to register values, because no
allocation = they can't be moved.  [In fact there are some other
exceptions as well where you can prove that an allocation won't move
your pointer, eg. if you only allocate one thing and immediately
return the value.]

However it's always safe to use the macros, even if you're not
allocating, albeit a tiny little bit slower.

You might find my series on the garbage collector interesting if you
want to look into this further:

http://rwmj.wordpress.com/?s=ocaml+internals

Also if you are calling C functions which don't allocate from OCaml
code, you might want to read about noalloc:

http://camltastic.blogspot.com/2008/08/tip-calling-c-functions-directly-with.html

 By the way, here's a question I've been wondering about this section. 
 Rule 3: When I have a Abstract_tag block used to wrap a pointer in the C 
 heap, it seems to me that you can just do it with a Field(v,0)= 
 assignment. Do you need Store_field for that?

This is to do with the Remembered Set.  See part 5 of the above
series.

Rich.

-- 
Richard Jones
Red Hat

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] problem creating .cma library

2010-01-09 Thread Daniel Bünzli
Section 2) of this paper also has a very gentle and readable
introduction to the gc :

http://portal.acm.org/citation.cfm?id=141130

Another thing you need to know, if you have long running pieces of C
code that don't interact with ocaml's runtime system, is the two
functions :

caml_enter_blocking_section
caml_leave_blocking_section

They are explained in this message  :

http://caml.inria.fr/pub/ml-archives/caml-list/2001/06/58d7a7e8747056c3842e53b4e9454f44.en.html

Best,

Daniel

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] problem creating .cma library

2010-01-09 Thread Daniel Bünzli
 http://portal.acm.org/citation.cfm?id=141130

http://portal.acm.org/citation.cfm?id=1411308

Sorry,

Daniel

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] problem creating .cma library

2010-01-09 Thread Joel Reymont

On Jan 9, 2010, at 2:02 PM, Daniel Bünzli wrote:

 http://portal.acm.org/citation.cfm?id=1411308

How can I access this paper without an ACM subscription?

Thanks, Joel

---
http://wagerlabs.com



___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


[Caml-list] ANN: UseOcaml.cmake script

2010-01-09 Thread Keyan
Hi,

i am not sure, if this is of interest here, but i give it a try. i use cmake 
heavily to compile my projects, so i wrote 
a UseOcaml.cmake script, adapted from UseLATEX.cmake, to do the job for me. it 
can be found here:

http://yars.svn.sourceforge.net/viewvc/yars/branches/yars-refactoring/modules/UseOcaml.cmake?revision=509view=markup

it is not complete yet, but it allows to easily compile ocaml-binaries in the 
following way:

  ADD_OCAML_TARGET(
  OUTPUTloc
  MAIN  loc.ml
  SOURCES   file_node.ml  files.ml  io.ml  file_statistics.ml  
message_node.ml
  HEADERS   file_node.mli files.mli io.mli file_statistics.mli 
message_node.mli
  LIBRARIES unix.cmxa str.cmxa extLib.cmxa
  INCLUDES  /opt/local/lib/ocaml/site-lib/extlib
  )

one current problem is that i cannot add multiple entries to the INCLUDES.

i am happy to receive comments.

cheers,
keyan
___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


Re: [Caml-list] problem creating .cma library

2010-01-09 Thread Guillaume Yziquel

Daniel Bünzli a écrit :

Section 2) of this paper also has a very gentle and readable
introduction to the gc :

http://portal.acm.org/citation.cfm?id=141130


Thanks for the link.


Another thing you need to know, if you have long running pieces of C
code that don't interact with ocaml's runtime system, is the two
functions :

caml_enter_blocking_section
caml_leave_blocking_section

They are explained in this message  :

http://caml.inria.fr/pub/ml-archives/caml-list/2001/06/58d7a7e8747056c3842e53b4e9454f44.en.html


OK.

So if I want to call R code that multithreads with OCaml, I should write 
something like



  enter_blocking_section();
  PROTECT(e = R_tryEval(Sexp_val(sexp_list), R_GlobalEnv, error));
  UNPROTECT(1);
  leave_blocking_section();


Am I correct?

--
 Guillaume Yziquel
http://yziquel.homelinux.org/

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


[Caml-list] CFP - ICLP 2010 - DEADLINE: Jan 26

2010-01-09 Thread iclp2010-announce

  [Apologies in case of receiving multiple copies.]
--
   CALL FOR PAPERS
26th International Conference on Logic Programming (ICLP 2010)
   Theory and Practice of Logic Programming
  
 Edinburgh, Scotland, U.K., July 16-19, 2010
ICLP 2010 will be held as part of the
 Fifth Federated Logic Conference (FLoC 2010)

 Submission deadline: ** January 26, 2010 ***

http://www.floc-conference.org/ICLP-home.html
--

CONFERENCE SCOPE

Since the first  conference held in Marseilles in  1982, ICLP has been
the premier international conference  for presenting research in logic
programming.  Contributions (papers  and  posters) are  sought in  all
areas of logic programming including but not restricted to:

Theory:  Semantic  Foundations,  Formalisms, Non-monotonic  Reasoning,
Knowledge Representation.
Implementation:  Compilation,  Memory  Management,  Virtual  Machines,
Parallelism.
Environments:ProgramAnalysis,   Transformation,Validation,
Verification, Debugging, Profiling, Testing.
Language Issues: Concurrency,  Objects, Coordination, Mobility, Higher
Order, Types, Modes, Assertions, Programming Techniques.
Related  Paradigms:  Abductive   Logic  Programming,  Inductive  Logic
Programming, Constraint Logic Programming, Answer-Set Programming.
Applications:  Databases, Data  Integration  and Federation,  Software
Engineering,  Natural Language Processing,  Web and  Semantic Web,
Agents, Artificial Intelligence, Bioinformatics.

In  addition to the  presentations of  accepted papers,  the technical
program will  include plenary invited talks in  association with other
FLoC conferences,  as well as ICLP invited  talks, advanced tutorials,
the doctoral consortium, and several workshops.

SUBMISSION DETAILS

The four  broad categories for  submissions are: (1)  technical papers
for describing  technically sound,  innovative ideas that  can advance
the state  of the  art of logic  programming; (2)  application papers,
where the emphasis will be  on their impact on the application domain;
(3) system and tool papers, where the emphasis will be on the novelty,
practicality, usability  and general  availability of the  systems and
tools described;  and (4) short  papers/posters, for ongoing  work not
yet ready for full publication and research project overviews.

All   papers  must   describe  original,   previously  unpublished
research,  and must  not simultaneously  be submitted  for publication
elsewhere.   They  must  be  written in  English.   Technical  papers,
application  papers, and  system and  tool papers  must not  exceed 15
pages. The  limit for short papers  / posters is  5 pages. Submissions
must  be made  in  TPLP format
(ftp://ftp.cup.cam.ac.uk/pub/texarchive/journals/latex/tlp-cls/)   via
the  Easychair  submission  system,  available  at
http://www.easychair.org/conferences/?conf=iclp2010

IMPORTANT DATES
 Paper registration deadline:  January 26, 2010
 Submission deadline:  February 2, 2010
 Notification to authors:  March   20, 2010
 Camera-ready copy due:April   21, 2010
 Conference:   July 16-19, 2010

PAPER PUBLICATION

All accepted long  papers will be published in  the journal Theory and
Practice of Logic Programming (TPLP), Cambridge U. Press (CUP), in one
or more special issues.

In order to ensure the quality of the final version, papers may be
subject  to more  than one  round of  refereeing (within  the decision
period) and/or shepherding.

At  the time  of the  conference CUP  will make  the web  page for
this(ese) TPLP issue(s) available  including volume and issue numbers,
table  of  contents, page  numbers,  and  the  papers themselves.  All
registered  attendants  at the  conference  will  get  a password  for
on-line access to this web page during the conference and indefinitely
from then on (lifetime access), which  can be used to read papers on
line, download them,  or print them for personal  use. Attendants will
also receive all the papers in a USB memory stick at the conference.

For short  papers /  posters the journal  issue(s) will  include a
listing of  the titles and authors of  these papers, as well  as a URL
pointing to their printable copy. Short papers / posters will also get
space in the program for presentation.

ICLP'2010 ORGANIZATION

General Chair:
Veronica Dahl(Simon Fraser University, Canada)
Program Co-chairs:
Manuel Hermenegildo   (IMDEA Soft. and UPM, Spain)
Torsten Schaub(University of Potsdam, Germany)
Workshops Chair:
Veronica Dahl(Simon Fraser University, 

Re: [Caml-list] problem creating .cma library

2010-01-09 Thread Daniel Bünzli
 So if I want to call R code that multithreads with OCaml, I should write
 something like

  enter_blocking_section();
  PROTECT(e = R_tryEval(Sexp_val(sexp_list), R_GlobalEnv, error));
  UNPROTECT(1);
  leave_blocking_section();

 Am I correct?

Yes, but the functions have now a caml_ prefix.

Make sure that there is no interaction whatsoever with ocaml's runtime
system (e.g. ocaml value allocation) between the two calls.

Note also that in case you need to use some caml value after the leave
call you have to declare it with a CAMLparam macro as it may move
during the blocking section even if the stub itself doesn't allocate.

Best,

Daniel

___
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs