about pointer

K

Keith Thompson

Skarmander said:
But they *are* references, not pointers, in modern parlance, even if
back in 1976 this distinction was not made. Correct me if I'm wrong,
but I do not believe Algol 68 has pointers in the C sense -- things
you can point to arbitrary memory locations, perform arithmetic on,
cast to and from all sorts of types, and allowing dereferencing only
on the programmer's responsibility that it makes sense at all.

I think this is about to devolve into a debate over the meaning of the
term "pointer". That's sensible in the context of a single language,
but it's going to cause confusion if you try to define the term across
languages that have different semantics for similarly-named
constructs. Each language has its own terminology.

(Personally, I'd say that both Algol 68 and C have pointers; C's
pointers are just particularly undisciplined.)
 
S

Skarmander

Keith Thompson wrote:
[references and pointers]
I think this is about to devolve into a debate over the meaning of the
term "pointer". That's sensible in the context of a single language,
but it's going to cause confusion if you try to define the term across
languages that have different semantics for similarly-named
constructs. Each language has its own terminology.
Oh, poppycock. Languages agree on the general terms that allow effective
comparison, like function, procedure, subprogram, subroutine, routine... :)
(Personally, I'd say that both Algol 68 and C have pointers; C's
pointers are just particularly undisciplined.)
I have no problem calling references "disciplined pointers", and in my
mind the distinction makes sense across languages, but it wasn't my
intent to start a definition war.

S.
 
A

Amar Prakash Tripaithi

Dear venktash,
Beside dynamic memory allocation, pointers increases the
execution time of a program. You can itself test it by writing programs
such as Fermat and Pythgoras in C and then in java or else.
 
K

Keith Thompson

Amar Prakash Tripaithi said:
Dear venktash,
Beside dynamic memory allocation, pointers increases the
execution time of a program. You can itself test it by writing programs
such as Fermat and Pythgoras in C and then in java or else.

That doesn't make any sense. A given algorithm implemented using
pointers *might* be slower than the same algorithm implemented without
pointers, but writing two different implementations is non-trivial,
and any performance difference caused by the use of pointers is likely
to be swamped by other differences. Comparing equivalent programs in
C and Java certainly isn't going to tell you anything about the
performance impact of pointers.

Use pointers when it makes sense to do so, and not when it doesn't.
Get the program working before you worry about micro-optimization.
 
T

Tim Rentsch

Ben Pfaff said:
I'm not sure what you mean by "the Algol descendants" here. C is
an Algol descendant. [...]

I would say C is more Algol-influenced than an Algol descendant.
Algol has nested functions, which C emphatically does not. Obviously
there are other differences, but this difference seems essential
rather than incidental.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,476
Latest member
blackwatermelon

Latest Threads

Top