caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* FW: [Caml-list] newbie questions
@ 2001-08-22 18:29 Collin Monahan
  2001-08-24  6:51 ` Stefano Zacchiroli
  0 siblings, 1 reply; 4+ messages in thread
From: Collin Monahan @ 2001-08-22 18:29 UTC (permalink / raw)
  To: caml-list


Taking into account Neel Krishnaswami's advice that it would be actually
helpful to mail my questions to the list, I'm sending some.

I hope I don't end up irritating people! 

thanks,
Collin

-----Original Message-----
From: Collin Monahan [mailto:cmonahan@fame.com] 
Sent: Wednesday, August 22, 2001 14¤24
To: 'Felix Terkhorn'
Subject: RE: [Caml-list] newbie questions


Hi,

Thanks!

Well, here's a few things I don't understand right now.

try 
 let chan = open_in "foobar"
with Sys_error ->
 print_string "error opening file\n";;

This doesn't work. I think it might be because the stuff in the first
part doesn't evaluate to the same type as the stuff in the second part.
I also wonder if it might have something to do with how in the
documentation, lots of exceptions are described as, for example
	exception Stack_overflow
but for Sys_error it says
	exception Sys_error of string

Why does it say, when I type into the toplevel,
	Sys_error;;
that the constructor expects an argument?

Collin

-----Original Message-----
From: Felix Terkhorn [mailto:masterkh@indiana.edu] 
Sent: Wednesday, August 22, 2001 14¤09
To: Collin Monahan
Subject: Re: [Caml-list] newbie questions

Howdy,

I can try to answer some of your questions, but I won't guarantee that I
know a terrible amount. ;)  I'm also using linux, so any non-linux
OS-specific stuff I won't be able to answer.

Felix Terkhorn

-- 
'(felix-terkhorn . masterkh@indiana.edu)

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* Re: FW: [Caml-list] newbie questions
  2001-08-22 18:29 FW: [Caml-list] newbie questions Collin Monahan
@ 2001-08-24  6:51 ` Stefano Zacchiroli
  2001-08-24  7:31   ` David Mentre
  0 siblings, 1 reply; 4+ messages in thread
From: Stefano Zacchiroli @ 2001-08-24  6:51 UTC (permalink / raw)
  To: Collin Monahan; +Cc: caml-list

On Wed, Aug 22, 2001 at 02:29:01PM -0400, Collin Monahan wrote:
> Well, here's a few things I don't understand right now.
> 
> try 
>  let chan = open_in "foobar"
> with Sys_error ->
>  print_string "error opening file\n";;
> 
> This doesn't work. I think it might be because the stuff in the first
> part doesn't evaluate to the same type as the stuff in the second part.
> I also wonder if it might have something to do with how in the
> documentation, lots of exceptions are described as, for example
> 	exception Stack_overflow
> but for Sys_error it says
> 	exception Sys_error of string

Exception are like others concrete type in OCaml the only difference is
that them are introduced with the keywork "exception".
When you define an exception you may define it with a variable number of
arguments; exception like "Stack_overflow" are exception with no
argument, exception like "Sys_error" are exception with one argument, in
particular "Sys_error" have one string argument (this is because the
same exception is used to report a lot of different errors).

In "try ... with" constructor, the "with" clause use a pattern matching
on the exception returned by the "try" clause that return an "Exception
of string" that is not matched by your pattern of the form "Exception".
You have to use something like:

try
  ...
with Sys_error ->
  print_string ...

Hope this helps ...

Cheers

-- 
Stefano "Zack" Zacchiroli <zack@cs.unibo.it> ICQ# 33538863
Home Page: http://www.students.cs.unibo.it/~zacchiro
Undergraduate student of Computer Science @ University of Bologna, Italy
                 - Information wants to be Open -
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* Re: FW: [Caml-list] newbie questions
  2001-08-24  6:51 ` Stefano Zacchiroli
@ 2001-08-24  7:31   ` David Mentre
  2001-08-24 10:57     ` Stefano Zacchiroli
  0 siblings, 1 reply; 4+ messages in thread
From: David Mentre @ 2001-08-24  7:31 UTC (permalink / raw)
  To: Stefano Zacchiroli; +Cc: Collin Monahan, caml-list

Stefano Zacchiroli <zack@cs.unibo.it> writes:

> try
>   ...
> with Sys_error ->

oops. You probably meant: with Sys_error _ ->
                                        ^^^

>   print_string ...


-- 
 David.Mentre@inria.fr
 Opinions expressed here are only mine.
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

* Re: FW: [Caml-list] newbie questions
  2001-08-24  7:31   ` David Mentre
@ 2001-08-24 10:57     ` Stefano Zacchiroli
  0 siblings, 0 replies; 4+ messages in thread
From: Stefano Zacchiroli @ 2001-08-24 10:57 UTC (permalink / raw)
  To: David Mentre; +Cc: caml-list

On Fri, Aug 24, 2001 at 09:31:01AM +0200, David Mentre wrote:
> > try
> >   ...
> > with Sys_error ->
> 
> oops. You probably meant: with Sys_error _ ->

oooops, sure.

-- 
Stefano "Zack" Zacchiroli <zack@cs.unibo.it> ICQ# 33538863
Home Page: http://www.students.cs.unibo.it/~zacchiro
Undergraduate student of Computer Science @ University of Bologna, Italy
                 - Information wants to be Open -
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


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

end of thread, other threads:[~2001-08-24 10:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-22 18:29 FW: [Caml-list] newbie questions Collin Monahan
2001-08-24  6:51 ` Stefano Zacchiroli
2001-08-24  7:31   ` David Mentre
2001-08-24 10:57     ` Stefano Zacchiroli

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