Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] O'Caml looks at the contents of comments?!
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Shawn Wagner <shawnw@s...>
Subject: Re: [Caml-list] O'Caml looks at the contents of comments?!
On Sun, Sep 14, 2003 at 02:29:25PM +1000, skaller wrote:
> On Sat, 2003-09-13 at 20:45, Jim Farrand wrote:
> > I've spent a long time puzzling over a "string not terminated" error
> > which was being reported inside a class I'm writing.  Camlp4r reported
> > the error just as being somewhere in the class (i.e. Line 267 character
> > 4 - 1076) which gave me quite a bit of code to look over.  I spent a
> > long while staring at the code quite puzzled because I couldn't see an
> > unterminated string anywhere.
> > 
> > Eventually I started commenting out bits of code, and I was even more
> > confused when I'd commented out the entire class and STILL got the
> > error.
> > 
> > Eventually I traced the error to an unterminated string inside a
> > comment.  This strikes me as slightly odd behaviour - one of the first
> > things comp sci students are taught about comments is that the compiler
> > ignores them.  As this has been my experience for many years it took me
> > a long time to even consider that I could have a syntax error inside a
> > comment.
> > 
> > So why is this restriction enforced?
> > 
> 
> The reason is: Ocaml comments are designed to be able to
> comment out code.
> 
> If you consider the code:
> 
> 	" (* " ^ x
> 
> and comment out the first part like this:
> 
> 	(* " (* " ^ *) x
> 
> it wouldn't work unless the (* in the string was detected
> as being inside a string and ignored. The contents of
> comments are not ignored, in the sense that every lexer
> even C's, has to find the comment terminator.
> 

I keep getting hit with this too. The problem in my case? Single quotes used
as apostrophes in the documentation in comments. Annoying, even if you know
why it's happening. 

-- 
Shawn Wagner
shawnw@speakeasy.org

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners