This is a propos the thread started by Javier Sansa at
http://lists.wfu.edu/pipermail/gretl-users/2016-March/011708.html
I have now re-enabled the "rename" command in loops, thus reverting 
to the situation as of the 2015a release.
This is because I've come up with a method that I'm comfortable 
with, for ensuring that renaming doesn't cause problems. Instead of 
trying to figure out what cases of "rename" are problematic and what 
cases OK, this is the approach:
(1) You can use "rename" at will, but
(2) we check if a loop (or in the general case, a stack of nested 
loops) involves any cases of "rename" (quite easy), and if so
(3) we temporarily disable the particular loop-optimization which is 
vulnerable to renaming.
Here's a little illustration:
<hansl>
open data4-1
loop i=1..6 -q
   x = max(price) / max(sqft)
   printf "x = %g\n", x
   rename sqft tmp
   rename price sqft
   rename tmp price
endloop
Since this loop swaps the numerical content associated with the 
identifiers "price" and "sqft", the scalar x should take on 
different values on odd- and even-numbered iterations. And it does.
The price is that we have to look up the ID numbers (positions 
within the dataset) of "price" and "sqft" on each iteration. If we 
were sure there was no renaming going on, we would look up the ID 
numbers once and reuse that information on subsequent iterations.
Note that (since we're not trying to be "too clever" here) _any_ 
instance of renaming in a loop means that _all_ series ID numbers 
will be looked up anew on each iteration of the loop, for safety's 
sake. But that's not really a big deal unless you're running a 
potentially quite time-consuming script.
Allin