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

Believe it or not, I'm trying to propose an alternate solution to machine generated code. The problem is that the maintainance headaches move from the code to the generator. Since the generator is almost always a reinvention of the wheel, it's much more difficult to maintain. Having that layer of abstraction, I've found, isn't usually worth it.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

  • Comment on Re: Re: Re: Re: Optimizing away calls to functions defined in eval

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Optimizing away calls to functions defined in eval
by jackdied (Monk) on Oct 17, 2001 at 02:47 UTC
    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