Thread overview
Local Functions
Feb 02, 2003
Kublai Kahn
Feb 02, 2003
Erik Rainey
Feb 09, 2003
Walter
February 02, 2003
Is there a provision for local functions in D?
Could you differentiate between global and local
functions?

In C, all the functions are global.  What if you
had local functions and global functions in D?
This is like public and private in C++ but different.
Local functions would only be accessible in a module.
But other modules or functions wouldn't be able to address
them out of scope.

This is an example:

local int signature(int lastname, middlename, firstname)
{
char string[];
...
return(0);
}



February 02, 2003
    Just a fine point, the symbols might have been globally accessable but
only if they were known. So in usage everything is local until exposed. It
is, effectively, data-hiding until someone knows how to unhide the symbol.

    More to the point what benefit can be derived from a local keyword when
everything is pretty much local by convention of using imports to get at
symbols you'd like to use, like C? I sense that the example code could be
convicingly crafted into a class to use those data-hiding features instead
of adding "local".

e.m.rainey

http://www.erik.rainey.name

--
e.m.rainey

http://www.erik.rainey.name
"Kublai Kahn" <Kublai_member@pathlink.com> wrote in message
news:b1hsjv$5td$1@digitaldaemon.com...
> Is there a provision for local functions in D?
> Could you differentiate between global and local
> functions?
>
> In C, all the functions are global.  What if you
> had local functions and global functions in D?
> This is like public and private in C++ but different.
> Local functions would only be accessible in a module.
> But other modules or functions wouldn't be able to address
> them out of scope.
>
> This is an example:
>
> local int signature(int lastname, middlename, firstname)
> {
> char string[];
> ...
> return(0);
> }
>
>
>


February 09, 2003
"Kublai Kahn" <Kublai_member@pathlink.com> wrote in message news:b1hsjv$5td$1@digitaldaemon.com...
> Is there a provision for local functions in D?

Yes. Just identify them as private,

    private void func() { }