🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2359

Re: Pointers

#2359
From: Herman Rubin
Date: Wed, 11 Nov 1992 13:26
66 lines
3688 bytes
In article <mwm.2lp7@contessa.palo-alto.ca.us> mwm@contessa.palo-alto.ca.us (Mike Meyer) writes:
>In <BxJ39L.LCv@mentor.cc.purdue.edu>, hrubin@mentor.cc.purdue.edu (Herman Rubin) wrote:
>> In article <mwm.2lit@contessa.palo-alto.ca.us> mwm@contessa.palo-alto.ca.us (Mike Meyer) writes:
>> >> You need explicit pointers to functions when the caller does not know
>> >> the name of the function being called, but the caller has received a
>> >> pointer to the function.

>> >No, you don't need *explicit* pointers to functions. It's perfectly
>> >reasonable (and I would argue, preferable) to allow function names
>> >in argument lists.

			....................

>Herman Rubin finding something difficult to read? That's amazing,
>considering what you call "obvious" code. Maybe it's the lack of
>extraneous characters that serve little or no useful purpose.

I presume that those who like 500-character names :-) might find it 
surprising that some people find that hard to read.

>> The way that I would want to use pointers
>> would be to have fl as the pointer to a fill function, and des as the
>> pointer to a descriptor array, of which the first two arguments would
>> be pointers to the current element of the buffer and the bounding position,
>> and then when it is needed make sure that the current element is correct,
>> and issue the call

>> 	*fl(*des);

>No problem. That call would look like:

>	fl(*des) ;

>> I will consider any suggestions to do this in a better manner, but I
>> am not willing to make it any less flexible, nor to put any more burdens
>> on the writers of the subprogram, nor of the (usually separately compiled)
>> fill functions.

>You want to make it better? Two things you can do. First, throw away
>the silly attachment to pointers per se, and let the compiler handle
>the trivia. When you call a function with a function as an argument,
>you give it the name of the function as the argument. When you receive
>a function as an argument, you declare it - AND USE IT - as a
>function. That means you can drop the extra "*" on the call, and on
>the reference to the function in the call. No explicit pointers
>needed; they are all implicit, and might not be there at all,
>depending on how good your compiler is.

The function is not an argument to something else.  I do not see how 
the code will run any better if we have to use something like

	superfill(*fl,*des)

than what I have suggested.  All superfill would do is to call *fl,
after putting more stuff on the stack, and do some more stack management.
So just as many pointers are used, anyhow.

There is no reason why the caller needs to know the NAME of the function,
in any case.  It is quite possible that even the object code might have
elided the name.  This is even more the case when the program under which
the caller is operating may want to change things at run time.  
-- 
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399
Phone: (317)494-6054
hrubin@snap.stat.purdue.edu (Internet, bitnet)  
{purdue,pur-ee}!snap.stat!hrubin(UUCP)
Technical Details
Message-ID: <BxJzzv.4H7@mentor.cc.purdue.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!spool.mu.edu!news.nd.edu!mentor.cc.purdue.edu!pop.stat.purdue.edu!hrubin
References: <mwm.2lit@contessa.palo-alto.ca.us> <BxJ39L.LCv@mentor.cc.purdue.edu> <mwm.2lp7@contessa.palo-alto.ca.us>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!spool.mu.edu!news.nd.edu!mentor.cc.purdue.edu!pop.stat.purdue.edu!hrubin
From: hrubin@pop.stat.purdue.edu (Herman Rubin)
Subject: Re: Pointers
Message-ID: <BxJzzv.4H7@mentor.cc.purdue.edu>
Sender: news@mentor.cc.purdue.edu (USENET News)
Organization: Purdue University Statistics Department
References: <mwm.2lit@contessa.palo-alto.ca.us> <BxJ39L.LCv@mentor.cc.purdue.edu> <mwm.2lp7@contessa.palo-alto.ca.us>
Date: Wed, 11 Nov 1992 13:26:18 GMT
Lines: 66