Version française
Home     About     Download     Resources     Contact us    
Browse thread
OCaml IDE (Camlp4 for code formatting)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hendrik Tews <tews@t...>
Subject: Re: [Caml-list] OCaml IDE (Camlp4 for code formatting)
"Nathaniel J. Gaylinn" <ngaylinn@cs.brown.edu> writes:

   On Tue, 21 Jun 2005, Hendrik Tews wrote:
   
   >    I understand why it makes this change,
   >
   > Could you explain? (Because I don't understand. "let _ = 5" and
   > "5" are different internally.)
   
   Heh, I didn't realize that they were handled different internally  ;)  I
   thought it was a reasonable thing to do because it is more explicit and
   equivalent, but if it isn't actually equivalent...
   
Not sure if you got me right: The two phrases "let _ = 5" and "5"
are semantically equivalent and probably compiled to the same
code. However, they have a different representation as a camlp4
ast. Still the question remains, why camlp4 rewrites one into the
other.

   Would it be difficult to write a printer that had much direct access with
   the original file? That's something that I'd quite obviously need.
   
If you pretty print an camlp4 ast similar to pr_o.cmo then you
will always change the input (ie. rewriting "(1,2)" into "1,2" or
vice versa). I don't think it makes sense to track the input to
recover the information that is not present in camlp4's ast,
because you would have to parse the input.

If you want to output all comments and print "(1,2)" as "(1,2)"
and "1,2" as "1,2" then you need a new parser for ocaml. Camlp4
won't help much in this case. It is probably easier to adjust the
yacc grammar from the ocaml sources.

Bye,

Hendrik