| Anonymous | Login | Signup for a new account | 2013-05-25 18:09 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||
| 0001696 | OCaml | Camlp4 | public | 2003-05-27 00:35 | 2010-04-29 14:31 | |||
| Reporter | frisch | |||||||
| Assigned To | ertai | |||||||
| Priority | normal | Severity | feature | Reproducibility | always | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | ||||||||
| Target Version | Fixed in Version | 3.11+dev | ||||||
| Summary | 0001696: feature-wish: camlp4 quotation | |||||||
| Description | Bonjour, Sauf erreur de ma part, il n'y a pas de moyen simple de passer des valeurs calculées à la compilation à un programme Caml. Typiquement, je veux faire qu'un module connaisse sa date de compilation, ou le compilateur utilisé (ocamlc ou ocamlopt). La solution de créer un fichier externe (genre utils/config.ml) n'est pas toujours agréable à mettre en oeuvre dans un Makefile (par exemple, pour savoir quel est le compilateur utilisé, car il faut regenerer le fichier entre un make et un make opt). Je propose la quotation camlp4 ci-dessous, qui permet de faire des choses du genre: -pp 'camlp4o q_symbol.cmo -symbol version=\"0.0.9\"' (pour les messages d'erreur, c'est plus joli que -pp 'sed ...') Je pense que ça aurait sa place dans le Camlp4 de la distribution d'OCaml. -- Alain ----- let symbols = ref [] let define s = let i = try String.index s '=' with Not_found -> failwith ("Invalid symbol definition :" ^ s) in symbols := (String.sub s 0 i, String.sub s (i + 1) (String.length s - i - 1)) :: !symbols let expr _ s = try List.assoc s !symbols with Not_found -> failwith ("No definition for symbol " ^ s) let _ = Quotation.add "symbol" (Quotation.ExStr expr); Pcaml.add_option "-symbol" (Arg.String define) "<symbol=value> Define a symbol" | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0004666) ertai (developer) 2008-10-06 10:04 |
Recent extensions of the camlp4 macro system (-D option) provides the same feature. Example: $ camlp4o -parser Camlp4MacroParser -DA=42 -str 'let x = A' let x = 42 # camlp4of is shorter $ camlp4of -DA='(1, "foo", '"'a'"', 3.4, [])' -str 'A' (1, "foo", 'a', 3.4, []) |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2005-11-18 10:13 | administrator | New Issue | |
| 2008-10-05 18:57 | ertai | Reporter | administrator => frisch |
| 2008-10-05 18:57 | ertai | Assigned To | => ertai |
| 2008-10-05 18:57 | ertai | Category | OCaml general => Camlp4 |
| 2008-10-05 18:57 | ertai | Description Updated | |
| 2008-10-06 10:04 | ertai | Note Added: 0004666 | |
| 2008-10-06 10:04 | ertai | Status | acknowledged => resolved |
| 2008-10-06 10:04 | ertai | Resolution | open => fixed |
| 2008-10-06 10:04 | ertai | Fixed in Version | => 3.11+dev |
| 2010-04-29 14:31 | xleroy | Status | resolved => closed |
| Copyright © 2000 - 2011 MantisBT Group |