# let a = 32 ;; let b = 42 ;; val a : int = 32 # b;; Error: Unbound value b
Yeah... it's a little bit weird... not so great, actually. :-/ -- Philippe Wang [email protected] On Mon, Sep 12, 2011 at 3:13 PM, Jesper Louis Andersen <[email protected]> wrote: > On Mon, Sep 12, 2011 at 14:56, Andrej Bauer <[email protected]> wrote: >> Would anyone wish to comment on this particular "feature" of toplevel? >> >> >> Objective Caml version 3.12.1 >> >> # let a = 12 ;; I CAN PUT ANY GARBAGE HERE AND IT GETS IGNORED >> val a : int = 12 >> > > It is a bug when you want to enter multiple statements, like in: > > # let a = 12;; a + 30;; > val a : int = 12 > > But it is a feature when you want to use the toplevel as a way to > comment on what you are doing > > # let prod x = List.fold_left (fun x y -> x*y) 1 x;; DEAR STUDENTS, > USE THIS DEFINITION TO DEFINE THE FACTORIAL FUNCTION > > where the helpful feature of the top level makes it easier for the > student to just paste the whole line into the top level (except for > the # at the beginning, you can't have everything, can you?). > > To conclude: It is a bug and a feature at the same time. Which is > quite peculiar, since it does not have mutual exclusivity in this case > (contrast to evaluation order where there is a right and a wrong one, > your mileage may vary - but you can't have both at the same time for > the same expression, though you can have both at different times for > the same expression :). > > -- > J. > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs
