You are here: Re: Macros in php « PHP Programming Language « IT news, forums, messages
Re: Macros in php

Posted by Dana Cartwright on 11/10/00 11:44

"Ian McConnell" <ian@emit.demon.co.uk> wrote in message
news:87vetlbkbt.fsf@emit.demon.co.uk...
> Just the other day, I was thinking that a preprocessor in PHP would be
> handy. I've got a lot of code that goes
>
> <?php
> include 'cache.inc';
> $c = new cache;
> if ($c->uncached()) {
>
> ... main body of php code
>
> }
> $c->end(); // cache and/or display html
> include 'stats_counter.inc';
> ?>
>
> It would be nice to replace this with
>
> <?php
> START_CACHING;
>
> ... main body of php code
>
> END_CACHING;
> ?>
>

Any piece of software is essentially a series of mental concepts, written
down as computer code. So what you are saying (and I agree heartily) is:
See this series of PHP statements? They represent a concept called "Start
Caching".

So it makes sense to write START_CACHING rather than spell out the details.
I think it makes the code easier to read, both for the author and any other
soul who has to learn it.

This aspect of macros has nothing to do with computer efficiency, but a
great deal to do with human efficiency. We *like* to name things.
Languages should accomodate this.

What's nice about macros is that they can be used to name rather arbitrary
stuff, including fragments of code. Functions have a different role to
play.

-Dana

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация