help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What does "lacks a prefix" mean?


From: Robert Thorpe
Subject: Re: What does "lacks a prefix" mean?
Date: Sun, 19 Jul 2015 01:59:21 +0100

Yuri Khan <yuri.v.khan@gmail.com> writes:

> On Tue, Jul 14, 2015 at 5:47 AM, Emanuel Berg <embe8573@student.uu.se> wrote:
>
>> If you are to muck around with old code, which seldom
>> is a good idea but sometimes necessary (?),
>
> Why the (?)? Mucking around with old code is necessary every time you
> want to add a feature or debug a failure.

For what it's worth, this is my opinion on let vs let*.

When there's a dependency between two of the variables I use let*.  If
there's no dependency at all I use let.  So, if the code defining y
depends on the code defining x then I use let*.

I don't like the style where let* is used for everything.  Here's an
example of the problem.  Suppose you're reading through a function.  You
have a local variable z and you want to understand what values it could have.
To begin with you want to understand what could happen at the beginning
of the body of the let statement z is defined in.

I.e.:-
(defun foo ()
 "blah blah"
 (let* ((a (something))
       (b (something-else ...))
       (z (something-more)))
 ... here...
 ...rest of the code...)

Now, let's say the programmer has used let.  In that case I know by
looking that I don't have to read the definitions of a & b.
Alternatively, suppose the programmer has used let* even though z isn't
dependent on a or b.  In that case let* indicates to me the reader that
they should read the definitions of a & b.  But, doing that isn't
immediately necessary, I may not need to understand the details of a & b
to understand the problem.

It's easy to be critical of the process of restructuring or refactoring
code.  It's inevitable in large codebases though.  The cost and time of
rewriting them is simply too large.  Even if the original is badly
written it generally contains undocumented features that people rely on.
If a large program is well written that doesn't mean it won't need
modifications regularly.

BR,
Robert Thorpe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]