Johan Vromans <[EMAIL PROTECTED]> writes:

[...]

> But I think this is getting ridiculous. $slightly_joking++; I'd
> propose a much nicer and cleaner concept:
> 
>     sub readit {
>         open F ... ;
>       prog1 {
>           scalar(<F>);
>           close F;
>         }
>     }
> 
> 'prog1' executes all expressions in the block, and returns the result
> of the first expression. Of course, we also need prog2, prog3, and so
> on ... $slightly_joking--; 

If you're going to reimplement Lisp poorly, at least reimplement the
right bits of Lisp poorly.  In this case, you want unwind-protect, not
prog1.  You can see the difference e.g. when throwing.

Here's the Emacs Lisp documentation of unwind-protect:

    `unwind-protect' is a built-in function

    Documentation:
    Do BODYFORM, protecting with UNWINDFORMS.
    Usage looks like (unwind-protect BODYFORM UNWINDFORMS...).
    If BODYFORM completes normally, its value is returned
    after executing the UNWINDFORMS.
    If BODYFORM exits nonlocally, the UNWINDFORMS are executed anyway.

You can read the relevant bit of CLtL2 at
http://www.supelec.fr/docs/cltl/clm/node96.html .

> All that POST and such do, is obfuscate the flow of control. I doubt
> that outweighs the small benefits.

However, unwind-protect is useful.  It's either use that or use
something destructor-related.  That just sits on top of some
unwind-protect-like hack in the internals.

-- 
Ariel Scolnicov        |"GCAAGAATTGAACTGTAG"            | [EMAIL PROTECTED]
Compugen Ltd.          |Tel: +972-2-5713025 (Jerusalem) \ We recycle all our Hz
72 Pinhas Rosen St.    |Tel: +972-3-7658117 (Main office)`---------------------
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555    http://3w.compugen.co.il/~ariels

Reply via email to