* Ocaml secrets
@ 2000-01-12 15:31 Norman Ramsey
  2000-01-12 17:56 ` David Brown
  2000-01-12 22:35 ` Francois Rouaix
  0 siblings, 2 replies; 3+ messages in thread
From: Norman Ramsey @ 2000-01-12 15:31 UTC (permalink / raw)
  To: caml-list
I've been going nuts copying record-type definitions, and then Benjamin Pierce
showed me a trick.
Please tell me where in the OCaml manual I could have discovered
the ability to write
  tm.Unix.tm_hour
as in
        let tm = Unix.localtime (Unix.time()) in
        sprintf "%02d:%02d:%02d " tm.Unix.tm_hour tm.Unix.tm_min tm.Unix.tm_sec
Norman
P.S.  just writing let tm = ... in ... tm.tm_hour ... etc causes ocamlc to barf.
^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: Ocaml secrets
  2000-01-12 15:31 Ocaml secrets Norman Ramsey
@ 2000-01-12 17:56 ` David Brown
  2000-01-12 22:35 ` Francois Rouaix
  1 sibling, 0 replies; 3+ messages in thread
From: David Brown @ 2000-01-12 17:56 UTC (permalink / raw)
  To: Norman Ramsey; +Cc: caml-list
On Wed, Jan 12, 2000 at 10:31:22AM -0500, Norman Ramsey wrote:
> Please tell me where in the OCaml manual I could have discovered
> the ability to write
> 
>   tm.Unix.tm_hour
> 
> as in
I didn't find it.  I tried it on a whim and was very glad that it
worked.
If you wander through the BNF grammar in the reference section, it
does show it as being possible.  A label can either be a label-name,
or a  (module-path '.' label-name).  It might be helpful to mention
this somewhere in the tutorial, or in some kind of FAQ, since it is
very handy.
Dave Brown
^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: Ocaml secrets
  2000-01-12 15:31 Ocaml secrets Norman Ramsey
  2000-01-12 17:56 ` David Brown
@ 2000-01-12 22:35 ` Francois Rouaix
  1 sibling, 0 replies; 3+ messages in thread
From: Francois Rouaix @ 2000-01-12 22:35 UTC (permalink / raw)
  To: Norman Ramsey; +Cc: caml-list
> Please tell me where in the OCaml manual I could have discovered
> the ability to write
> 
>   tm.Unix.tm_hour
Well, the online manual says
    label ::= label-name
           |  module-path .  lowercase-ident
at http://pauillac.inria.fr/ocaml/htmlman/manual009.html
and expr ::= ... | expr.label
at http://pauillac.inria.fr/ocaml/htmlman/manual013.html
I'd say it's a matter of faith in the regularity of the compiler (or 
its authors, hi guys, how are you) ;-)
Since we know that a language object (except modules and weird things like
method names) always lives in some module, and since we know that we can use 
M.x to access value x in module M, we should expect M.l to be valid to refer
to label l in module M.
--f
^ permalink raw reply	[flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-01-13 16:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-12 15:31 Ocaml secrets Norman Ramsey
2000-01-12 17:56 ` David Brown
2000-01-12 22:35 ` Francois Rouaix
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox