PHP's global namespace

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default PHP's global namespace

    Why are PHP's system functions all in a global namespace?

    Won't this lead to chaos as new functions are added, which have names
    which clash with user-defined functions?
    --
    __________
    |im |yler [url]http://timtyler.org/[/url] [email]tim@tt1lock.org[/email] Remove lock to reply.
    Tim Tyler Guest

  2. Similar Questions and Discussions

    1. How do I keep individual .php's from being posted
      My DW operator left the company and I need to remove her from the website. I do not want to delete her PHP though. I can see other ex-employees in...
    2. Is there a Coldfusion equivalent to PHP's array_unique?
      I'm trying to filter out unique array elements in Coldfusion MX 7. Is there any coldfusion function equivalent to PHP's array_unique function? ...
    3. IPTables namespace - how to commandeer namespace
      I have a Perl module, IPTables::IPv4, that I've been developing for some time, and that is in the CPAN repository. I've expanded the module to...
    4. Something like PHP's PEAR::DB_NestedSet?
      This PHP module looks cool: http://pear.php.net/package/DB_NestedSet is there something like it in CPAN? -- dave
    5. PHP's References
      I'm trying to create a stack of class objects; but on cycling through them with 'foreach' I am unable to update their properties. What is the...
  3. #2

    Default Re: PHP's global namespace

    Tim Tyler wrote:
    > Why are PHP's system functions all in a global namespace?
    >
    > Won't this lead to chaos as new functions are added, which have names
    > which clash with user-defined functions?
    simple : do not use php functions as your own names. this would conflict
    in ANY language!

    regards

    timo

    Timo Henke Guest

  4. #3

    Default Re: PHP's global namespace

    Timo Henke <timonews@fli7e.de> wrote or quoted:
    > Tim Tyler wrote:
    >> Why are PHP's system functions all in a global namespace?
    >>
    >> Won't this lead to chaos as new functions are added, which have names
    >> which clash with user-defined functions?
    >
    > simple : do not use php functions as your own names.
    I was talking about new functions added to PHP.

    Avoiding those would apparently require precognition.

    Rarely have I seen user functions going into such a crowded namespace -
    picking function names feels a bit like navigating a minefield.
    > this would conflict in ANY language!
    Other languages don't put all their functions straight into a global namespace.
    --
    __________
    |im |yler [url]http://timtyler.org/[/url] [email]tim@tt1lock.org[/email] Remove lock to reply.
    Tim Tyler Guest

  5. #4

    Default Re: PHP's global namespace

    Tim Tyler wrote:
    > Other languages don't put all their functions straight into a global
    > namespace.
    I think this issue has more to do with the fact namespaces arn't a feature
    of PHP. They will be included in PHP5.

    Kind Regards,

    --
    Ian P. Christian
    Ian P. Christian Guest

  6. #5

    Default Re: PHP's global namespace

    On Sat, 18 Oct 2003 11:30:30 +0100, "Ian P. Christian" <pookey@pookey.co.uk>
    wrote:
    >Tim Tyler wrote:
    >
    >> Other languages don't put all their functions straight into a global
    >> namespace.
    >
    >I think this issue has more to do with the fact namespaces arn't a feature
    >of PHP. They will be included in PHP5.
    The last I heard the developers changed their minds on that, and they're not
    going to be implemented.

    Which is a big shame, because name clashes are inevitable once there's enough
    people working on a PHP project, or you use several libraries in one script.

    [url]http://news.php.net/article.php?group=php.internals&article=2124[/url]

    Hopefully they will, or already have, reversed that decision.

    --
    Andy Hassall (andy@andyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage analysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  7. #6

    Default Re: PHP's global namespace

    Andy Hassall wrote:
    > On Sat, 18 Oct 2003 11:30:30 +0100, "Ian P. Christian"
    > <pookey@pookey.co.uk> wrote:
    >
    >>Tim Tyler wrote:
    >>
    >>> Other languages don't put all their functions straight into a global
    >>> namespace.
    >>
    >>I think this issue has more to do with the fact namespaces arn't a feature
    >>of PHP. They will be included in PHP5.
    >
    > The last I heard the developers changed their minds on that, and they're
    > not
    > going to be implemented.
    >
    > Which is a big shame, because name clashes are inevitable once there's
    > enough
    > people working on a PHP project, or you use several libraries in one
    > script.
    Oh, that is a shame :(

    I personally use classes though to provide namespaceish functionality.

    Auth::getAuth(); etc. etc.

    Kind Regards,

    --
    Ian P. Christian
    Ian P. Christian Guest

  8. #7

    Default Re: PHP's global namespace

    Tim Tyler:
    > Timo Henke <timonews@fli7e.de> wrote or quoted:
    >> Tim Tyler wrote:
    >
    >>> Why are PHP's system functions all in a global namespace?
    >>>
    >>> Won't this lead to chaos as new functions are added, which have names
    >>> which clash with user-defined functions?
    >>
    >> simple : do not use php functions as your own names.
    >
    > I was talking about new functions added to PHP.
    >
    > Avoiding those would apparently require precognition.
    >
    > Rarely have I seen user functions going into such a crowded namespace -
    > picking function names feels a bit like navigating a minefield.
    In my 4 years of PHP experience this has not been a problem for me. I can't
    remember ever being bothered by this feature of PHP. It's seems like a
    terrible idea, but it doesn't really work that bad.

    André Nęss
    André Nęss Guest

  9. #8

    Default Re: PHP's global namespace

    Tim Tyler wrote:
    > Why are PHP's system functions all in a global namespace?
    >
    > Won't this lead to chaos as new functions are added, which have names
    > which clash with user-defined functions?
    Functions typically have a library prefix to get around this:
    array_sort()
    preg_replace()
    ..
    ..
    ..

    It would be nice if this convention were refined and the old functions
    would be removed in PHP 5.


    Keith Bowes Guest

  10. #9

    Default Re: PHP's global namespace

    With total disregard for any kind of safety measures Keith Bowes
    <do.not@spam.me> leapt forth and uttered:
    > It would be nice if this convention were refined and the old
    > functions would be removed in PHP 5.
    >
    Or at least a series of function aliases put in place that define a
    proper naming standard whilst maintaining a certain degree of
    backwards-compatibility.

    I don't see why this would cause noticable overhead. Many existing
    functions already have more than one name.

    --
    There is no signature.....
    Phil Roberts Guest

  11. #10

    Default Re: PHP's global namespace

    Tim Tyler <tim@tt1lock.org> wrote in message
    news:<HMy4KL.HIM@bath.ac.uk>...
    >
    > Why are PHP's system functions all in a global namespace?
    Because there is no concept of namespace in PHP, I believe.
    > Won't this lead to chaos as new functions are added, which
    > have names which clash with user-defined functions?
    Highly unlikely, especially given the fact that all functions
    added after a certain point are prefixed with their extension
    name (imap_*, ldap_*, mysql_*, etc.). If you are concerned
    with namespace issues, you might as well adopt a similar
    approach and prefix all your functions in a similar fashion.

    Cheers,
    NC
    Nikolai Chuvakhin Guest

  12. #11

    Default Re: PHP's global namespace

    Nikolai Chuvakhin <nc@iname.com> wrote or quoted:
    > If you are concerned with namespace issues, you might as well adopt a
    > similar approach and prefix all your functions in a similar fashion.
    Namespaces via a naming convention seems like a hack to me.

    For one thing, it fails to make referring to things in your
    "own" namespace any easier.

    Wouldn't it be better to use classes for this purpose?
    --
    __________
    |im |yler [url]http://timtyler.org/[/url] [email]tim@tt1lock.org[/email] Remove lock to reply.
    Tim Tyler Guest

  13. #12

    Default Re: PHP's global namespace

    Tim Tyler <tim@tt1lock.org> wrote in message
    news:<Hn00CC.LHs@bath.ac.uk>...
    > Nikolai Chuvakhin <nc@iname.com> wrote or quoted:
    >
    > > If you are concerned with namespace issues, you might as well adopt a
    > > similar approach and prefix all your functions in a similar fashion.
    >
    > Namespaces via a naming convention seems like a hack to me.
    But it's an easy one; that's what counts in a language that, above all,
    is supposed to be simple.
    > For one thing, it fails to make referring to things in your
    > "own" namespace any easier.
    This is by and large a matter of personal taste. You want your
    own namespace because having it makes you feel more comfortable.
    I don't want my own namespace because having it makes me feel
    less comfortable.
    > Wouldn't it be better to use classes for this purpose?
    To some people, yes. To an old-fashioned procedural type like yours
    truly, it's an unnecessary and potentially wasteful hassle.

    Cheers,
    NC
    Nikolai Chuvakhin Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139