caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Oliver Bandel <oliver@first.in-berlin.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] tail rec
Date: Sun, 20 May 2007 02:06:22 +1000	[thread overview]
Message-ID: <1179590782.18119.90.camel@rosella.wigram> (raw)
In-Reply-To: <20070519144651.GD335@first.in-berlin.de>

On Sat, 2007-05-19 at 16:46 +0200, Oliver Bandel wrote:

> > I think this is blocking understanding of how ressources
> > are allocated, when one uses a certain style of programming
> > and datastructures.
> 
> Forget these words: I misunderstood your email,
> because I did not read until end before I answered.
> Sorry for the unnecessary traffic.

Actually you make an important point!

> I thought you want to automatically *convert*
> code to tailrec-code.

Well that would be totally cool, but it appears
to be a rather hard problem?

>  Even if this would
> also be a fine thing, it could block understanding,
> as mentioned above.

Actually, you DO have an important point here.
When looking at, say, ordinary Ocaml code,
it is important to learn about recursion.

Examining the syntactic structure of the code
to understand the 'different' uses of a simple
but powerful primitive in an 'idiomatic' way
is important for understanding functional programming.

The use of sugar, annotations, or other device to
assure certain properties may well hide these idioms,
making learning and recognizing them harder.

I say 'may' because I'm only one individual, and not
a teacher familiar with learning experiences of many people.

> But you only want to have warnings...
> ...that might be a good helper.

Actually no: if you write 

let tailrec ...

then if a direct call of f is not in tail position,
you get a hard error, not a warning.

The construction has definite semantics. That applies
to Basile's more local annotation too.

In both cases the error indicates either that the routine
is possibly suboptimal in performance, or even that there
is a semantic bug in it!

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2007-05-19 16:06 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-19  2:56 skaller
2007-05-19  5:00 ` [Caml-list] " Erik de Castro Lopo
2007-05-19  5:28 ` Basile STARYNKEVITCH
2007-05-19 12:58   ` skaller
2007-05-19 20:19     ` Jonathan Bryant
2007-05-19 21:55       ` Erik de Castro Lopo
2007-05-19 22:13       ` skaller
2007-05-19 14:28 ` Oliver Bandel
2007-05-19 14:46   ` Oliver Bandel
2007-05-19 16:06     ` skaller [this message]
2007-05-21 12:57 ` Brian Hurt
2007-05-21 13:04   ` Robert Fischer
2007-05-21 13:21     ` Basile STARYNKEVITCH
2007-05-21 13:30       ` Robert Fischer
2007-05-21 14:00         ` Brian Hurt
2007-05-21 13:47       ` Daniel Bünzli
2007-05-21 14:24         ` Christopher L Conway
2007-05-21 14:36           ` Jon Harrop
2007-05-21 14:49             ` Richard Jones
2007-05-21 14:42           ` ocaml faq (was [Caml-list] tail rec) Daniel Bünzli
2007-05-21 15:09             ` Christopher L Conway
2007-05-21 15:17               ` Robert Fischer
2007-05-21 15:27                 ` Daniel Bünzli
2007-05-21 16:23                   ` Richard Jones
2007-05-21 16:59                     ` Robert Fischer
2007-05-21 16:26                   ` Richard Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1179590782.18119.90.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=oliver@first.in-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).