Translation of C function pointer.
Jonathan M Davis
jmdavisProg at gmx.com
Fri Sep 17 10:46:02 PDT 2010
On Friday, September 17, 2010 05:00:55 Simen kjaeraas wrote:
> On Fri, 17 Sep 2010 10:12:34 +0200, Jonathan M Davis <jmdavisProg at gmx.com>
>
> wrote:
> > On Thursday 16 September 2010 23:50:16 Kagamin wrote:
> >> BCS Wrote:
> >> > The trick is that function pointers are best read from the inside out.
> >>
> >> All C declarations are read from inside out, postfixes take precedence,
> >> that's why you have to use braces to give pointer higher precedence. One
> >> of the earlier books by Stroustroup gives a nice monster of arrays,
> >> pointers and functions to master understanding of declarations.
> >
> > It's essentially the same principle that makes it so that the D
> > declaration
> >
> > int[4][3] a;
> >
> > is an array with 3 rows and 4 columns rather than 4 rows and 3 columns
> > like
> > you'd expect.
>
> I've always been confused by C in this regard. It seems to logical to me
> that T[3] works the same whether T is U[4] or U.
You're going to have to elaborate on that. I'm not quite sure what you're
talking about. And the syntax int[4][3] isn't legal C anyway. It just does what
C would likely have done had it put the brackets with the type rather than the
variable name, since D uses pretty much the same syntax for variable
declarations and therefore pretty much the same rules.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list