December 01, 2001 Re: some more questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to nancyetroland | I agree with the sentiment. It will just need comments from some more knowledge able people (are you lurking, Walter?) about whether it is technically feasible without specail cases in the parser. -- 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))) ] |
December 01, 2001 Re: some more questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russ Lewis | "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3C08E404.67B8A193@deming-os.org... > I agree with the sentiment. It will just need comments from some more knowledge able > people (are you lurking, Walter?) about whether it is technically feasible without specail > cases in the parser. I have run into some problems with it. Specifically, pointers to functions. C: int (*fp)(args); // ugly, but servicable D: int (*)(args) fp; // ?? int (args)* fp; // ?? arrgh |
December 02, 2001 Re: some more questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:9ubqoj$1lh7$1@digitaldaemon.com... > I have run into some problems with it. Specifically, pointers to functions. > > C: > int (*fp)(args); // ugly, but servicable > > D: > int (*)(args) fp; // ?? > int (args)* fp; // ?? arrgh Solution: int(args) fp; No need for * here anyhow, since we can only have pointers to functions, not function variables by themselves. |
December 02, 2001 Re: some more questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | And for pointers to methods, I'd suggest the following: int.(args) mp; |
December 02, 2001 Re: some more questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:9ucq38$2o5m$1@digitaldaemon.com... > And for pointers to methods, I'd suggest > the following: > int.(args) mp; I'm trying to avoid pointers to members <g>. |
December 02, 2001 Re: some more questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:9uctpk$2rvp$3@digitaldaemon.com... > "Pavel Minayev" <evilone@omen.ru> wrote in message news:9ucq38$2o5m$1@digitaldaemon.com... > > And for pointers to methods, I'd suggest > > the following: > > int.(args) mp; > > I'm trying to avoid pointers to members <g>. A question then. Since D doesn't have macroses, it would be hard to define a simple syntax for message maps. Pointers to members are not supported. If I want to write a GUI library for D, what other ways could I use then? WndProc and switch() (aka back to the WinAPI days)? nah, totally ditches the idea... anything else? Just to make this all clearer, a code that could be part of a GUI library: // =================================================== // using pointers to methods, if they were implemented class Button { void.() OnClick int WndProc(uint uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_LBUTTONDOWN) OnClick() } } class MyForm { Button cmdOk; this() { cmdOk.OnClick = cmdOk_Click; } void cmdOk_Click() { // do something useful... } } // ============================================= // using map tables, if there were macroses in D class MyForm { BEGIN_MESSAGE_MAP(MyForm) ON_NOTIFY(IDC_CMDOK, BN_CLICKED, cmdOk_Click) END_MESSAGE_MAP() void cmdOk_Click() { // do something useful... } } // ======================================== // using if() or switch(), already possible class MyForm { int WndProc(uint uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_COMMAND && hiword(wParam) == IDC_CMDOK) cmdOk_Click(); } void cmdOk_Click() { // do something useful... } } |
December 02, 2001 Re: some more questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | I am not sure why you would want to avoid pointers to member functions... they sure can be useful sometimes. Declaration syntax could be: class Foo { void Fn1(int a); void Fn2(int a); } void Foo:(int) memfuncptr = Foo.Fn1. Calling syntax could then be: object.memfuncptr:(args); Which kinda matches the declaration syntax I proposed. Ok, so I can't think of a decent syntax either. ;( But I'd still like to see them included in D. Sean "Walter" <walter@digitalmars.com> wrote in message news:9uctpk$2rvp$3@digitaldaemon.com... > I'm trying to avoid pointers to members <g>. |
December 02, 2001 Re: some more questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | "Sean L. Palmer" <spalmer@iname.com> wrote in message news:9ud1c0$2vqm$1@digitaldaemon.com... > I am not sure why you would want to avoid pointers to member functions... they sure can be useful sometimes. > > Declaration syntax could be: > > class Foo > { > void Fn1(int a); > void Fn2(int a); > } > > void Foo:(int) memfuncptr = Foo.Fn1. > > Calling syntax could then be: > > object.memfuncptr:(args); > > Which kinda matches the declaration syntax I proposed. > > Ok, so I can't think of a decent syntax either. ;( But I'd still like to see them included in D. Yeah, syntax is a question. Still I'd like to see them in D, especially if they are able to hold pointer to object together with pointer to method, as I've stated before =) |
December 03, 2001 Re: some more questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | "Sean L. Palmer" wrote:
>
> I am not sure why you would want to avoid pointers to member functions... they sure can be useful sometimes.
So can operator overloading. So can the preprocesser. So can multiple
inheritance. So can templates. The better question might be, what (if
anything) will be in D to replace the functionality?
Dan
|
December 03, 2001 Re: some more questions concerning D specs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:9ucvsu$2u60$1@digitaldaemon.com... > Since D doesn't have macroses, it would be hard to define > a simple syntax for message maps. Pointers to members > are not supported. If I want to write a GUI library for > D, what other ways could I use then? WndProc and switch() > (aka back to the WinAPI days)? nah, totally ditches the > idea... anything else? What you could do is create an array of function pointers, indexed by the message number. A default one is provided by the gui library. You could write an associative array that contains just the messages you want to dispatch on. So, you test your local associative array, if it's there, dispatch. Otherwise, use the default array, and dispatch to that one. Member function pointers are not necessary, just use a static member function. |
Copyright © 1999-2021 by the D Language Foundation