autocoding project proposal

brianr at liffe.com brianr at liffe.com
Tue Jan 29 09:05:06 EST 2002


"Sean 'Shaleh' Perry" <shalehperry at attbi.com> writes:

> 
> I haev looked at it for much smaller, almost one off uses.  As you suggest, I
> always seem to end up with an 'indentation_level' variable and code doing
> something like:
> 
> line = (indentation_level * ' ') + data
> 
> It just always feels more soupy.  Being able to say 'int main() { foo; bar;
> baz; }' makes machine generated coding go a little easier.  But I am sure that
> is not for long term projects like yours.  Different issues for small scale
> versus large scale.  Adding the necessary python code for mine always seemed
> like overkill.  In your case what is 10 or 20 more lines of code in a 100 -
> 1000+ line app.
> 

I agree it is easier to generate code if you don't have to worry about
indenting, and you don't have to worry about that with languages that
that don't care about indentation and have begin and end block markers.

I have had to generate plenty of python code myself and I have found
that the need to maintain indentation adds complexity to the problem of
code generation.

My idea to make it easier (and I haven't tried it yet) is to make use of
pyindent. That is generate the code using the end block tags that
pyindent uses without worrying about indentation, then use pyindent
itself to post-process the code and apply the correct indentation.

Can anyone suggest any problems with this approach, or was this what a
previous poster meant by being not that hard?

-- 
Brian Raven
I would estimate that the number of programs it breaks in the world
will be less than 10.  As long as one of those 10 isn't CGI.pm, we're
probably okay.
             -- Larry Wall in <199804161805.LAA18882 at wall.org>



More information about the Python-list mailing list