Experiences/guidance on teaching Python as a first programming language

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu Dec 19 01:41:00 EST 2013


Dave Angel wrote:
> C is a glorified macro assembler.  So the -> operator is not analogous 
> to the dot operator, it's Syntactic sugar:
> 
> p-> a. Is really
> (*p).a

But it's not above inferring a dereferencing
operation when you call a function via a
pointer. If f is a pointer to a function,
then

    f(a)

is equivalent to

    (*f)(a)

If the compiler can do that for function calls,
there's no reason it couldn't do it for member
access as well.

If I remember rightly, Ada not only does implicit
dereferencing like this, it doesn't even have an
explicit dereferencing operator! If you want to
refer to the whole record pointed to by p, you
have to say 'p.all'.

BTW, the whole notion of a "pointer to a function"
is redundant in C, since you can't do anything
with what it points to other than call it. The
equivalent concept in Modula, for example, is
just called a function type, not a pointer-to-
function type. Similarly in most languages that
have functions as values.

-- 
Greg



More information about the Python-list mailing list