Re: A modern way to solve the "callback problem" from a subroutine?
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Thu, 20 Mar 2008 09:30:24 -0800
GaryScott wrote:
(snip)
I'm not really as anti-pointer as that sounded, however, it is
possible to solve these problems in other ways. You can write a
linked list (double, single, skip) functionality without pointers and
in my opinion more clearly. "Best" is highly subjective. Clear,
clean, easy to understand code may be best for some, whereas,
efficient memory utilization might be someone else's criterion.
Efficient memory utilization is often important. When Fortran
was young, computers only had one program in storage at a time so
that there was no reason not to give that program all available storage.
Many Fortran "tricks" are based on how to use that memory within
the program.
When you have more than one program running and using memory at
the same time, efficient use of memory is important. When a
program can't anticipate its memory usage, dynamic allocation
is needed. In the case of a linked list of unknown and highly
variable length, pointers allow more efficient memory usage.
If the total length is known, or approximately known, then
an array of appropriate size can be allocated and array
elements referenced as part of a list. (I have done
that even in C.)
I've
solved virtually every type of problem without ever needing pointers.
The only exceptions have been the need to associate an application
memory buffer or structure with allocated memory returned by the
operating system, or to assign a callback procedure. I would add that
if linked lists are so overwhelmingly beneficial, then we should build
them into the language, perhaps as an intrinsic object.
PL/I has locate mode I/O for that case. One can read data in such
that the system supplies a pointer to the data in the input buffer
or write data directly into the output buffer. That saves copying
large amounts of data unnecessarily, especially for read-modify-write
when only small modifications are being made.
-- glen
.
- Follow-Ups:
- References:
- A modern way to solve the "callback problem" from a subroutine?
- From: Henrik Holst
- Re: A modern way to solve the "callback problem" from a subroutine?
- From: relaxmike
- Re: A modern way to solve the "callback problem" from a subroutine?
- From: GaryScott
- Re: A modern way to solve the "callback problem" from a subroutine?
- From: glen herrmannsfeldt
- Re: A modern way to solve the "callback problem" from a subroutine?
- From: GaryScott
- A modern way to solve the "callback problem" from a subroutine?
- Prev by Date: Re: copy behavior of a fortran array as input argument
- Next by Date: Re: OO is "non-procedural"?
- Previous by thread: Re: A modern way to solve the "callback problem" from a subroutine?
- Next by thread: Re: A modern way to solve the "callback problem" from a subroutine?
- Index(es):
Relevant Pages
|