[Top][All Lists]

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

Re: Emacs contributions, C and Lisp

From: Perry E. Metzger
Subject: Re: Emacs contributions, C and Lisp
Date: Fri, 9 Jan 2015 09:17:52 -0500

On Fri, 09 Jan 2015 10:48:39 +0200 Eli Zaretskii <address@hidden> wrote:
> > Date: Thu, 8 Jan 2015 19:43:42 -0500
> > From: "Perry E. Metzger" <address@hidden>
> > Cc: Óscar Fuentes <address@hidden>, address@hidden
> > 
> > There are refactorings that are impossible without statement level
> > structure, such as semantic patches, that is, refactorings that
> > are aware of higher level information such as "has this value that
> > resulted from bar() being called been checked against NULL since
> > the last call to foo(), and if not, bracket the variable it was
> > assigned to in the following if statement...".
> Can you show a concrete example of such refactoring?

How much detail do you want?

An obvious example of something of the flavor is this: you add an
error return code to a function, and you then want to add code
throughout the program to check for the error return code, but only
if the error is possible from context. (For example, your call might
have an optional parameter, and the error return might tell
you that the optional parameter is invalid, but you only want to
check for such a return if the optional parameter has been passed at
all.) I could make up a synthetic example but I think most programmers
have seen such things.

A second, inverse example might be this: you find a bug caused by
failing to check an error return code, and you would like to go
through all your code looking for similar instances of the same call.
There are thousands of such calls and almost all of them are correct,
so you only want to see the ones where the error return code hasn't
been checked for. Your search is then not on some short string but
rather on a fairly arbitrary pattern over the AST. Again, I could
make up a synthetic example, but I think most programmers have seen
such things before. If it will help, though, I can invent an example.

Perry E. Metzger                address@hidden

reply via email to

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