Thread overview
Make Function Pointers Like Delegates: funcptr Keyword
Apr 06, 2002
Russ Lewis
Apr 06, 2002
Pavel Minayev
Apr 07, 2002
Russ Lewis
Apr 07, 2002
OddesE
Apr 07, 2002
Pavel Minayev
Apr 07, 2002
OddesE
Apr 07, 2002
Pavel Minayev
Apr 07, 2002
Walter
April 06, 2002
Let's bite the bullet and require a funcptr keyword for all function pointers:

    int funcptr(int x,int y) myFunctionPointer;

I know, I know, it's hard for all us old C guys to change...but let's admit it - the old syntax never really worked.  Let's just get it over with, admit our collective stupidity, and start using a keyword so that things are actually readable.

I know that the first time I saw a declaration like

    typedef unsigned short (* __pascal Hook_t)(char __far *,unsigned
short,unsigned short);
        (actual line from winc.h)

It wasn't even remotely clear what was being declared.  At least, with a funcptr keyword, newbies (and quick readers) have a chance...

--
The Villagers are Online! http://villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]


April 06, 2002
"Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3CAF3CB4.E08DE90F@deming-os.org...

> It wasn't even remotely clear what was being declared.  At least, with a funcptr keyword, newbies (and quick readers) have a chance...

I guess, since delegates work with static functions as well, they just superseed C-style function pointers, which are left for compatibility with C and API. After all, if you use a function pointer, you can't be sure if somebody will want to use method of class as a callback, so you'll end up declaring it as a delegate after all...


April 07, 2002
Pavel Minayev wrote:

> "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3CAF3CB4.E08DE90F@deming-os.org...
>
> > It wasn't even remotely clear what was being declared.  At least, with a funcptr keyword, newbies (and quick readers) have a chance...
>
> I guess, since delegates work with static functions as well, they just superseed C-style function pointers, which are left for compatibility with C and API. After all, if you use a function pointer, you can't be sure if somebody will want to use method of class as a callback, so you'll end up declaring it as a delegate after all...

I'm not against doing this...but if we're going to have one keyword for both, I think that "funcptr" is better than "delegate" since it is more widely known.

--
The Villagers are Online! http://villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]


April 07, 2002
"Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3CAF9D71.C3D71327@deming-os.org...
> Pavel Minayev wrote:
>
> > "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3CAF3CB4.E08DE90F@deming-os.org...
> >
> > > It wasn't even remotely clear what was being declared.  At least, with
a
> > > funcptr keyword, newbies (and quick readers) have a chance...
> >
> > I guess, since delegates work with static functions as well, they just superseed C-style function pointers, which are left for compatibility with C and API. After all, if you use a function pointer, you can't be sure if somebody will want to use method of class as a callback, so you'll end up declaring it as a delegate after all...
>
> I'm not against doing this...but if we're going to have one keyword for
both,
> I think that "funcptr" is better than "delegate" since it is more widely known.
>

I agree with you that function pointers are quite
unreadable in C/C++. I think your idea of a keyword
for function pointers is a very good one. I support
delegate instead of funcptr though, because I don't
like abbreviations. Also functions that are part of
a class are often called methods. Delegate seems
like a good combination of the concept pointer to
method or function. However, it seems that Walter
is thinking of ditching the whole keyword altogether,
instead accepting pointers to methods as well as
pointers to functions with the same notation as in
C/C++?


--
Stijn
OddesE_XYZ@hotmail.com
http://OddesE.cjb.net
_________________________________________________
Remove _XYZ from my address when replying by mail








April 07, 2002
> method or function. However, it seems that Walter
> is thinking of ditching the whole keyword altogether,
> instead accepting pointers to methods as well as
> pointers to functions with the same notation as in
> C/C++?

I didn't remember Walter saying something like that!?


April 07, 2002
"Pavel Minayev" <evilone@omen.ru> wrote in message news:a8po42$25s8$1@digitaldaemon.com...
> > method or function. However, it seems that Walter
> > is thinking of ditching the whole keyword altogether,
> > instead accepting pointers to methods as well as
> > pointers to functions with the same notation as in
> > C/C++?
>
> I didn't remember Walter saying something like that!?
>

He said this:

"It really is just an enhanced "pointer to function",
so it should declare in a manner similar to pointer to
function. I thought of using another special character
to replace the * in pointer to function, but that got
too wierd looking <g>. I considered *., but that looked
too confusing with C++ pointers to members."

in his last answer on your thread "New D site": a8ggfq$cdp$1@digitaldaemon.com

So that is where I got it from...
I should have said "with the same notation as
in D" though... :)



--
Stijn
OddesE_XYZ@hotmail.com
http://OddesE.cjb.net
_________________________________________________
Remove _XYZ from my address when replying by mail





April 07, 2002
"OddesE" <OddesE_XYZ@hotmail.com> wrote in message news:a8q1bi$2kph$1@digitaldaemon.com...

> "It really is just an enhanced "pointer to function",
> so it should declare in a manner similar to pointer to
> function. I thought of using another special character
> to replace the * in pointer to function, but that got
> too wierd looking <g>. I considered *., but that looked
> too confusing with C++ pointers to members."

I thought that was the explanation of why he chose the "delegate" keyword over the traditional C way?

Walter, could you pleeease make it clear? Are you
going to use the "delegate" syntax or not?


April 07, 2002
"Pavel Minayev" <evilone@omen.ru> wrote in message news:a8q2jf$2lv3$1@digitaldaemon.com...
> "OddesE" <OddesE_XYZ@hotmail.com> wrote in message news:a8q1bi$2kph$1@digitaldaemon.com...
> > "It really is just an enhanced "pointer to function",
> > so it should declare in a manner similar to pointer to
> > function. I thought of using another special character
> > to replace the * in pointer to function, but that got
> > too wierd looking <g>. I considered *., but that looked
> > too confusing with C++ pointers to members."
> I thought that was the explanation of why he chose the "delegate"
> keyword over the traditional C way?
> Walter, could you pleeease make it clear? Are you
> going to use the "delegate" syntax or not?

For the declaration, I'm planning on using "delegate".