Re: type inference problem in my ocaml program (program is very short)



Dirk Thierbach kirjoitti:
But the point was to explain the basics, taking in accout the kind of
mistakes the original poster was making.

I always try to explain any shortcomings of code (the shortcomins that
I know of) that I post on usenet or any other forum. This has several
desirable effects including that
- it reduces the need for others to correct my code,
- it opens the door for further questions on the part of the person who
is asking for help, and
- it opens the door for others to show even better ways to solve the
problem.

I would recommend reading about the try-in-unless construct of
Benton and Kennedy:

I know the try-in-unless construct.

In general, when I reply to posts in usenet, I don't write them
specifically for one person. There is an exception, however. When I
post-and-mail, I intend the post as an open letter to one particular
recipient.

The above is problematic in that the file will not be properly closed
in case some exception other than End_of_file is raised,

Same here.

Not quite. I try very hard not to lie about the properties of code
that I post. IIRC, your comments on the code didn't indicate that it
would leak resources in some exceptional situations. I assume that you
understood the problem. Not mentioning important details like that can
lead others astray and the damage may be considerable.

If you want to present a good example for efficient waterproof code in
this situation that is easily understandable for a beginner, go ahead. :-)

I try very hard not to underestimate the intellectual capability of
others. For instance, in my reply I pointed to the Benton/Kennedy
article, which is probably not something that everyone can read at
their leisure (for me, reading it the first time required a fairly high
level of concentration). I expect (or wish) that others ask questions
on issues that they do not understand.

-Vesa Karvonen

.



Relevant Pages

  • Re: Evaluating Exceptions, Try Except and Try Finally
    ... work with the resource ... Consider your database example. ... exception handling differently than if the db open is something optional. ... both cases the code that actually opens the db shouldn't be the one making ...
    (alt.comp.lang.borland-delphi)
  • Re: Visual Studio Crashes Opening an Orchestration
    ... This happens when I open any orchestration. ... clicking on an orchestration opens the file in a new instance of VS fine. ... I can use every other file type except the orchestrations. ... Unhandled exception at 0xc5b917e3 in devenv.exe: 0xC0000005: Access ...
    (microsoft.public.biztalk.general)
  • Re: Evaluating Exceptions, Try Except and Try Finally
    ... ofcourse not true if an exception happens before the try block is entered! ... SINCE THE CONNECTION DID NOT OPEN ???!!!?? ... Opens a database connection with the settings specified by the ... Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows ...
    (alt.comp.lang.borland-delphi)
  • Re: USING clause with TRY...CATCH blocks
    ... > open or subsequent ops are guaranteed not to generate an exception. ... > Also multiple file opens seem more awkward with 'using' statements. ... Stream first = null; ... second = new FileStream; ...
    (microsoft.public.dotnet.languages.csharp)