caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Inlined records don't work in toplevel
@ 2016-04-13 21:30 Yann Hamdaoui
  2016-04-14  6:59 ` Mr. Herr
  2016-04-14  7:14 ` Jeremy Yallop
  0 siblings, 2 replies; 4+ messages in thread
From: Yann Hamdaoui @ 2016-04-13 21:30 UTC (permalink / raw)
  To: caml-list

Dear list,

I tried to test inlined records for type constructors with
4.03.0+trunk+flambda in the toplevel and the syntax seems not to be
recognized :

%ocaml
OCaml version 4.03.0+dev18-2016-04-01
[....]
# type t = A of int;;
type t = A of int
# type t' = B of {x : int};;
Error:Parse error: [str_item] or ";;" expected (in [top_phrase])
(the A is underlined)

However if I put the code in a file test.ml

type t = A of {x : int}
let a = A {x=5}
let () = match a with A r -> print_int r.x

and run

%ocaml test.ml
5

everything goes fine. Am I missing something ?

-- 
Y.H

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

* Re: [Caml-list] Inlined records don't work in toplevel
  2016-04-13 21:30 [Caml-list] Inlined records don't work in toplevel Yann Hamdaoui
@ 2016-04-14  6:59 ` Mr. Herr
  2016-04-14  7:14 ` Jeremy Yallop
  1 sibling, 0 replies; 4+ messages in thread
From: Mr. Herr @ 2016-04-14  6:59 UTC (permalink / raw)
  To: caml-list


On 13.04.2016 23:30, Yann Hamdaoui wrote:
> Dear list,
>
> I tried to test inlined records for type constructors with
> 4.03.0+trunk+flambda in the toplevel and the syntax seems not to be
> recognized :
>
> %ocaml
> OCaml version 4.03.0+dev18-2016-04-01
> [....]
> # type t = A of int;;
> type t = A of int
> # type t' = B of {x : int};;
> Error:Parse error: [str_item] or ";;" expected (in [top_phrase])
> (the A is underlined)
>
> However if I put the code in a file test.ml
>
> type t = A of {x : int}
> let a = A {x=5}
> let () = match a with A r -> print_int r.x
>
> and run
>
> %ocaml test.ml
> 5
>
> everything goes fine. Am I missing something ?
>
most recent version is beta2 AFAIK, this case is okay - protocol:


strobel@suse132-intel:~> ocamli
        OCaml version 4.03.0+beta2

# type t = A of int;;
type t = A of int
# type t' = B of {x : int};;
type t' = B of { x : int; }
#

/Str.

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

* Re: [Caml-list] Inlined records don't work in toplevel
  2016-04-13 21:30 [Caml-list] Inlined records don't work in toplevel Yann Hamdaoui
  2016-04-14  6:59 ` Mr. Herr
@ 2016-04-14  7:14 ` Jeremy Yallop
  2016-04-14  7:49   ` Yann Hamdaoui
  1 sibling, 1 reply; 4+ messages in thread
From: Jeremy Yallop @ 2016-04-14  7:14 UTC (permalink / raw)
  To: Yann Hamdaoui; +Cc: Caml List

Dear Yann,

On 13 April 2016 at 22:30, Yann Hamdaoui <yann.hamdaoui@gmail.com> wrote:
> I tried to test inlined records for type constructors with
> 4.03.0+trunk+flambda in the toplevel and the syntax seems not to be
> recognized :
>
> %ocaml
> OCaml version 4.03.0+dev18-2016-04-01
> [....]
> # type t = A of int;;
> type t = A of int
> # type t' = B of {x : int};;
> Error:Parse error: [str_item] or ";;" expected (in [top_phrase])
> (the A is underlined)

The error is coming from Camlp4.  Perhaps you have an .ocamlinit file
that loads Camlp4 into the toplevel.  It appears that Camlp4's parser,
at least in the version you have installed, doesn't support the
inlined record syntax.

> However if I put the code in a file test.ml

Running ocaml with a filename as argument doesn't run .ocamlinit
files, so Camlp4 is not loaded and the standard OCaml parser is used
instead.

Kind regards,

Jeremy.

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

* Re: [Caml-list] Inlined records don't work in toplevel
  2016-04-14  7:14 ` Jeremy Yallop
@ 2016-04-14  7:49   ` Yann Hamdaoui
  0 siblings, 0 replies; 4+ messages in thread
From: Yann Hamdaoui @ 2016-04-14  7:49 UTC (permalink / raw)
  To: Jeremy Yallop; +Cc: Caml List

On 14/04/2016 09:14, Jeremy Yallop wrote:
> Perhaps you have an .ocamlinit file
> that loads Camlp4 into the toplevel. 
Indeed ! Now it works. Thank you very much

-- 
Y.H.

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

end of thread, other threads:[~2016-04-14  7:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-13 21:30 [Caml-list] Inlined records don't work in toplevel Yann Hamdaoui
2016-04-14  6:59 ` Mr. Herr
2016-04-14  7:14 ` Jeremy Yallop
2016-04-14  7:49   ` Yann Hamdaoui

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