May 28, 2003 Re: nested function problems | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dario | You're right that a static nested function could be (Windows), since it has no enclosing frame pointer. |
May 28, 2003 Re: nested function problems | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dario | "Dario" <supdar@yahoo.com> wrote in message news:baghm5$2u3b$2@digitaldaemon.com... > I found out that this restriction prevents two nested functions call one > another. > void func() > { > void one() > { > two(); // error: two is not declared yet > } > void two() > { > one(); // ok > } > } > So the work-around of moving the nested functions before they're used > does not always work. You're correct. |
May 28, 2003 Re: nested function problems | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Sorry, I don't grok your answer. Surely D works with windows callbacks? All I'm saying is to allow them inside D functions. "Walter" <walter@digitalmars.com> wrote in message news:bb1ghc$2j50$1@digitaldaemon.com... > It would be nice, but Windows doesn't know how to call nested functions. If > you're using it with other D functions, there's no need to give it a Windows > calling convention. > > |
June 27, 2003 Re: nested function problems | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bb38fa$1g7q$1@digitaldaemon.com... > Sorry, I don't grok your answer. > > Surely D works with windows callbacks? All I'm saying is to allow them inside D functions. D does work with windows callbacks. But the callbacks need to be module level functions, not nested functions. Windows does not support D nested functions. > > "Walter" <walter@digitalmars.com> wrote in message news:bb1ghc$2j50$1@digitaldaemon.com... > > It would be nice, but Windows doesn't know how to call nested functions. > If > > you're using it with other D functions, there's no need to give it a > Windows > > calling convention. > > > > > > |
July 09, 2003 Re: nested function problems | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Alas, the brain is weak, and I still don't get it. Nor do I understand what "Windows does not support D nested functions" means. Isn't this the wrong way round? "Walter" <walter@digitalmars.com> wrote in message news:bdie99$139m$2@digitaldaemon.com... > > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bb38fa$1g7q$1@digitaldaemon.com... > > Sorry, I don't grok your answer. > > > > Surely D works with windows callbacks? All I'm saying is to allow them inside D functions. > > D does work with windows callbacks. But the callbacks need to be module level functions, not nested functions. Windows does not support D nested functions. > > > > > "Walter" <walter@digitalmars.com> wrote in message news:bb1ghc$2j50$1@digitaldaemon.com... > > > It would be nice, but Windows doesn't know how to call nested functions. > > If > > > you're using it with other D functions, there's no need to give it a > > Windows > > > calling convention. > > > > > > > > > > > > |
July 09, 2003 Re: nested function problems | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:befroh$16hq$1@digitaldaemon.com... > > Alas, the brain is weak, and I still don't get it. Nor do I understand what > "Windows does not support D nested functions" means. Isn't this the wrong way round? > I think it's the same reason why Windows (or C linkers, really) doesn't support D class methods: They need an extra pointer to the enclosing scope. _____________________________ Julio César Carrascal Urquijo <adnoctum_at_phreaker_dot_net> |
July 09, 2003 Re: nested function problems | ||||
---|---|---|---|---|
| ||||
Posted in reply to Julio César Carrascal Urquijo | I never said I wanted them to be class methods. Just nested functions. "Julio César Carrascal Urquijo" <adnoctum@phreaker.net> wrote in message news:behdgl$2l2k$1@digitaldaemon.com... > > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:befroh$16hq$1@digitaldaemon.com... > > > > Alas, the brain is weak, and I still don't get it. Nor do I understand > what > > "Windows does not support D nested functions" means. Isn't this the wrong > > way round? > > > > I think it's the same reason why Windows (or C linkers, really) doesn't support D class methods: They need an extra pointer to the enclosing scope. > > _____________________________ > > Julio César Carrascal Urquijo <adnoctum_at_phreaker_dot_net> > > |
July 09, 2003 Re: nested function problems | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | Matthew Wilson wrote:
> I never said I wanted them to be class methods. Just nested functions.
Nested functions get access to the local variables in the parent functions as if they were globals. To accomplish that, they get a hidden parameter -- pointer to a previous stack frame. This feature requieres a special compiler support, and is thus not callable from C, Pascal, or whatever other compiled language. Not even the same language outside the scope of the function where it was defined - because it would inevatably break, since variable ordering is only known to compiler when it compiles a specific function.
This hidden-pointer-thingy is somewhat similar in concept to the class functions, though class functions must be simpler to workaround, since field ordering in a class can be reconstructed from its formal description, unlike the local variable order.
Tell me what you need nested functions with other calling conventions for?
-i.
|
July 09, 2003 Re: nested function problems | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Minkov | See my post of the 22nd May "Ilya Minkov" <midiclub@8ung.at> wrote in message news:bei20l$92j$1@digitaldaemon.com... > Matthew Wilson wrote: > > I never said I wanted them to be class methods. Just nested functions. > > Nested functions get access to the local variables in the parent functions as if they were globals. To accomplish that, they get a hidden parameter -- pointer to a previous stack frame. This feature requieres a special compiler support, and is thus not callable from C, Pascal, or whatever other compiled language. Not even the same language outside the scope of the function where it was defined - because it would inevatably break, since variable ordering is only known to compiler when it compiles a specific function. > > This hidden-pointer-thingy is somewhat similar in concept to the class functions, though class functions must be simpler to workaround, since field ordering in a class can be reconstructed from its formal description, unlike the local variable order. > > Tell me what you need nested functions with other calling conventions for? > > -i. > |
July 09, 2003 Re: nested function problems | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | In article <bdie99$139m$2@digitaldaemon.com>, Walter wrote: > > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bb38fa$1g7q$1@digitaldaemon.com... >> Sorry, I don't grok your answer. >> >> Surely D works with windows callbacks? All I'm saying is to allow them inside D functions. > > D does work with windows callbacks. But the callbacks need to be module level functions, not nested functions. Windows does not support D nested functions. How about static nested functions, then? AFAIK, they're just ordinary functions, only defined in a function scope, and could as well be called by Windows. -Antti |
Copyright © 1999-2021 by the D Language Foundation