Nested functions should be exempt from sequential visibility rules

Timon Gehr timon.gehr at gmx.ch
Tue Apr 3 03:23:02 PDT 2012


On 04/03/2012 07:38 AM, Nick Sabalausky wrote:
> Regarding this:
>
> http://d.puremagic.com/issues/show_bug.cgi?id=790
>
> I submit that nested functions should be exempt from the usual sequential
> visibility rules. (Therefore, mutually recursive nested functions would
> become possible.)
>
> Or at the very *least*, this horrific C-like workaround should be possible:
>
> void foo()
> {
>      void b();
>      void a() {...};
>      void b() {...};
> }
>
> ...Flame away! ;)
>
>

This is the right way to work around this issue. It works now and does 
not imply any kind of overhead at runtime:

void foo(){
     void a()(){ ... }
     void b()  { ... }
}

However, I agree. Local functions that appear directly in sequence 
should be able to forward-reference each other. If some functions 
appearing in such a sequence have identical names, they should overload 
against each other.


More information about the Digitalmars-d mailing list