Op 2010-07-26 14:34, Martin het geskryf: > Let me see, if I got the idea (Graeme's idea) correct.
Please note: I did not say my ideas are perfect, just that they are suggestions that was put out there. Discussions regarding namespaces and ideas/suggestions need to filter out the finer details of what could or couldn't work. This is the whole point of this discussion at this stage. > lets say we have: > rtl: classes, sysutils, but *not* foo > rxlib: sysutils, foo (all in namespace rx) > mylib: foo (namespace my) > It the my project itself: sysutils, my (no namespace?) > > uses classes; // the one from rtl > uses sysutils; // the one from my project? No. I envision that not defining a namespace means if falls under the "global" namespace, and the global namespace takes priority. So with saying that, FPC's RTL would probably be compiled as-is without defining any namespace, giving it search priority. In your example above, sysutils inside the project conflicts with the sysutils of the rtl, so the project will have to define a namespace for its sysutils unit. eg: 'unit sysutils namespace myproject;' or compile the project with a namespace compiler parameter. > uses rtl.sysutols; // rtl As I mentioned above. Reducing the amount of required changes (which would make FPC developers happy), means that the RTL is not compiled with any namespace, so to reference the RTL's Sysutils unit, you would simply use: uses sysutils; > uses foo; // error ambigious? Yes, just like you would get with the current FPC compiler (which doesn't have namespace support). You need to specify which namespace the 'foo' unit belongs too. Neither the RTL nor the project contains a 'foo' unit, so the compiler will give a conflicting unitname error (or something like that). > uses rc.foo, my.foo, my; // there is a unit my > ... > begin > foo.a; // error, which foo? > my.foo.a; // is that unit my, record foo.a OR unit my.foo ? Good point, I haven't thought that far. I only worked though of the uses clause. Maybe when referencing a namespace we need a different syntax? Something that distinguishes between a <unit name>.<var or record> reference and a <namespace>.<unit name> reference. I'm not sure what will fit nicely in the Object Pascal language. Generics already uses the < and > characters. The _ is not allowed as the starting character of a unit name, so maybe that could be used? Or maybe the # character? eg: uses rc.foo, my.foo, my; ... begin foo.a; // is the <unitname>.<var or record> syntax _my.foo.a; // is <namespace>.<unit name>.<var or record> syntax. ...not sure if _ should be used in the uses clause as well for consistency. Currently a '.' (dotted) unit name is not allowed in the uses clauses, so FPC could know that a 'rc.foo' means <namespace>.<unit>. But consistent syntax is probably better, so the uses clause will change to. uses _rc.foo, _my.foo, my; Second suggestion is changing the _ character to a # character, but then again, that conflicts with a hex char notation, so is probably not a good idea. > But worst of all > uses sysutils; // the one from my project? No, because the RTL is not compiled with a namespace, so falls under the "global" namespace with takes preference over project units or all other namespaces. This then stays consistent with how developers understood the code as it currently works. Compiler included units take preference. Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal