|
Posted by Jerry Stuckle on 04/10/06 01:10
Tim Martin wrote:
> Jerry Stuckle wrote:
>
>> Tim Martin wrote:
>>
>>> Used judiciously these sorts of techniques can open up all sorts of
>>> possibilities (I've seen generic type containers implemented in pure
>>> C using macros), but the general consensus is that the potential for
>>> misuse is far too great and modern language constructs have obviated
>>> all the genuine needs for such techniques.
>>>
>>
>> What "General consensus"? I haven't heard that.
>
>
> For example, Sutter / Alexandrescu, "C++ Coding standards". They dismiss
> macros in no uncertain terms. You could argue about quite how widely
> accepted this viewpoint is (not that I have any interest in such an
> argument).
>
That's hardly a "general consensus". It's also about C/C++, not PHP.
And it goes against virtually every "coding standard" I've ever seen in C/C++.
> I deliberately phrased it like that to avoid giving the impression that
> I endorse this consensus myself. Personally, I think there are plenty of
> valid uses for macros in C (provided they are used with care). Whether
> the benefits outweigh the costs in PHP (or indeed C++) is much less
> obvious.
>
>> And just because someone might misuse them means no one can have
>> them? People might misuse functions - get rid of them. Someone might
>> misuse relational databases - get rid of them.
>
> >
>
>> It's not a valid argument.
>
>
> That wouldn't be a valid argument, but that wasn't the extent of my
> argument. You have to weigh up the potential benefits against costs. The
> fact that inexperienced programmers might end up using them to create
> unmaintainable code is a very definite cost. So far I haven't seen any
> real benefits.
>
The potential benefits of having them are that they can make coding more
understandable and easier to maintain.
The lack of macros doesn't give you the option.
> Out of interest, do you think that register_globals should be enabled by
>default, since it causes no problems for people who write correct code?
>
An entirely different discussion - which I am not going to get into here.
>>> To the OP: What are you trying to achieve with macros? With a
>>> combination of pass-by-reference, soft references and eval() you can
>>> achieve many of the things that C macros are able to achieve, with
>>> better syntax and less potential for misuse.
>>
>>
>> Make code clearer, more concise and more maintainable. All of which
>> can be increased by the judicious use of macros.
>
>
> The question is whether the same thing can be achieved by judicious use
> of existing constructs, without having to introduce macros into the
> language. So far, I haven't seen any proof otherwise.
>
> Tim
No it can't. Read my other posts.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|