in reply to Re^2: Perl vs. PHP
in thread Perl vs. PHP

Classes are better, but they still have no namespaces. Everything is in one global namespace.

Replies are listed 'Best First'.
Re^4: Perl vs. PHP
by adrianh (Chancellor) on Aug 14, 2004 at 10:34 UTC
    Classes are better, but they still have no namespaces. Everything is in one global namespace.

    Just being devils advocate for a minute: How is this different from Perl?

    Perl mangles the package and class concepts together - it doesn't really have namespaces either (in the sense they are used in C#, C++, Smalltalk, etc.)

      It's different because I, as a Perl programmer, don't have to worry about the next function name I choose colliding with any of over 3000 built-ins or any function defined in any file I might ever want to include.

        It's different because I, as a Perl programmer, don't have to worry about the next function name I choose colliding with any of over 3000 built-ins or any function defined in any file I might ever want to include.

        Don't PHP classes solve exactly that problem? For example:

        <?php class foo { function hello() { print "hello world\n"; } } class bar { function hello() { print "greetings planetary body\n"; } } foo::hello(); bar::hello(); ?>

        Can't you treat PHP classes like Perl packages?

        (Disclaimer: I'm not a PHP coder so I'm probably missing something blatant ;-)