caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Conditional compilation wrt OCaml version?
@ 2009-01-26 21:25 David Rajchenbach-Teller
  2009-01-26 21:40 ` Sylvain Le Gall
  2009-01-26 22:58 ` [Caml-list] " Mikkel Fahnøe Jørgensen
  0 siblings, 2 replies; 6+ messages in thread
From: David Rajchenbach-Teller @ 2009-01-26 21:25 UTC (permalink / raw)
  To: OCaml

      Dear list,

  Working on Batteries, we're faced with a few places where we'd like to
perform conditional compilation depending on the version of OCaml being
used. We could probably do this with Camlp4, cpp, Autoconf hackery, etc.
-- but first, we need to decide on which of these options we'll adopt.

Any suggestion?

Thanks in advance,
 David

-- 
David Teller-Rajchenbach
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
   La Recherche publique est liquidée. Les chercheurs sont en colère.
   Latest News of French Research: System being liquidated. Researchers angry.


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

* Re: Conditional compilation wrt OCaml version?
  2009-01-26 21:25 Conditional compilation wrt OCaml version? David Rajchenbach-Teller
@ 2009-01-26 21:40 ` Sylvain Le Gall
  2009-01-29  8:43   ` Ocamlopt+macros, caching MetaOcaml code. Was: " Jan Kybic
  2009-01-29  9:21   ` [Caml-list] " David Rajchenbach-Teller
  2009-01-26 22:58 ` [Caml-list] " Mikkel Fahnøe Jørgensen
  1 sibling, 2 replies; 6+ messages in thread
From: Sylvain Le Gall @ 2009-01-26 21:40 UTC (permalink / raw)
  To: caml-list

On 26-01-2009, David Rajchenbach-Teller <David.Teller@ens-lyon.org> wrote:
>       Dear list,
>
>   Working on Batteries, we're faced with a few places where we'd like to
> perform conditional compilation depending on the version of OCaml being
> used. We could probably do this with Camlp4, cpp, Autoconf hackery, etc.
> -- but first, we need to decide on which of these options we'll adopt.
>
> Any suggestion?
>

There is optcomp:
https://forge.ocamlcore.org/projects/optcomp/
http://darcs.ocamlcore.org/repos/optcomp/optcomp/README

The example in README should talk to you directly.

Regards,
Sylvain Le Gall


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

* Re: [Caml-list] Conditional compilation wrt OCaml version?
  2009-01-26 21:25 Conditional compilation wrt OCaml version? David Rajchenbach-Teller
  2009-01-26 21:40 ` Sylvain Le Gall
@ 2009-01-26 22:58 ` Mikkel Fahnøe Jørgensen
  1 sibling, 0 replies; 6+ messages in thread
From: Mikkel Fahnøe Jørgensen @ 2009-01-26 22:58 UTC (permalink / raw)
  To: David Rajchenbach-Teller; +Cc: OCaml

>  Working on Batteries, we're faced with a few places where we'd like to
> perform conditional compilation depending on the version of OCaml being
> used. We could probably do this with Camlp4, cpp, Autoconf hackery, etc.
> -- but first, we need to decide on which of these options we'll adopt.
>
> Any suggestion?

If you are interested in using ocamlbuild you can have a look at
ocamlbuild-ctools:

http://dvide.com/labs/ocamlbuild-ctools/

I added extensions to ocamlbuild using a syntax like

normalfile.o
[mytag,myothertag,~notthistag]
conditionalfile.o
...

this is done in a .cprog file that lists all files to include, but
that same could be done with other similar files e.g. .mllib

Also, I added multi-variant builds so the same build can handle
multiple build targets based on tags - for example debug and release
builds. Multivariant builds work by adding tags in the filename:
myfile.variant_release,mingw.o


Most of this could be integrated into ocamlbuild, but ocamlbuild is
not very actively maintained as I understand.

Mikkel


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

* Ocamlopt+macros, caching MetaOcaml code. Was: Conditional compilation wrt OCaml version?
  2009-01-26 21:40 ` Sylvain Le Gall
@ 2009-01-29  8:43   ` Jan Kybic
  2009-01-29 13:00     ` [Caml-list] " Jérémie Dimino
  2009-01-29  9:21   ` [Caml-list] " David Rajchenbach-Teller
  1 sibling, 1 reply; 6+ messages in thread
From: Jan Kybic @ 2009-01-29  8:43 UTC (permalink / raw)
  To: caml-list

>>   Working on Batteries, we're faced with a few places where we'd like to
>> perform conditional compilation depending on the version of OCaml being
>> used. We could probably do this with Camlp4, cpp, Autoconf hackery, etc.
>> -- but first, we need to decide on which of these options we'll adopt.
>>
>
> There is optcomp:
> https://forge.ocamlcore.org/projects/optcomp/
> http://darcs.ocamlcore.org/repos/optcomp/optcomp/README
>

Good morning. I have looked at ocamlopt and it looks very useful. 
Are there any plans to include macro expansion in ocamlopt?
I mean something like merging the functionality of ocamlopt and
pa_macro but without the restrictions that pa_macro places on 
where the macro can be used.

Besides conditional compilation - to try different variants of the
code or to have debugging messages which can be switched off without
any performance penalty - I would also like to use it for short pieces
of compile-time generated code (for speed up). Currently, I use a
Python-based templating system em.py
(http://www.alcyone.com/pyos/empy/) for this purpose. This works but
combining the way Python and Ocaml syntax is sometimes not very
intuitive.

It appears that a modern and universal tool for compile-time code
generation is MetaOcaml. However, is there a way in MetaOcaml to
generate the code just once and not every time the program is run? I
mean, can the code fragments be cached - saved into a file (a shared library?)
and later retrieved?

Thanks,

Jan

-- 
-------------------------------------------------------------------------
Jan Kybic <kybic@fel.cvut.cz>                       tel. +420 2 2435 5721
http://cmp.felk.cvut.cz/~kybic                      ICQ 200569450


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

* Re: [Caml-list] Re: Conditional compilation wrt OCaml version?
  2009-01-26 21:40 ` Sylvain Le Gall
  2009-01-29  8:43   ` Ocamlopt+macros, caching MetaOcaml code. Was: " Jan Kybic
@ 2009-01-29  9:21   ` David Rajchenbach-Teller
  1 sibling, 0 replies; 6+ messages in thread
From: David Rajchenbach-Teller @ 2009-01-29  9:21 UTC (permalink / raw)
  To: Sylvain Le Gall; +Cc: caml-list

Exactly what I needed.

Thanks,
 David

On Mon, 2009-01-26 at 21:40 +0000, Sylvain Le Gall wrote:

> There is optcomp:
> https://forge.ocamlcore.org/projects/optcomp/
> http://darcs.ocamlcore.org/repos/optcomp/optcomp/README
> 
> The example in README should talk to you directly.

-- 
David Teller-Rajchenbach
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
   La Recherche publique est liquidée. Les chercheurs sont en colère.
   Latest News of French Research: System being liquidated. Researchers angry.


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

* Re: [Caml-list] Ocamlopt+macros, caching MetaOcaml code. Was: Conditional compilation wrt OCaml version?
  2009-01-29  8:43   ` Ocamlopt+macros, caching MetaOcaml code. Was: " Jan Kybic
@ 2009-01-29 13:00     ` Jérémie Dimino
  0 siblings, 0 replies; 6+ messages in thread
From: Jérémie Dimino @ 2009-01-29 13:00 UTC (permalink / raw)
  To: Jan Kybic; +Cc: caml-list


Jan Kybic <kybic@fel.cvut.cz> writes:

> Good morning. I have looked at ocamlopt and it looks very useful. 
> Are there any plans to include macro expansion in ocamlopt?

Right now there is no plan for that. My only intention when i started
optcomp was conditional compilation, and i made choices making it
incompatible with macro expansion.

By the way, it would be easy to transform it into a macro expansion
system.

> I mean something like merging the functionality of ocamlopt and
> pa_macro but without the restrictions that pa_macro places on 
> where the macro can be used.

Yes, these restrictions could be bypassed because it modify directly the
stream of tokens.

The disadvantage of dealing with macros is for expressions needing to be
evaluated at compile time. For example in that case, assuming the
variable "x" is not defined:

,----
| #let y = x
|
| #if y
| ...
| #endif
`----

the error would be raised at the "#if y" line. Whereas it is raised at
the "#let y = x" line with optcomp. That is mostly why i decided not to
design it as a macro expansion system.

Jérémie


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

end of thread, other threads:[~2009-01-29 13:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-26 21:25 Conditional compilation wrt OCaml version? David Rajchenbach-Teller
2009-01-26 21:40 ` Sylvain Le Gall
2009-01-29  8:43   ` Ocamlopt+macros, caching MetaOcaml code. Was: " Jan Kybic
2009-01-29 13:00     ` [Caml-list] " Jérémie Dimino
2009-01-29  9:21   ` [Caml-list] " David Rajchenbach-Teller
2009-01-26 22:58 ` [Caml-list] " Mikkel Fahnøe Jørgensen

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