Re: Pointer-valued function to access inner components
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Wed, 14 Feb 2007 14:00:30 -0800
Salvatore <sfilippone@xxxxxxxxxxx> wrote:
Is the following code legal? Specifically, I am referring to the
pointer assignment in the main program. I am getting three different
behaviours from three different compilers....
The pointer assignment is ok. I need to leave pretty soon and don't have
time to adequately peruse the rest of the code.
However, just reading the subject line rings alarm bells. I truly wish
that the standard did not allow pointer-values functions. It does allow
them, but I consider their problems to be far more severe than their
benefits. Pointer-valued functions are extremely error prone, even for
expert users.
If you adopt a style that keeps away from the most problematic
error-prone areas, then you pretty much give up what functions are for.
The thing that most interestingly distinguishes a function from a
subroutne is that you can evaluate a function as part of an expression.
You aren't restricted to just things like y=f(x); you can also have
y=f(x)+42, or whatever. But do that with a pointer-valued function and
you probably introduced a memory leaks or other bug.
Yes, there are isolated cases where you can avoid the problems. But to
me, those cases are too isolated to counter the error-proneness of teh
whole thing.
I do note that you've got generics that have specifics of the same name
as the generic. The standard does allow that, but it wouldn't shock me
if some compilers get as confused by it as I do. (I didn't see at first
that was what was going on).
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- Follow-Ups:
- Re: Pointer-valued function to access inner components
- From: Salvatore
- Re: Pointer-valued function to access inner components
- References:
- Pointer-valued function to access inner components
- From: Salvatore
- Pointer-valued function to access inner components
- Prev by Date: Re: Optional arguments in nested subroutines
- Next by Date: Re: Optional arguments in nested subroutines
- Previous by thread: Pointer-valued function to access inner components
- Next by thread: Re: Pointer-valued function to access inner components
- Index(es):
Relevant Pages
|
|