in reply to Re: Re: Re: Re: Optimizing away calls to functions defined in eval
in thread Optimizing away calls to functions defined in eval

I worked for a pure-perl company for a couple years, and we used quite a bit of generated code to good effect. You are right in that you have to pick your battles or you can get screwed.

Things that generate very well are expressable in XML. If you can't express it easilly in static XML, it isn't a good place to generate. Good examples are database schemas - you then generate the perl accessors and also create/alter scripts from one source. Another is lists of static text to pre/append to pages depending on user preferences - like what level of help they require.

<help page="user-settings"> <tip level="novice"> Do not touch anything, the defaults are fine </tip> <tip level="admin"> Changing the starting day of the week will impact reports and time + sheets </tip> </help>
The usage in perl would be like $page->print_hints(-hint_level=>$user->setting('hintlevel')); The perl is overly verbose, but you get the idea.

-jackdied