Loading ...
Sorry, an error occurred while loading the content.

camlp4 or camlp5?

Expand Messages
  • Phil Tomson
    Which one is recommended? Should I learn camlp4 (which seems to have more docs and examples out there) or camlp5 (which seems to be billed as the replacement
    Message 1 of 9 , Apr 27 3:58 PM
    View Source
    • 0 Attachment
      Which one is recommended? Should I learn camlp4 (which seems to have
      more docs and examples out there) or camlp5 (which seems to be billed
      as the replacement for camlp4)?

      The think that worries me aoubt camlp5 is this from the webpage:

      "Note: the revised syntax

      The revised syntax is a specific syntax whose aim is to resolve some
      problems and inconsistencies of the normal OCaml syntax. A chapter
      will explain the differences between the normal and the revised
      syntax.

      All examples of this documentation are written in that revised syntax.
      Even if you don't know it, it is not difficult to understand. The same
      examples can be written in normal syntax. In case of problems, refer
      to the chapter describing it."

      So now we've got a new revised OCaml syntax? What's the story here?

      Phil
    • Martin Jambon
      ... Don t try to write syntax extensions if you re a beginner. ... No, you re confused and it is normal. Camlp4
      Message 2 of 9 , Apr 27 5:23 PM
      View Source
      • 0 Attachment
        On Sun, 27 Apr 2008, Phil Tomson wrote:

        > Which one is recommended?

        Don't try to write syntax extensions if you're a beginner.

        > Should I learn camlp4 (which seems to have
        > more docs and examples out there) or camlp5 (which seems to be billed
        > as the replacement for camlp4)?

        No, you're confused and it is normal.

        Camlp4 <= 3.09 is essentially the same as camlp5,
        while camlp4 >= 3.10 is largely incompatible with the earlier camlp4 and
        camlp5.


        > The think that worries me aoubt camlp5 is this from the webpage:
        >
        > "Note: the revised syntax
        >
        > The revised syntax is a specific syntax whose aim is to resolve some
        > problems and inconsistencies of the normal OCaml syntax. A chapter
        > will explain the differences between the normal and the revised
        > syntax.
        >
        > All examples of this documentation are written in that revised syntax.
        > Even if you don't know it, it is not difficult to understand. The same
        > examples can be written in normal syntax. In case of problems, refer
        > to the chapter describing it."
        >
        > So now we've got a new revised OCaml syntax? What's the story here?

        It's not new, but it definitely adds up to the complexity of the whole
        camlp4/camlp5 story.

        We could write a book about the history of camlp4 without a single line of
        code...


        Martin

        --
        http://wink.com/profile/mjambon
        http://mjambon.com
      • Phil Tomson
        ... How many years should I wait? The official reference docs for OCaml 3.10 shows a camlp4 example in Chapter 1. ... OK. That sounds, um, confusing. Is this
        Message 3 of 9 , Apr 27 11:12 PM
        View Source
        • 0 Attachment
          On 4/27/08, Martin Jambon <martin_jambon@...> wrote:
          >
          >
          >
          >
          >
          >
          > On Sun, 27 Apr 2008, Phil Tomson wrote:
          >
          > > Which one is recommended?
          >
          > Don't try to write syntax extensions if you're a beginner.

          How many years should I wait?

          The official reference docs for OCaml 3.10 shows a camlp4 example in
          Chapter 1.


          >
          > > Should I learn camlp4 (which seems to have
          > > more docs and examples out there) or camlp5 (which seems to be billed
          > > as the replacement for camlp4)?
          >
          > No, you're confused and it is normal.
          >
          > Camlp4 <= 3.09 is essentially the same as camlp5,
          > while camlp4 >= 3.10 is largely incompatible with the earlier camlp4 and
          > camlp5.

          OK. That sounds, um, confusing. Is this by design? So it's camlp4
          >= 3.10 that all the cool kids are using now?

          >
          > > The think that worries me aoubt camlp5 is this from the webpage:
          > >
          > > "Note: the revised syntax
          > >
          > > The revised syntax is a specific syntax whose aim is to resolve some
          > > problems and inconsistencies of the normal OCaml syntax. A chapter
          > > will explain the differences between the normal and the revised
          > > syntax.
          > >
          > > All examples of this documentation are written in that revised syntax.
          > > Even if you don't know it, it is not difficult to understand. The same
          > > examples can be written in normal syntax. In case of problems, refer
          > > to the chapter describing it."
          > >
          > > So now we've got a new revised OCaml syntax? What's the story here?
          >
          > It's not new, but it definitely adds up to the complexity of the whole
          > camlp4/camlp5 story.

          It's starting to sound like I should go learn Haskell.


          Phil

          >
          > We could write a book about the history of camlp4 without a single line of
          > code...
          >
          > Martin
          >
          > --
          > http://wink.com/profile/mjambon
          > http://mjambon.com
          >
        • Richard Jones
          ... If you re starting off, you re probably better off using camlp4 from OCaml 3.10 simply because it is included in the base OCaml and so doesn t require
          Message 4 of 9 , Apr 28 1:04 AM
          View Source
          • 0 Attachment
            On Sun, Apr 27, 2008 at 03:58:28PM -0700, Phil Tomson wrote:
            > Which one is recommended? Should I learn camlp4 (which seems to have
            > more docs and examples out there) or camlp5 (which seems to be billed
            > as the replacement for camlp4)?

            If you're starting off, you're probably better off using camlp4 from
            OCaml 3.10 simply because it is included in the base OCaml and so
            doesn't require anything to install.

            There are some tutorials here:

            http://www.ocaml-tutorial.org/camlp4_3.10

            For other examples, have a look in the humps for camlp4 syntax
            extensions:

            http://caml.inria.fr/cgi-bin/hump.en.cgi
            (Sorry, no direct link to syntax extensions that I could find).

            If you want a minimal camlp4 extension to start off from, then I wrote
            one last week which you can find here:

            http://caml.inria.fr/pub/ml-archives/caml-list/2008/04/b64ebf7e5015d1e80516e195bc1c1c9d.en.html

            Camlp4 _is_ complicated but that shouldn't stop you from trying to
            learn it because it is amazingly powerful.

            Rich.

            --
            Richard Jones
            Red Hat
          • postalchris
            ... You should probably wait until you know the language well enough to have a good intuition for what can and can t be accomplished without syntax extensions.
            Message 5 of 9 , Apr 28 6:17 AM
            View Source
            • 0 Attachment
              --- In ocaml_beginners@yahoogroups.com, "Phil Tomson" <rubyfan@...> wrote:
              >
              > On 4/27/08, Martin Jambon <martin_jambon@...> wrote:
              > > On Sun, 27 Apr 2008, Phil Tomson wrote:
              > > Don't try to write syntax extensions if you're a beginner.
              >
              > How many years should I wait?

              You should probably wait until you know the language well enough to
              have a good intuition for what can and can't be accomplished without
              syntax extensions. As an example, I programmed in OCaml exclusively
              for two years before I was presented with a problem where I felt a
              syntax extension was appropriate. YMMV.

              Also, note that syntax extensions are powerful and sometimes yield
              "nicer" code, but they are never strictly necessary.

              > The official reference docs for OCaml 3.10 shows a camlp4 example in
              > Chapter 1.

              This is somewhat unfortunate. The case demonstrated in the manual
              isn't really a syntax extension: you could use ocamllex and ocamlyacc
              to do the same thing. I think camlp4 is used to show its flexibility
              and to demonstrate a more idiomatically (or idiosyncratically)
              OCaml-ish solution.

              > It's starting to sound like I should go learn Haskell.

              By all means, you should. But OCaml is good too.

              Regards,
              Chris
            • Matt Gushee
              ... Personally, I would never say don t try, but you will need a *lot* of patience. For me it took about two years of OCaml programming before Camlp4 really
              Message 6 of 9 , Apr 28 6:23 AM
              View Source
              • 0 Attachment
                Phil Tomson wrote:

                > > Don't try to write syntax extensions if you're a beginner.
                >
                > How many years should I wait?

                Personally, I would never say "don't try," but you will need a *lot* of
                patience. For me it took about two years of OCaml programming before
                Camlp4 really started to make sense. I think it could take less time if
                you have background knowledge of parsing and language structure (such as
                you might gain in CompSci courses, I suppose).

                > > Camlp4 <= 3.09 is essentially the same as camlp5,
                > > while camlp4 >= 3.10 is largely incompatible with the earlier camlp4 and
                > > camlp5.
                >
                > OK. That sounds, um, confusing. Is this by design?

                Not exactly. The gist of it is that the OCaml development team decided
                to make some significant changes to Camlp4. Some of the changes are
                backwards-incompatible, and at any rate Daniel deRauglaudre, who
                designed the original Camlp4, disagrees with the new design. Since the
                name Camlp4 belongs to the main development team, Daniel had no choice
                but to rename his project.

                I am not qualified to judge who (if anyone) is right on the design
                issue, but I'd be interested in hearing some informed opinions on that
                subject.

                Hope that clarifies things a bit.

                --
                Matt Gushee
                : Bantam - lightweight file manager : matt.gushee.net/software/bantam/ :
                : RASCL's A Simple Configuration Language : matt.gushee.net/rascl/ :
              • Richard Jones
                I forgot the most important resource which is the camlp4 wiki: http://brion.inria.fr/gallium/index.php/Camlp4 This is the only up to date documentation you re
                Message 7 of 9 , Apr 28 6:58 AM
                View Source
                • 0 Attachment
                  I forgot the most important resource which is the camlp4 wiki:

                  http://brion.inria.fr/gallium/index.php/Camlp4

                  This is the only up to date documentation you're likely to find on
                  the new camlp4.

                  Rich.

                  --
                  Richard Jones
                  Red Hat
                • Martin Jambon
                  ... I recommend using camlp4 3.10 because it is the official version of camlp4 and we can t afford to have 2. I also recommend professional developers to stick
                  Message 8 of 9 , Apr 28 8:46 AM
                  View Source
                  • 0 Attachment
                    On Sun, 27 Apr 2008, Phil Tomson wrote:

                    >> while camlp4 >= 3.10 is largely incompatible with the earlier camlp4 and
                    >> camlp5.
                    >
                    > OK. That sounds, um, confusing. Is this by design? So it's camlp4
                    >> = 3.10 that all the cool kids are using now?

                    I recommend using camlp4 3.10 because it is the official version of
                    camlp4 and we can't afford to have 2.

                    I also recommend professional developers to stick with the official
                    syntax, not the revised one, for the same reason.


                    >> > The think that worries me aoubt camlp5 is this from the webpage:
                    >> >
                    >> > "Note: the revised syntax
                    >> >
                    >> > The revised syntax is a specific syntax whose aim is to resolve some
                    >> > problems and inconsistencies of the normal OCaml syntax. A chapter
                    >> > will explain the differences between the normal and the revised
                    >> > syntax.
                    >> >
                    >> > All examples of this documentation are written in that revised syntax.
                    >> > Even if you don't know it, it is not difficult to understand. The same
                    >> > examples can be written in normal syntax. In case of problems, refer
                    >> > to the chapter describing it."
                    >> >
                    >> > So now we've got a new revised OCaml syntax? What's the story here?
                    >>
                    >> It's not new, but it definitely adds up to the complexity of the whole
                    >> camlp4/camlp5 story.
                    >
                    > It's starting to sound like I should go learn Haskell.

                    Why? As far as I know, Haskell doesn't have anything like camlp4, and you
                    do not have to use camlp4 for doing great things in OCaml.

                    It's "just" that camlp4 allows you to define amazing domain-specific
                    languages embedded in OCaml, that you can distribute and install just like
                    libraries.


                    Martin

                    --
                    http://wink.com/profile/mjambon
                    http://mjambon.com
                  • Phil Tomson
                    ... Good to know. Thanks. ... sorry, I said that in a bought of frustration as the situation seemed rather confusing. Now that a few more people have chimed
                    Message 9 of 9 , Apr 28 10:26 AM
                    View Source
                    • 0 Attachment
                      On 4/28/08, Martin Jambon <martin_jambon@...> wrote:

                      >
                      > On Sun, 27 Apr 2008, Phil Tomson wrote:
                      >
                      > >> while camlp4 >= 3.10 is largely incompatible with the earlier camlp4 and
                      > >> camlp5.
                      > >
                      > > OK. That sounds, um, confusing. Is this by design? So it's camlp4
                      > >> = 3.10 that all the cool kids are using now?
                      >
                      > I recommend using camlp4 3.10 because it is the official version of
                      > camlp4 and we can't afford to have 2.
                      >
                      > I also recommend professional developers to stick with the official
                      > syntax, not the revised one, for the same reason.

                      Good to know. Thanks.
                      >

                      > > It's starting to sound like I should go learn Haskell.
                      >
                      > Why? As far as I know, Haskell doesn't have anything like camlp4, and you
                      > do not have to use camlp4 for doing great things in OCaml.

                      sorry, I said that in a bought of frustration as the situation seemed
                      rather confusing. Now that a few more people have chimed in it makes
                      some kind of sense.

                      >
                      > It's "just" that camlp4 allows you to define amazing domain-specific
                      > languages embedded in OCaml, that you can distribute and install just like
                      > libraries.
                      >

                      yes, that's the reason I want to learn camlp4.

                      Phil

                      > Martin
                      >
                      > --
                      > http://wink.com/profile/mjambon
                      > http://mjambon.com
                      >
                    Your message has been successfully submitted and would be delivered to recipients shortly.