Version française
Home     About     Download     Resources     Contact us    
Browse thread
Value shadowing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jim Farrand <jim.farrand@g...>
Subject: Re: [Caml-list] Value shadowing
On Wed, 13 Aug 2008 02:15:53 -0700
Brighten Godfrey <pbg@cs.berkeley.edu> wrote:

> I also find that style useful.  Sometimes the type changes, but I
> can recall useful cases where the type doesn't change, e.g., a
> sequence of various operations on a list.  Mock-up:
> 
>      let lst = generate_list_somehow () in
>      let lst = List.filter (fun x -> x > 0) in
>      let lst = List.sort compare lst in

Agreed.

I have a slightly different proposal than using return types: short
pragmas for switching off specific instances of a warning.

I always want as many warnings as possible switched on because I find
them really useful.  The problem is they are warnings for a reason:
They don't ALWAYS represent errors.

Once my code has a warning in it, the usefulness of warnings is greatly
reduced as I'm less likely to spot the addition of another warning in
the compiler output.

If I could disable specific instances of a warning, which I've looked
at and decided to ignore, I'd get the best of both worlds.

>      (* @disableshadowwarning *)
>      let lst = generate_list_somehow () in
>      let lst = List.filter (fun x -> x > 0) in
>      let lst = List.sort compare lst in
>      (* @enableshadowwarning *)

No doubt, someone can think of a better syntax

Regards,
Jim