> -----Original Message----- > From: Guilherme Blanco [mailto:[EMAIL PROTECTED] > Sent: Monday, July 23, 2007 8:21 PM > To: David Coallier > Cc: David Zulke; Dmitry Stogov; Arpad Ray; Hans Lellelid; PHP > internals > Subject: Re: [PHP-DEV] Simple Namespace Proposal > > > > > > > > 2) In short and clear, why are braces not being used ? > C++, C# uses > > > it. (Short answer and if the answer is "Developer didn't > want to do > > > it..." just say "Usual" > > > > We are not C++. Python doesn't use braces. > > The only neediness for braces is placing several namespaces > into one > > file, but one of the goal of our concept is avoiding this. > > > Your answered like "We are not like C#, but we are like > Python.". I'm not the one that will point that Python always > try to be a unique language or will criticize you.
Ok. Look into Pascal, Ada, Modula, Oberon, ... All of them allows only one module per file. Java even allows one class per file. > I've read dozen of PHP books, and what I suggested earlier is > only based on what I've read. The topic is always entitled as > "block scope". Since namespace is a block scope too, so it's > a commom sense. It's easier to read, easier to understand, etc. "Block scope" has nothing common with namespaces and classes. Class declaration uses braces but it doesn't mean that it is a "block scope". > Your short answer is "no, because it's not needed, since > there'll be only one namespace per file." > > It doesn't matter is one, two or hundreds namespaces are > defined in a single file, but the KIS idea must remain. > Stanislav mentioned that file names, directories, etc do not > require braces. > > Ok, but we are not talking about File System, we are talking > about language structure and standards. PHP uses braces to > define new scope, like block scope, loops, if-else, switch, > function, classes, etc. Again. "block scope" or "block statement" may be used instead of statement, but it doesn't relay with class and even function. > But namespaces are different! > Why different? It's another language functionality, as all > others I mentioned. So, let's change the PHP to allow only > one class per file, and remove the braces' need too. Classes > are different too. Or maybe better... only one namespace per > file and only in one file. Namespaces are different, as you > said! If PHP supports more than one namespace per file, why > not provide it to developers? It's a functionality, not a > bug. Do not restrict functionalities because you do not like them. Namespaces are really different. They like packages in Java and one file cannot belong to several packages. > I'm repeating... it's up to the PHP developer decide if he > wants this or that way to code. Currently he's able to define > more than one class in a single file. Ok, I don't do it, and > will do one namespace per file (and continue one class per > file), but I don't think that this restriction is really necessary. > > That's my final point, and my last try to talk about braces. > Seems you do not like external ideas. I developed concepts with braces and without and after thoughts and discussions decide that having braces makes only mess. Thanks. Dmitry. > > > > I'll give you an example... PHP Doctrine package has a > lot of files, > > > hundreds... there is a way to compile it in a single > file, to save > > > some memory usage for including these files. Including a > single file > > > > Putting all code together in the same file rarely saves any > > significant amount of memory and leads to a very messy code. Of > > course, it's your application and your decision, but I > don't see any > > reason to promote such style on the language level. Anyway, > if you can > > do with everything in single file, I think having single namespace > > won't hurt. > > > It saves the time needed to include all the files and also > the memory that it saves for calling require_once, > include_once, etc. Forget this, it was only one illustration > that such optimizations (what Doctrine call as compile into a > single file) does. You keep all the hundred files but you > have one "compiled" with all the code. > > > > > 2 - Overwrite will be implemented? > > > Something like: overwrite function strlen( ... ) { ... } > > > > What it's supposed to do? > > I think it's overload. Someone mentioned earlier and I was > curious if you implemented this or not. > > > > > <?php > > > class Bar { ... } > > > > > > <?php > > > namespace Foo { > > > class Bar { ... } > > > } > > > > > > <?php > > > import Foo; > > > > For 100th time, import Foo is a no-op. I'm thinking about > prohibiting > > it at all... If you do import Foo::bar you'll get an error > if Bar is > > already defined. > > I was supposed to suggest triggering a E_NOTICE that Bar is > already defined and instantiate the Bar class of "global". > But if you want something more radical... =) > > > > > 4 - Will namespaces support anything else than functions > and classes > > > (like constants, for example)? > > > > Not likely, since there's no such thing as free-form > constant. Though, > > in fact, we might add one (i.e. const X = 'foo' which is define('X', > > 'foo')) ... But, if you need a constant, why not put it > into a class? > > Bad example I did. I was supposed to ask for namespace level > variables. Not in global scope, not in class scope. =) > > > > I have another questions regarding namespace support... well, > about function support. > > 1- How will is_a, instanceof, will behave in this situation? > > $a = new NS1::SubNS1::MyClass(); > > echo is_a( $a, "MyClass" ); ????? true/false? > echo is_a( $a, "NS1::SubNS1::MyClass" ); ??? > > > 2- Will exist some namespace specific functions? Examples: > > $a = namespace_contains( "SomeClass" ); > $b = namespace_exists( "NS1" ); > $c = is_a_namespace_class ( $NS1ObjString ); > // ...... > > > > Best regards, > > -- > Guilherme Blanco - Web Developer > CBC - Certified Bindows Consultant > Cell Phone: +55 (16) 9166-6902 > MSN: [EMAIL PROTECTED] > URL: http://blog.bisna.com > São Carlos - SP/Brazil > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php