caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] strange behaviour of ocamldoc
@ 2004-09-14 17:47 Eugene Ossintsev
  2004-09-15 13:28 ` [Caml-list] Confused Jon Harrop
  0 siblings, 1 reply; 11+ messages in thread
From: Eugene Ossintsev @ 2004-09-14 17:47 UTC (permalink / raw)
  To: caml-list

Hello,

In OCaml 3.08.0 and 3.08.1 (not tested with the other versions) it seems 
that ocamldoc behaves strangely in the following case:

foo.mli:
--------
(** Supported URL schemes. *)
type url_scheme =
   | Http  (** Hypertext Transfer Protocol *)
   | Ftp   (** File Transfer protocol *)
   | File  (** Local file access *)

ocamldoc foo.mli writes the error message:

        foo.mli : lexing: empty token.

That error occurs if in the (** *)-comment of an enumerated type there 
exists a word (or, more exactly, a combination of letters) matching the 
name of the following enumerated type or a part of the name of that 
type. In the above example it is "File".

In other words, any of those combinations gives the error:

(** Comments *)
type my_type =
   | Aaa (** foo Bbb bar *)
   | Bbb (** blah-blah *)

(** Comments *)
type my_type =
   | Aaa (** foo Bbb bar *)
   | Bb  (** blah-blah *)

(** Comments *)
type my_type =
   | Aaa (** foo Bbb bar *)
   | B   (** blah-blah *)

Could you help me solve the problem? What am I doing wrong?

-- 
Eugene Ossintsev

-------------------
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Caml-list] Confused
  2004-09-14 17:47 [Caml-list] strange behaviour of ocamldoc Eugene Ossintsev
@ 2004-09-15 13:28 ` Jon Harrop
  2004-09-15 13:46   ` Michael
                     ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Jon Harrop @ 2004-09-15 13:28 UTC (permalink / raw)
  To: caml-list


How come this works:

# let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1);;
val build : int -> float list = <fun>
# let test = 1. :: build 1000;;
val test : float list = ...

But this does not:

# let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1) in
  let test = 1. :: build 1000;;
Syntax error

Am I being stupid?

Cheers,
Jon.

-------------------
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Confused
  2004-09-15 13:28 ` [Caml-list] Confused Jon Harrop
@ 2004-09-15 13:46   ` Michael
  2004-09-15 13:51   ` Radu Grigore
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Michael @ 2004-09-15 13:46 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

Hi,

On Mittwoch, 15. September 2004 15:28, you wrote:
>But this does not:
># let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1) in
>  let test = 1. :: build 1000;;
>Syntax error


it works with 
 let test =
	 let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1) in
	 1. :: build 1000
;;


 Michael

-------------------
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Confused
  2004-09-15 13:28 ` [Caml-list] Confused Jon Harrop
  2004-09-15 13:46   ` Michael
@ 2004-09-15 13:51   ` Radu Grigore
  2004-09-15 14:01   ` Brian Hurt
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Radu Grigore @ 2004-09-15 13:51 UTC (permalink / raw)
  To: Jon Harrop, caml-list

On Wed, 15 Sep 2004 14:28:53 +0100, Jon Harrop <jon@jdh30.plus.com> wrote:
 
> How come this works: [...]
> But this does not:
> 
> # let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1) in
>   let test = 1. :: build 1000;;
> Syntax error
 
Look at this. I'm even more confused:

----------------
[rgrig@radugrigore temp]$ ocaml
        Objective Caml version 3.07+2

# #load "camlp4r.cma";;
        Camlp4 Parsing version 3.07+2

# let rec b = function 0 -> [] | n -> 2. :: b (n - 1) in let t = 1. :: b 2;;
Toplevel input:
# let rec b = function 0 -> [] | n -> 2. :: b (n - 1) in let t = 1. :: b 2;;
                         ^^
Parse error: 'and' or 'in' expected (in [expr])
# exit 0;;
Toplevel input:
# exit 0;;
        ^^
Parse error: ';' expected after [str_item] (in [phrase])
#
------------------

regards,
 radu

-------------------
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Confused
  2004-09-15 13:28 ` [Caml-list] Confused Jon Harrop
  2004-09-15 13:46   ` Michael
  2004-09-15 13:51   ` Radu Grigore
@ 2004-09-15 14:01   ` Brian Hurt
  2004-09-15 14:13   ` Jon Harrop
  2004-09-15 14:52   ` skaller
  4 siblings, 0 replies; 11+ messages in thread
From: Brian Hurt @ 2004-09-15 14:01 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

On Wed, 15 Sep 2004, Jon Harrop wrote:

> 
> How come this works:
> 
> # let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1);;
> val build : int -> float list = <fun>
> # let test = 1. :: build 1000;;
> val test : float list = ...
> 
> But this does not:
> 
> # let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1) in
>   let test = 1. :: build 1000;;
> Syntax error

What you want to do is:
let test =
	let rec build = funcion 0 -> [] | n -> 1e-6 :: build (n-1) in
	1. :: build 1000
;;


"let var = expression" is not, itself, and expression.  It's a statement.  
Ocaml does, in fact, have statements and not just expressions.  The let/in 
construct is: "let var = expression in expression" is an expression- but 
it requires the stuff to the right of the 'in' keyword to also be an 
expression.  This means that it can be another let/in expression, but not 
statements like "let var = expression".  

The solution, then, is to move the let/in definition down into the 
expression part of the statement- i.e., after the equals sign.  Thus my 
counter-example.

> Am I being stupid?

No- just confused on a subtle point of Ocaml syntax.

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
Brian

-------------------
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Confused
  2004-09-15 13:28 ` [Caml-list] Confused Jon Harrop
                     ` (2 preceding siblings ...)
  2004-09-15 14:01   ` Brian Hurt
@ 2004-09-15 14:13   ` Jon Harrop
       [not found]     ` <7f8e92aa04091507233d074f31@mail.gmail.com>
  2004-09-15 14:52   ` skaller
  4 siblings, 1 reply; 11+ messages in thread
From: Jon Harrop @ 2004-09-15 14:13 UTC (permalink / raw)
  To: caml-list

On Wednesday 15 September 2004 14:28, Jon Harrop wrote:
> # let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1) in
>   let test = 1. :: build 1000;;
> Syntax error
>
> Am I being stupid?

Yes! The correct syntax is, of course:

let test =
  let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1) in
  1. :: build 1000;;

So the "let" returned to the top-level has to be the outermost one. All inner 
"let"s must be followed by "in" and an expression.

Thanks, John and Christoph and anyone else who replies before I get this 
off. ;-)

Cheers,
Jon.

-------------------
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Caml-list] Confused
       [not found]     ` <7f8e92aa04091507233d074f31@mail.gmail.com>
@ 2004-09-15 14:23       ` Radu Grigore
  2004-09-15 14:50         ` Virgile Prevosto
  0 siblings, 1 reply; 11+ messages in thread
From: Radu Grigore @ 2004-09-15 14:23 UTC (permalink / raw)
  To: caml-list

Forgot to send it to the list too:


---------- Forwarded message ----------
From: Radu Grigore <radugrigore@gmail.com>
Date: Wed, 15 Sep 2004 17:23:11 +0300
Subject: Re: [Caml-list] Confused
To: Jon Harrop <jon@jdh30.plus.com>

On Wed, 15 Sep 2004 15:13:13 +0100, Jon Harrop <jon@jdh30.plus.com> wrote:

> Thanks, John and Christoph and anyone else who replies before I get this
> off. ;-)

Ok, I got it too.

But it still doesn't explain why I was unable to exit ocaml
interactive interpreter after loading camlp4r and typing your exact
example: exit doesn't work, #quit doesn't work, ctrl-C doesn't work,
etc. The only solution that worked was ctrl-Z followed by "kill".

regards,
 radu

-------------------
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Confused
  2004-09-15 14:23       ` Radu Grigore
@ 2004-09-15 14:50         ` Virgile Prevosto
  2004-09-15 14:57           ` Radu Grigore
  0 siblings, 1 reply; 11+ messages in thread
From: Virgile Prevosto @ 2004-09-15 14:50 UTC (permalink / raw)
  To: Radu Grigore; +Cc: caml-list

Le 15.09.2004, à 17:23:48, Radu Grigore a écrit:

> But it still doesn't explain why I was unable to exit ocaml
> interactive interpreter after loading camlp4r and typing your exact
> example: exit doesn't work, #quit doesn't work, ctrl-C doesn't work,
> etc. The only solution that worked was ctrl-Z followed by "kill".
> 

because camlp4R loads the Revised syntax, in which toplevel sentences
are ended by a single semicolumn, not a double one:
~ [754]$ ocaml
        Objective Caml version 3.08.1

#  #load "camlp4r.cma";; (* normal syntax, use ';;' *)
        Camlp4 Parsing version 3.08.1

# exit 0; (* revised syntax, use ';' *)
~ [755]$

To go back to the initial question, note that the revised syntax has two
different keywords for global declaration and local binding: the former
is introduced by 'value', while the latter is still 'let ... in'. Hence,
you'll have to write

# #load "camlp4r.cma";;
# value test = 
   let rec build = 
    fun [0 -> [] | n -> [1e-6 :: build (n-1)]] 
   in [1.::(build 1000)]; 
(* There are also differences in lists and pattern-matching syntax *)
value test : list float
=  [1; 1e-06; 1e-06; 1e-06; 1e-06; 1e-06; 1e-06; 1e-06; 1e-06; 1e-06;
   1e-06; <snip>

The revised syntax is described in the chapter 6 of the camlp4 manual.

-- 
E tutto per oggi, a la prossima volta
Virgile

-------------------
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Confused
  2004-09-15 13:28 ` [Caml-list] Confused Jon Harrop
                     ` (3 preceding siblings ...)
  2004-09-15 14:13   ` Jon Harrop
@ 2004-09-15 14:52   ` skaller
  2004-09-15 18:42     ` William Lovas
  4 siblings, 1 reply; 11+ messages in thread
From: skaller @ 2004-09-15 14:52 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

On Wed, 2004-09-15 at 23:28, Jon Harrop wrote:
> How come this works:
> 
> # let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1);;
> val build : int -> float list = <fun>
> # let test = 1. :: build 1000;;
> val test : float list = ...
> 
> But this does not:
> 
> # let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1) in
>   let test = 1. :: build 1000;;
> Syntax error
> 
> Am I being stupid?

The top level let is unrelated to the expression let/in.
It just happens to use the same keyword. I'll change the 
keyword to demonstrate:

toplet x = y;;
let x = y in z;;

The first form is a toplet statement, the second is an entirely
unrelated expression statement. Note that toplet explicitly
has side-effects -- it enriches the global environment with
the symbol x. The expression statement has side-effects 
if y and z do OR if you are using the command line 'ocaml'
program (it prints the type and value).

Now rewriting your example:


let rec build = function 0 -> [] | n -> 1e-6 :: build (n-1) in
  toplet test = 1. :: build 1000;;

you can see you've used a 'toplet' in an inner location
where an expression is expected: let/in is an expression,
toplet isn't.

Basically this syntax is a 'hack' used by language
designers, overloading related syntactic forms to avoid
introducing new keywords and to make the language 
'more intuitive' - which usually backfires on newbies
and even experts at times. 

Such impurity is annoying, however a fully 'orthogonal'
syntax may well be worse. For example seeing:

int_match x with | 1 -> ..
float_match x wth | 1.2 -> ...
variant_match x with | True -> 

you can probably agree some 'pattern matching' in the compiler
itself to discriminate these cases (and allow just plain 'match')
is probably justified.

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net



-------------------
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Confused
  2004-09-15 14:50         ` Virgile Prevosto
@ 2004-09-15 14:57           ` Radu Grigore
  0 siblings, 0 replies; 11+ messages in thread
From: Radu Grigore @ 2004-09-15 14:57 UTC (permalink / raw)
  To: Virgile Prevosto; +Cc: caml-list

On Wed, 15 Sep 2004 16:50:46 +0200, Virgile Prevosto
<prevosto@mpi-sb.mpg.de> wrote:

> because camlp4R loads the Revised syntax, in which toplevel sentences
> are ended by a single semicolumn, not a double one:

Thanks. Now I feel really stupid. <going back to my corner>

regards,
 radu

-------------------
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Confused
  2004-09-15 14:52   ` skaller
@ 2004-09-15 18:42     ` William Lovas
  0 siblings, 0 replies; 11+ messages in thread
From: William Lovas @ 2004-09-15 18:42 UTC (permalink / raw)
  To: caml-list

On Thu, Sep 16, 2004 at 12:52:26AM +1000, skaller wrote:
> Basically this syntax is a 'hack' used by language
> designers, overloading related syntactic forms to avoid
> introducing new keywords and to make the language 
> 'more intuitive' - which usually backfires on newbies
> and even experts at times. 

I suspect it was inherited from the original ML -- O'Caml could easily fix
this "problem" without introducing any new keywords, but i think the costs
outweigh the potential benefits.

cheers,
William

-------------------
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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-09-15 18:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-14 17:47 [Caml-list] strange behaviour of ocamldoc Eugene Ossintsev
2004-09-15 13:28 ` [Caml-list] Confused Jon Harrop
2004-09-15 13:46   ` Michael
2004-09-15 13:51   ` Radu Grigore
2004-09-15 14:01   ` Brian Hurt
2004-09-15 14:13   ` Jon Harrop
     [not found]     ` <7f8e92aa04091507233d074f31@mail.gmail.com>
2004-09-15 14:23       ` Radu Grigore
2004-09-15 14:50         ` Virgile Prevosto
2004-09-15 14:57           ` Radu Grigore
2004-09-15 14:52   ` skaller
2004-09-15 18:42     ` William Lovas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).