<thelema>
so you have the toplevel linked into your camlp4 driver? Can this be packaged separately for other projects to use?
<hongboz>
more convenient since I can still use camlp4 syntax extension is reflexitive
<hongboz>
hey, I workaround it by static linking the toplevel, the ugly bits is I wrote my own camlp4 driver, so no dynamic link required, now I can do compile-time evaluation. beautiful :-)
<adrien>
avsm: yup, I've actually stopped using camlp4 in yypkg for the type-conv+sexplib stuff because it was really slower
<avsm>
the big (4x) difference is native camlp4 vs bytecode
2012-07-07
<ssbr>
anyway I still don't really know how to write a lexer for camlp4. Is there something I should read?
<ssbr>
the issue is that I don't really know what lexers in camlp4 are like. The tutorial basically says, "just edit the ocaml lexer", and the manual says gibberish
<ssbr>
writing camlp4 lexers with ocamllex -- good idea?
<avsm>
and the codebases are really large, with lots of camlp4
<hongboz>
I improved camlp4 a bit, the delimeter is <<a a>>
<hongboz>
It's necessary indeed, since camlp4 depends on the link order
<hongboz>
avsm: camlp4 using .cmxs is pretty fast
<avsm>
it still does; the tooling around it hasnt kept up. ocamlbuild + ocamlopt.opt is pretty good, but then if you use bytecode camlp4 it slows right down again
2012-07-04
<thelema_>
as far as I can tell, there's no way to have `-package foo` turn camlp4 pre-processing on.
<thelema_>
vext01: you may need `-syntax camlp4o` as well for ocamlfind to engage camlp4 mode
<wieczyk>
Hi, could someone help how to compile automli (It cannot find MLast module, it looks like it was some old module in old camlp4) or give me a tool which generates MLI from ML?
2012-06-24
<adrien>
one reason is that I use it on windows and camlp4 has some issues there so it's better to just avoid the dependency completely
2012-06-18
<mfp>
right, but it's very nice to use them where supported. camlp4 is already taking most of the compilation time :-| (hoping syntax extensions shipped as .cxms become more common)
<mfp>
The first thing that comes to mind is very very mundane and basic: pretty-printing. There are many tools that solve it (sexplib, deriving...), but at the end of the day I code it manually because adding camlp4 to the building process is always a bother.
<hongboz>
mfp: sure, I would rewrite gen_plugin in original syntax. for plugin writers, they don't need to understand too much about camlp4, I think it's doable
<mfp>
as for me, I can read and write it (when needed for camlp4 quotations, those in original syntax are too buggy), but favor the original one
<hongboz>
I try to derive all the boilerpolate code for the ocaml compiler and camlp4 itself
2012-06-16
<wmeyer>
or even a camlp4 compiler
2012-06-14
<hcarty>
We have camlp4-less syntax extensions/AST transformations in trunk... nifty
2012-06-11
<thelema>
orbitz: yes, one needs to be careful combining camlp4
2012-06-10
<orbitz>
Does one need to be careful when combining multiple camlp4 macros?
<wmeyer```>
orbitz: yes, you can have several Camlp4 syntax extensions stacked
<orbitz>
Hrm, would be ab intersting time to learn camlp4
<wmeyer```>
you can always write your own camlp4 magic based on the lwt extension, should not be difficult - I am surprised nobody has done that before
<orbitz>
Only downside is possibly performance, and no pretty lwt camlp4 magic
2012-06-08
<wmeyer``>
yes, mikmatch is for camlp4
<ssbr>
does camlp4 let you rewrite function calls in the lisp stype?
<wmeyer``>
phao: that's why Camlp4 is much less powerful than classical Lisp macros - and much more complicated - because it's very hard to do
2012-06-07
<ssbr>
this is apparently bad enough to break error reporting in camlp4. Woooooo.
2012-06-05
<thelema_>
yes, you could do this with camlp4, camlp5, although they're both unnecessarily complex for this kind of task
2012-06-04
<wmeyer>
i will try to do the camlp4 part for time being
<wmeyer>
I could possibly add the camlp4 bits & pieces if you need some help
<pippijn>
can I use a menhir parser with camlp4?
<wmeyer>
are you doing C quotes in Camlp4
<wmeyer>
pippijn: no, it;s fine, i do the same thing too - but today i looked what camlp4 can offer me
<pippijn>
I like how type inference enables the existence of camlp4
<Drakken>
The only thing I know about printing camlp4 data is that you can print a grammar like this:
<ssbr_>
I don't have the camlp4 source code
<Drakken>
camlp4 usually takes .cmo files as grammar extensions.
<Drakken>
ssbr_ have you tried running camlp4 on the command line and looking at the output code?
<ssbr_>
How should I find out how camlp4 lexes a string?
2012-06-02
<wmeyer`>
ssbr_: camlp4 is damn useful
<ssbr_>
camlp4 isn't that bad... just annoying.
<wmeyer`>
ssbr_: Maybe they are enjoying feeling of dreaming - and don't want to destroy it by the camlp4 hell
<ssbr_>
"It is not necessary to use Camlp4’s parsing facilities in order to implement quotations—ultimately we will need to provide just a function from strings to ASTs, so we could use ocamlyacc or what-have-you instead—but it is convenient."
<wmeyer`>
it's very cool series about camlp4
2012-06-01
<wmeyer`>
ssbr_: because lexers are not extensible in Camlp4
<wmeyer`>
ssbr_: yes, of course Camlp4 is not lexerless
<ssbr_>
hmmm, there is apparently a difference between ".";"b";"d";...;"r" and ".bddvarorder" in camlp4
<wmeyer`>
one the code generation side of camlp4 - i can say it's damn useful
<wmeyer`>
the beautiful thing about camlp4 is that allows you to implement quotations or/and extend the existing grammar, and also because it has already a decent lexer
<wmeyer`>
i tend to just use camlp4 in the begining, trying very hard
<wmeyer`>
ssbr_: should i encourage you to become a daily camlp4 hacker?
<wmeyer`>
ssbr_: don't worry will bump into this issues quite often with camlp4
* wmeyer`
being emotional with camlp4 parsers
<wmeyer`>
the thing that bothers me - is that i don't understand how the camlp4 parsers work
<wmeyer`>
ssbr_: the inline rules for Camlp4 parsers are maybe the best thing there ;-)
<Drakken>
Camlp4: Uncaught exception: DynLoader.Error ("./_build/MetlString.cmo", "interface mismatch on Metl")
<Drakken>
How do you debug "interface mismatch" bugs in camlp4?
2012-05-31
<Drakken>
ski It doesn't really have to be a function. the outer variant type is a syntax tree and the inner type is the terminals. I just need to extend a camlp4 grammar entry to return values of the inner type to be used as leaf nodes in the ast.
2012-05-28
<wmeyer``>
adrien: Common Lisp style macros beat down Camlp4 hard in terms how easy is to use them and how powerful they are. CPP is fine for the most simpliest cases
<wmeyer``>
adrien: that begs a question, maybe Camlp4 is too complicated for factoring these tasks - complicated to setup etc. not everything can be factored - e.g. variadic functions needs macro support
<flux>
that's what some camlp4 extensions do as well
2012-05-23
<adrien>
pre-processing, not in the language (like in C's case actually): there's camlp4 and a number of existing syntax extensions for it
2012-05-22
<mfp>
batteries used to do that with camlp4
<wmeyer``>
and camlp4 goes mad
<ssbr>
camlp4 always lets me down :<
<wmeyer``>
ssbr: Camlp4 let me down again :(
2012-05-19
<wmeyer>
I'm going to file a bug - it looks like the problem is with marshaling on camlp4 side, when pretty printed, even to the output file it works like a charm
<wmeyer>
I have some weird problem, when I use camlp4of and preprocess my DSL I can compile the resulting file. However, when using -pp flag, and camlp4 pipe marshaled AST to ocamlc it fails badly
<wmeyer>
did anybody generate declaration polymorphic variant type through Camlp4?
<flux>
ocamlbuild is possibly one of the more annoying tools in ocaml, possibly neck-to-neck with camlp4. both that could be fixed by excellent documentation.
2012-05-14
<thelema>
you want to treat "A" as camlp4 code? I think you'll have to work much harder
<thelema>
sorry, my camlp4-fu is weak
2012-05-12
<wmeyer>
pippijn: I was duing some weired building of ml trhough camlp4 (as a target) and js with symlinking
2012-05-11
<wmeyer>
From other things I would like to see in Camlp4 is sort of type reflection. I want to know the environment during expansion.
<wmeyer>
@ARM I had generated 200KLOC of ML using Menhir and Camlp4 and it was quite pleasant. From the other drawbacks I see is that the Camlp4 are not recursive, expand the rules until fixpoint is reached - this is how the Lisp macros work, and in this regard it's weaker paradigm.
<wmeyer>
I had similar problems with Camlp4, it's a very powerful tool for code generation and it's easy to extend Caml grammar. However, if you want more ambigous grammars and custom lexer not extending the language I would really advice on Menhir, Dypgen, parsing combinator library like Planck or one of the packrat implementations. Still however you can generate code through Camlp4, it's just you will not be able to extend existing O
<ssbr_>
I'd really like some way to define rules that aren't quite rules, so that camlp4 can still do its magic LL(1) factorization stuff across them
<Drakken>
ssbr_ are you still working on that camlp4 prob?
<hcarty>
mrvn: There are a few logging modules that have camlp4 support. I think Lwt's logging module supports this (and requires that you use Lwt). Bolt does as well - http://forge.ocamlcore.org/projects/bolt/
2012-05-10
<ssbr_>
oh, maybe I can hack around this using a first required thing and then LIST0? I assume it's LIST1 that's confusing camlp4
<ssbr_>
I'm having trouble dealing with the grammar of things that can be of the form "Foo(a:b)" versus "Foo(a).". camlp4 complains that it was expecting a ":" in the latter case, whereas I want it to realize that if it encounters a ')' (or ','), then things are of the second form, not the first
<ssbr_>
blagagh. Is this the place to ask about camlp4 stuff?
<mrvn>
Maybe I should learn camlp4 for that. It could remove the debug statements at compile time depending on the level.
<ssbr_>
In camlp4, would "LIST1 [k = relat -> k]" be equivalent to "LIST1 relat", or else, what does that "[k = relat -> k]" mean?
<ssbr_>
the camlp4 docs aren't actually that bad. I was linked to a wiki that was supposed to be better, but often it just repeated what the official tutorial said, in unreadable contextless bullet-point form...
2012-05-09
<mrvn>
ssbr_: camlp4 works in memory
<thelema>
ssbr_: ml files on disk are generally pre-camlp4 modification
<ssbr_>
ARGH. OK -- how do I tell if a .ml file is generated by a camlp4 thing?
<thelema>
ssbr_: camlp4 docs are crap, you may have to reverse engineer existing parsers
<ssbr_>
Would anyone recommend a source for learning camlp4?
2012-05-08
<avsm>
so, just to confirm, it's not possible to build a camlp4 extension, and then invoke it on an executable compile?
<avsm>
packaging a camlp4 extension
<hcarty>
joelr: Deriving may provide something like that. You would need to use something camlp4-based.
<thelema>
camlp4 can't get at types
<mrvn>
I wonder how much camlp4 magic it would need together with GADTs to implement it without compiler changes.
<thelema>
but maybe core will not drop camlp4
<hcarty>
But that's a lot of hand-coded (de)serialization to write if they are removing camlp4
<thelema>
I've heard a rumor that core may shed camlp4 in its core. That said, I can't figure out how to do that - adding sexplib to modules that don't have it?
<hcarty>
thelema: And it seems (seemed?) to break often, probably due to the camlp4 complexities involved.
<thelema>
There's a number of nice features of parameterless variants that could be built into OCaml, but probably never will be because they could be done in camlp4
<hcarty>
pippijn: ciml provides some camlp4 magic to make writing bindings a bit cleaner. camlidl automates part of the process if header files are setup properly. swig can produce ugly bindings.
2012-05-07
<mrvn>
What does one need compiler-libs for? camlp4?
<Drakken>
How are you supposed to feed object files for syntax extensions to camlp4 when you use it as a -pp preprocessor to ocamlc?
2012-04-14
<mrvn>
or some camlp4 and GADT magic.
2012-04-05
<thelema>
Lor: ocaml sadly lacks features to do this in the "right" way. One can use camlp4 to generate code to do this, but all arguments to functions will be evaluated.
<Drakken>
In a camlp4 syntax extension, does anyone know how to splice a list of nodes into the middle of a surrounding list? It would be equivalent to the @(...) syntax in Lisp macros.
2012-03-16
<Drakken>
Where is the best place to ask advanced camlp4 questions? I've aske a couple here, but I've never gotten an answer.
2012-03-15
<Drakken>
Is there a way to insert program logic into a camlp4 grammar entry that dynamically affects how a symbol matches? The manual says the section after the arrow is an "action", so I suppose code may be allowed there, but what about the symbols to the left of the arrow?
2012-03-13
<f[x]>
probst, ocamlbuild file.pp.ml to see what camlp4 generates
<mrvn>
The question is wether you haver some camlp4 extension or extra flags that screw with the syntax
2012-03-10
<Drakken>
Where is it specified what camlp4 does with BLANK and NEWLINE tokens?
2012-03-08
<Drakken>
What do I do after I've defined my camlp4 syntax extensions? Do I have to write out the file-handling code for my parser program by hand?
2012-03-01
<thelema>
hmm, probably not as builtin as the usual camlp4 call methods
<thelema>
I avoid camlp4 in my projects, so I'm not so sure
2012-02-28
<pippijn>
(without camlp4)
<adrien>
I think camlp4 parsing would help: warnings don't help for syntax errors
2012-02-25
<flux>
[moviuro], it appears to depend on camlp4 which isn't installed (does 'camlp4' work?). that should definitely be a package in your distribution, if ocaml is. (ocaml comes with camlp4, but at times it's packaged separately)
2012-02-23
<flux>
no, because it doesn't have the correct precedency and $ is used by camlp4 for something
2012-02-19
<rwmjones>
it's written 'in' camlp4
2012-02-18
<adrien>
I don't think anyone wants to remove camlp4 but having the option to build it or not is a good thing
<oriba>
adrien, why is skipping camöp4 compilation an advantage? Isn't it a good idea to have camlp4 available too?
<adrien>
camlp4 can now be skipped wehen building ocaml
2012-02-15
<adrien>
there was a library for a parser based on camlp4; anyone remember the name/link
2012-02-14
* rwmjones
works out how to "lift" an OCaml expression in camlp4
<rwmjones>
grrr camlp4
2012-02-11
<zorun>
I've never used camlp4, sorry
<dsheets>
hmm why would a camlp4 label not consume through an underscore?
2012-02-09
<bnwr>
Drakken: if you want getters generated for fields of records, use camlp4
<adrien>
typically, a camlp4 extension could however
2012-02-08
<bnwr>
Ptival: maybe you can pipe your code into camlp4
<yezariaely>
It works now, I was missing camlp4-extra
<thelema>
MaskRay: or look into it and the battop.ml for how to load batteries' camlp4 modules
2012-02-07
<adrien>
so, I had a syntax error when I was not using camlp4 on a file
2012-02-04
<thelema>
bobry: camlp4 hasn't changed significantly (just bugfixes, iirc) from 3.10 to 3.12
<bobry>
I wonder if a manual for camlp4 3.12 even exists? the only one i've googled is for 3.07, anyone?
<tomprince>
Doesn't camlp4 change the syntax more than just allowing syntax extensions? At least by default.
<adrien>
I really only get a syntax error when not using camlp4 on that file
<adrien>
but I don't understand why this line seems to require camlp4... { metadata_of_sexp sexp with size_expanded = pkg_size }
<adrien>
I would preprocess on linux, commit to a git branch, and pull on windows; it has been working quite well but I only have one file which uses camlp4 and the "with sexp" syntax so I figured I could as well remove camlp4 use altogether
<thelema>
I'm still not convinced it's worth the hassle of camlp4
<thelema>
adrien: I avoid camlp4 on all platforms
* adrien
curses at the fact that it's a good idea to avoid camlp4 on windows
2012-02-01
<adrien>
MaskRay: it also has to do with me not knowing which exact package you wanted to use and not being terribly used to camlp4
<dsheets>
what does lwt_log do that is better/worse than a camlp4 logger?
<avsm>
gildor: or anyone else, around? I'm wondering how to get an _oasis Document section to pass a -syntax option (to use camlp4 Lwt) to the ocamldoc invocation
2011-12-29
<thelema>
rwmjones: sorry about that. the having to work with camlp4 part.
* rwmjones
is working on a large (and secret, but may be public soon) camlp4 project now
<Drakken>
Why is ocamlc reporting type errors and unknown functions as "syntax" errors when I'm not explicitly using camlp4?
2011-12-19
<thelema_>
Kakadu: You could write a syntax extension in camlp4
<hcarty>
Kakadu: If you use camlp4 you'll get a more informative error
2011-12-11
<gasche>
plus you don't want to try to combine camlp4 and ocamldoc, you really don't
<gasche>
all things camlp4-related make deployment and adoption difficult
<gasche>
ocaml parses the original syntax; there is no support for revised syntax outside camlp4
<gasche>
now, sgnb certainly isn't pushing camlp4-out-of-ocaml as a way to *deprecate* it
<edwin>
so that means camlp4 will still have to be maintained for some time, until the transition is made
<edwin>
just dropping camlp4 and forcing everyone to move to a new way of doing things, without even knowing if its possible is not very useful
<gasche>
but edwin, I don't claim that *all* current uses of camlp4 would be expressible with those lighter extension points
<edwin>
well as long as your proposal can implement the popular camlp4 extension I'm happy
<gasche>
you are suggesting to rewrite camlp4 in a less fragile way; what Alain and Gerd (and I) suggest is to drop the idea of ocaml syntax extensibility altogether
<edwin>
then camlp4 syntax extensions would be dypgen grammar extensions, but again converting the yacc grammar is not trivial
<gasche>
I could understand the idea of "when the yacc grammar fail, call camlp4 independently to get a better error message and display it if <some heuristic> finds it legit"
<edwin>
of course that'd make camlp4 maybe a dynlinked module, and not a separate tool
<edwin>
hmm, how about adding some error tokens to the yacc grammar, and making it call out to camlp4 only in that case, see if camlp4 can parse a terminal, and then continue with its own parsing?
<gasche>
plus there is the fact that camlp4's ocaml grammar is built as a diff on top of the camlp4 revised grammar
<gasche>
I don't know if anyone besides Daniel knows of camlp4 semantics; I don't think converting the yacc grammar in a trivial way would preserve the properties
<sgnb>
(I mean, about using only camlp4 for parsing)
<edwin>
I guess automatically converting the yacc grammar to camlp4's internal one is out of the question?
<gasche>
also, from what I heard, changing camlp4 to accomodate new language changes is not at all trivial
<gasche>
I agree with you that camlp4 parser's error reporting is generally excellent, better than the ocaml parser
<edwin>
that would reduce the burdain of update when new language features have to be added: only camlp4 needs to be changed
<edwin>
hmm can't camlp4's parser be used as _the_ parser in ocamlc, and ocamlc would only take the AST output by camlp4?
<gasche>
I think only a minority of ocaml users are interested in camlp4 matters, no one is forced to read this subdiscussions
<gasche>
adrien, yes, and I didn't discuss camlp4 before there was a separate header/thread about it
<sgnb>
camlp4 is not a separate source package in debian
<gasche>
camlp4 is already a separate package in debian; you're saying that it would be easier if the split was done in the official distribution as well?
<gasche>
(I agree the logorrhea is maybe too much; that said, it's been a long time since camlp4 status was last discussed publicly; it's better to discuss it on the list, even with volume, than to keep private observations private)
<sgnb>
gasche: tying camlp4 and ocamlbuild to ocaml itself makes it hard to upgrade them without upgrading ocaml itself
<edwin>
still I think that the official distribution should come with ocamlbuild, camlp4|5, ocamldoc, _and_ findlib
<edwin>
sgnb: well external people could be given restricted committ access to ocamlbuild, camlp4, ocamldoc, etc.
<adrien>
I'm not saying anything about camlp4 vs. camlp5 however
<sgnb>
edwin: to split the official distribution into several components (camlp4 comes to mind, but ocamlbuild could also benefit from that), so that (eventually) some components could be taken over by people outside the core team... it's what happend with ocsigen and lwt... I haven't (yet) taken time to write it down formally
2011-12-08
<thelema>
it involves camlp4 magic, so I try to avoid it
<flux>
f[x], but the corresponding language will be awful. camlp4 could help there.
<f[x]>
there is nothing dynamic in there, just a compiler-supported way for type reflection - which is currently done via camlp4
2011-12-02
<diml>
you can then compile it with: ocamlbuild -tag use_dynlink,use_camlp4_full print_expr.byte
<diml>
Drakken: you have to use -package camlp4.lib, the camlp4 package is only for syntax extensions
<adrien>
you'd link your program in order to get an executable; it's not really how you do something with camlp4 usually
<Drakken>
Reference to undefined global `Camlp4'
<Drakken>
Effective set of compiler predicates: pkg_camlp4,autolink,byte
<Drakken>
Okay, the code compiled, but now the linker says global Camlp4 is undefined.
<flux>
also perhaps it's a little bit more difficult to teach to newcomers, given that it requires the use of camlp4 and camlp4 error messages are worse than non-camlp4-errors :(
<flux>
was it ocaml 3.09 that still had the old camlp4?
<Drakken>
So what are all these camlp4 libs in my installation? New or old?
<adrien>
camlp5 is the new name of the old camlp4, yes
<Drakken>
Oh, and do I really want camlp4, or is it camlp5? I don't see camlp5 in `ocamlfind list`, but that's the new name of the old syntax system, right? So are my camlp4 libs the old or the new? And if they're the new, is there a Grammar module in the new system or did that get changed?
<Drakken>
just "Camlp4"
<adrien>
does it say "Camlp4" or "Camlp4.Sig.Grammar.Entry"?
<Drakken>
I have findlib, although I haven't been using it for this particular program, and want to use camlp4 to write some macros/syntax extensions.
<everyonemines>
what are you trying to use camlp4 for
2011-11-28
<everyonemines>
...have you used camlp4 then?
<everyonemines>
you mean camlp4?
2011-11-25
<reynir>
Which one is easier: compile camlp5 as non-root or port a 75-line camlp5 syntax extension to camlp4?
2011-11-23
<jessicah>
that tells ocamlbuild that needs to get passed to camlp4; your ocamlfind line above doesn't know about it in there
<superbobry>
yup, here it is: 'ocamlfind ocamldep -package type-conv -package camlp4.quotations -package camlp4.lib -package camlp4 -package calendar -package binary -syntax camlp4o -modules examples/world.ml > examples/world.ml.depends'
<jessicah>
superbobry: looks like your bson thing isn't getting passed in to ocamlfind, so bson isn't loaded for your camlp4
<superbobry>
funny thing is, the above example actually compiles, when i do it manually with "camlp4 -I +camlp4 -parser o -parser op -printer o pa_type_conv.cma _build/syntax/pa_bson.cmo examples/world.ml"
2011-11-17
<hcarty>
Drakken: pa-do has one and I think that camlp4 includes a simple version as well