This topic drew my interest because I had a related idea. In our application it's relatively common to create script files that serve as libraries to be #included. Although not everyone follows this trend, typically it makes sense for all or most of entities in those files to be registered as shared. They may get big and be included by multiple modules, so it probably saves some compilation time, and in case users want to implement any type of interaction between modules involving the entities, they don't have to modify the library file or come up with workarounds.
As such, I have written files that have over a hundred occurrences of the "shared" keyword, at the beginning of every declaration that allows it. This is a really minor inconvenience but occasionally it gets in the way, such as when I initially forget to add it and have to insert it in several dozen lines, or when I want to temporarily make all entities non-shared to test something. It also looks too verbose to my liking.
Because included files are also typically wrapped in a namespace, my idea to solve this was the following syntax:
shared namespace ns { // shared namespace automatically declares all entities in corresponding block as shared
class Object {} // Object is shared class
void func() {} // func is shared function
funcdef void VoidFunc(); // funcdefs are allowed in shared namespace blocks and act as always
typedef double float64; // same applies to typedefs
//int n; // error: variables cannot be shared
}
namespace ns { // being shared is not a property of the namespace itself, only of a particular namespace block
// different namespace blocks with the same name may be declared as non-shared
class Derived : Object {} // Derived is not shared
shared int zero() {} // shared declaration in non-shared namespace block still allowed
funcdef int IntFunc(); // funcdefs shared by default
int n; // ok: n is not declared as shared
}
However, without support for anonymous namespaces, this might be quite inconvenient in instances where a named namespace is undesired, so later I also came up with a simpler, minimal syntax:
namespace ns {
shared {
class Object {}
void func() {}
funcdef void VoidFunc();
typedef double float64;
//int n;
}
class Derived : Object {}
shared int zero() {}
funcdef int IntFunc();
int n;
}
I think implementing one of those or a similar syntax would be helpful.