Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* question on exceptions
@ 2005-05-13 13:34 Julien Verlaguet
  2005-05-16  8:43 ` [Caml-list] " Johann Spies
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Verlaguet @ 2005-05-13 13:34 UTC (permalink / raw)
  To: caml-list

I have the following peace of code

exception E;;
let x=E;;
exception E;;

I don't understand why the two following things are not equivalent :

# x=E;;
- : bool = true

# match x with
   | E -> true
   | _ -> false;;
- : bool = false

Is this normal ?

J


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

* Re: [Caml-list] question on exceptions
  2005-05-13 13:34 question on exceptions Julien Verlaguet
@ 2005-05-16  8:43 ` Johann Spies
  0 siblings, 0 replies; 2+ messages in thread
From: Johann Spies @ 2005-05-16  8:43 UTC (permalink / raw)
  To: caml-list, caml-list

On Fri, May 13, 2005 at 03:34:22PM +0200, Julien Verlaguet wrote:
> I have the following peace of code
> 
> exception E;;
> let x=E;;
> exception E;;
> 
> I don't understand why the two following things are not equivalent :
> 
> # x=E;;
> - : bool = true
> 
> # match x with
>   | E -> true
>   | _ -> false;;
> - : bool = false
> 
> Is this normal ?

Maybe.  I am no expert but I suspect the second "exception E;;" causes
the behaviour that you saw.  Look at this:

# exception E;;
let x=E;;
exception E;;
exception E
# val x : exn = E
# exception E
#  x=E;;
- : bool = true
#  match x with
  | E -> true
  | _ -> false;;
    - : bool = false

So far it is the same, but

# exception E;;
exception E
# let x=E;;
val x : exn = E
#  x=E;;
- : bool = true
#  match x with
  | E -> true
  | _ -> false;;
    - : bool = true

Regards
Johann
-- 
Johann Spies          Telefoon: 021-808 4036
Informasietegnologie, Universiteit van Stellenbosch

     "In my Father's house are many mansions: if it were not
      so, I would have told you. I go to prepare a place for
      you. And if I go and prepare a place for you, I will 
      come again, and receive you unto myself; that where I 
      am, there ye may be also."        John 14:2,3 


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

end of thread, other threads:[~2005-05-16  8:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-13 13:34 question on exceptions Julien Verlaguet
2005-05-16  8:43 ` [Caml-list] " Johann Spies

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox