From: carroll@dori.cis.udel.edu (Mark C. Carroll)
Subject: Re: Pointers
Organization: University of Delaware, Newark
Date: Wed, 18 Nov 1992 15:34:26 GMT

In article <BxrABr.KyE@mentor.cc.purdue.edu> hrubin@mentor.cc.purdue.edu (Herman Rubin) writes:
]In article <1992Nov15.033115.3324@udel.edu> carroll@thorin.cis.udel.edu (Mark C. Carroll) writes:
]]In article <BxIoDv.72J@mentor.cc.purdue.edu> hrubin@pop.stat.purdue.edu (Herman Rubin) writes:
]
]			........................
]
]]You need *some* way of passing functions as arguments. Pointers are
]]most definitely *not* necessary. Functions can be passed many ways -
]]perhaps by some form of name passing, perhaps by passing closures,
]]perhaps by passing some sort of magical function id, perhaps...
]
]]The implementation model doesn't matter. All that matters is that you
]]be able to pass functions as arguments and call the functions that you
]]receive as arguments.
]
]When I want to call (not pass as an argument) the function or procedure
]which is designated somewhere, I effectively want a pointer.  There is
]a little known notation in logic for this, but it still is a pointer.
]
]The example I gave is to call the function_whose_name_I_do_not_know
]of the argument_whose_name_I_do_not_know.  What I do know is a way
]to contact that part of the program which does know.  Whatever you
]call that, it is using pointers.  BTW, in that example, I also
]want to use elements of the remote argument to read the buffer.

So what??

You are _still_ just passing functions around the program. It doesn't
matter how it gets done. The program can _still_ pass the function as
a closure, or as an identier, or as a magic hash-code. Who cares how
it's passed? What matters is that you need to be able to pass a
function around the program as an argument. You need to be able to
call that function anywhere where it was passed as an argument. That's
it. Why do you insist on forcing the compiler to use a restrictive
implementation when that restriction does not give you _any_ advantage
of _any_ kind.

You're insisting on using a uselessly complex, restrictive, and
obfuscatory abstraction. Function pointers in a language like C carry
a _lot_ more garbage than first-class functions. Why do you insist
on that baggage when it doesn't buy you anything?

Consider Modula-3.  In Modula-3, you have procedure types. Procedures
get passed around the program as arguments. When you receive a
procedure argument, you can apply that procedure argument. That's
_exactly_ the same thing as passing function pointers in C. The
difference is, you're _only_ capturing the necessary abstraction.

Or consider Scheme. In Scheme, you can pass closures around your
program. (A closure is a pair containing an environment and a sequence
of code.) By using closures, you get absolutely everything that you're
demanding from function pointers, only it's far more general with _no_
runtime cost.  

Why do you believe that Cs function pointers are preferable to Mod-3's
procedure types or Scheme's closures?

	<MC>
-- 
[ Mark Craig Carroll <MC> ] You say you know no tricks, have no talents -
[ U of Delaware, CIS Dept ] Isn't everyone supposed to have their own?
[ Grad Student/Lab Hacker ] Yes, but few are obvious. Few draw notice to those
[ carroll@udel.edu        ] who posess them, like flags waving themselves.