[Haskell-cafe] Proposal: Non-recursive let
AntC
anthony_clayden at clear.net.nz
Thu Jul 11 08:37:28 CEST 2013
> <oleg <at> okmij.org> writes:
> ...
> In Haskell I'll have to uniquely number the s's:
>
> let (x,s1) = foo 1 [] in
> let (y,s2) = bar x s1 in
> let (z,s3) = baz x y s2 in ...
>
> and re-number them if I insert a new statement.
>
> I once wrote about 50-100 lines of code with the fragment like the
> above and the only problem was my messing up the numbering (at one
> place I used s2 where I should've used s3). ...
Oleg, I hope you are not saying that in production code you use names like
x, y, z, s1, s2, s3, s4, ...
It leads to opaque code. If even you can mess up, what hope for us with
only nano-Oleg brain capacity?
Next you'll be wanting GOTO and destructive assignment.
Who knows: one day somebody modifying your code might need to insert a
line. (That 'somebody' might be your future self.)
Just don't do that! Use long_and_meaningful names.
50-100 near-identical lines of code sounds like an opportunity for an
algorithm.
AntC
More information about the Haskell-Cafe
mailing list