SitePoint Sponsor

User Tag List

Page 2 of 4 FirstFirst 1234 LastLast
Results 26 to 50 of 95
  1. #26
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Some of those features you mentioned would absolutely kill PHP. Why do we need pointers of any kind? PHP is nothing close to C or C++. Function pointers are also not needed, though I wouldn't mind seeing delegates and events as in C# for referencing functions.

    I can do without nested classes. never used them before.

    I also disagree about knowing the addresses of data. That's C-style type of features, nothing you will ever see in any scripting language.

    I would love to see namespace support in PHP.

    I would also love a decent IDE for PHP. Right now, as a great editor for PHP and other languages, I'm using PSPad, and that is working fine for me for now. But I miss Visual Studio for C#.
    Laudetur Iesus Christus!
    Christ's Little Flock
    Jesus is the Good Shepherd

  2. #27
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why do we need pointers of any kind?
    My guess from that statement is you don't have the experience i have with c and c++ therefore how can you make statements like: "that it would absolutely kill php" and "PHP is nothing close to C or C++". [give an example of how it would kill it. please do.] To me these statements come from hearsay . If not, prove yourself and give examples.


    Just to educate you I'll explain how php can benefit from pointers.

    How do you think polymorphism is implemented in procedure languages like c?
    I mean polymorphism is what allows you to build reusable blocks of code.

    example:

    directory_walker(&fnfile, &fndirectory);

    basically now we have a directory_walker that iterates as it normally would.. but when a file is identified it's passed to our supplied function file: fnfile.

    when people ask how do i copy all files and directories inside this folder.. or how do i delete files, rename files.. the answer is always pass a reference to your function that implements what you need and give them your directory_walker function


    I also disagree about knowing the addresses of data.
    pointers benefits comes with dynamic memory allocation. Again areas you've never worked in.



    Function pointers are also not needed, though I wouldn't mind seeing delegates and events as in C# for referencing functions.
    thats an oxymoron. delegates are nothing more than an array of function pointers. read on google about dispatch table.


    I can do without nested classes. never used them before.
    thats weird that you want namespaces but don't want nested classes. basically nested classes allow you the same benefit.. which is not to dirty your namespace which can cause conflict. If only one class requires another one why would you make it visable to all?


    I wonder why you bring this thread back up with no new information.
    reminds me of http://www.sitepoint.com/forums/show...highlight=php6
    but not as good.

    php was initially a procedure language so it should have the basic procedure constructs... pointers. It should be up to the developer on when and where it should be used... not that it be a requirement as in c.

  3. #28
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry

    Quote Originally Posted by leblanc
    My guess from that statement is you don't have the experience i have with c and c++ therefore how can you make statements like: "that it would absolutely kill php" and "PHP is nothing close to C or C++". [give an example of how it would kill it. please do.] To me these statements come from hearsay . If not, prove yourself and give examples.
    Wow, why so harsh? :P Of course I have experience with both C and C++. They're fine for what they are used for, but I see no purpose whatsoever for pointers in PHP. To me, it's luticrous to even suggest it. Pointers come with manual memory management which you have to do in C and C++. I hope we never have to do that in PHP.


    Quote Originally Posted by leblanc
    Just to educate you I'll explain how php can benefit from pointers.
    Educate me? Come on, really.

    Quote Originally Posted by leblanc
    How do you think polymorphism is implemented in procedure languages like c?
    I mean polymorphism is what allows you to build reusable blocks of code.
    PHP is OO, therefore we can use polymorphism as it is implemented in other OO languages.

    Quote Originally Posted by leblanc
    example:

    directory_walker(&fnfile, &fndirectory);

    basically now we have a directory_walker that iterates as it normally would.. but when a file is identified it's passed to our supplied function file: fnfile.

    when people ask how do i copy all files and directories inside this folder.. or how do i delete files, rename files.. the answer is always pass a reference to your function that implements what you need and give them your directory_walker function
    Or have the parameters be of a type of interface, and pass objects which are of that type.



    Quote Originally Posted by leblanc
    pointers benefits comes with dynamic memory allocation. Again areas you've never worked in.
    And, what makes you think so? I've worked in it plenty, I just don't care to have to worry about memory in PHP. Can you imagine the havoc that could be caused by developers on a shared server being able to allocate memory as they deem necessary?





    Quote Originally Posted by leblanc
    thats an oxymoron. delegates are nothing more than an array of function pointers. read on google about dispatch table.
    I know quite well what delegates are. I just think it's a much cleaner way to do the same thing.



    Quote Originally Posted by leblanc
    thats weird that you want namespaces but don't want nested classes. basically nested classes allow you the same benefit.. which is not to dirty your namespace which can cause conflict. If only one class requires another one why would you make it visable to all?
    I've used languages with the capability of nested classes, and have just never used them in all the projects I've done. I know what they can be used for, but just haven't done so.


    Quote Originally Posted by leblanc
    I wonder why you bring this thread back up with no new information.
    reminds me of http://www.sitepoint.com/forums/show...highlight=php6
    but not as good.
    Why? Am I now not allowed to post threads if there's been any hint of a discussion on the same topic? I posted it because i wanted to see where people felt PHP was going and what was going to happen to those not using its OO features, as stated in my first post.

    Quote Originally Posted by leblanc
    php was initially a procedure language so it should have the basic procedure constructs... pointers. It should be up to the developer on when and where it should be used... not that it be a requirement as in c.
    Pointers are far from the basic procedure constructs. True you have function pointers, but truthfully tell me you want the headaches of allocating and freeing memory for every little thing you want to allocate memory for? I'm happy to not have to use new and delete anymore. Can you imagine how much that'd scare the novice developers of PHP?

    Anyway, thanks for thoroughly insulting me. Really though, please don't assume my skill level or what I've done in the past. If I haven't worked in C and C++, do you really think I'd even have an idea what pointers were, and would have the nerve to post on something I had no idea about? I think not.
    Laudetur Iesus Christus!
    Christ's Little Flock
    Jesus is the Good Shepherd

  4. #29
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you insulted me by laughing at my first post. Worst part was that you provided no support in your statements. I just wanted to return the favor.

    Educate me? Come on, really.
    believe me your threads provide no insights either. I've already taught you where the benefits of pointers are. - whether you agree with me or not

    Quote Originally Posted by LEBLANC
    It should be up to the developer on when and where it should be used... not that it be a requirement as in c.
    I'm not saying that oop is not a better approach for large projects.
    command line tools is what would benefit from function pointers [short and sweet]. We could then implement are own delegates and get rid of all the observer patterns out there.




    don't assume my skill level, or assume that i can't defend my statements.

  5. #30
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Uhm ... Isn't callback a function pointer ?

  6. #31
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey thanks .. yes it is!

    I read about it when i first started php many years ago.. and since then never ran into it again.

    thanks for refreshing my memory. I guess we can already implement delegates now.


    damn c.. there we go people we have our function pointer which is what i wanted.

    I guess when namespaces are avaiable the Static class method call
    will be call_user_func(array('NamespaceName.More.MyClass', 'myCallbackMethod')); but we'll c.

  7. #32
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's the hacky variant too :
    PHP Code:
    $escape "htmlentities";
    echo 
    $escape("foobar"); 
    call_user_func works with object methods too, which makes it almost as powerful as a closure. Is that the same as a delegate btw. ? (I've never worked with C#)

    ...

    Staying on the PHP6-wishlist, it would actually be nice to make call_user_func implicit, so that this was possible :
    PHP Code:
    class Foo
    {
      function 
    blah() { }
    }
    $foo = Array('Foo''blah');
    $foo(); 
    Right now, it just gives a fatal.

  8. #33
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can at least simulate delegates yourself similar to c#.
    [
    you will need to create the add($obj) method ...base class

    you would need to create a loop that calls the value of all your function pointers [conforming to an interface; eventually call_user_func(array($obj, 'myCallbackMethod'));],

    and maybe more which c# does automatically... but yes.. because of function pointers we can at least simulate it.
    ]




    here is an example of my authenticate class in c#:

    //declare a delegate for the event
    public delegate void LoginHandler(object sender);
    public delegate void LogoutHandler(object sender);
    //declare the event using the delegate
    public event LoginHandler LoginEvent;
    public event LogoutHandler LogoutEvent;


    raises your events in authenticate class that then calls registered listeners methods: [c# automatically calls all registere members functions.]

    logout method
    PHP Code:
    if (this.LogoutEvent != null)
                
    this.LogoutEvent(this); 
    loggin method
    PHP Code:
    if (this.LoginEvent != null)
                
    this.LoginEvent(this); 




    now you have your auth class contain only reusable code.. and 2 main events are raised when certain methods are run.


    so how do you use it:
    default.aspx looks like this.
    PHP Code:
        protected void btnLogin_Click(object senderEventArgs e)
        {
            
    Authenticate auth = new Authenticate(this.usernamethis.passwordthis.cbxRememberMe);

    //add listeners
            
    auth.LoginEvent += new Authenticate.LoginHandler(auth_LoginEvent);

            
    auth.run();

            if (!
    auth.isValid())
            {

            }

        }





     
    private 
    void auth_LoginEvent(object sender)
        {
            
    //keep count of how many users are signed in. 

            
    Response.Redirect("/welcome.aspx");
        } 

    my authenticate class has to possible __constructs Authenticate(....) and Authenticate()

    besides default.aspx all other pages use an httpmodule so i don't have to specifically add Authenticate() to each page.]


    add listeners for logout can add user objects that delete temporary files created,
    save object history in database,
    and much more stuff by just

    LogoutEvent += ...

  9. #34
    SitePoint Guru dbevfat's Avatar
    Join Date
    Dec 2004
    Location
    ljubljana, slovenia
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    kyberfabrikken: how would you call "call_user_func_array" with that?

  10. #35
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    at a guess..
    PHP Code:
    $func = array('Foo', array('arg1''arg2')); 

  11. #36
    SitePoint Guru dbevfat's Avatar
    Join Date
    Dec 2004
    Location
    ljubljana, slovenia
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that's a function call. How about a class/object method with array arguments?

  12. #37
    SitePoint Evangelist
    Join Date
    Aug 2004
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this i don't have php installed on the pc i'm using @ school.
    PHP Code:
    call_user_func_array(array(&$obj,$method),array(&$arg1,$arg2,$arg3)) 
    http://www.php.net/manual/en/functio...func-array.php

  13. #38
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    Staying on the PHP6-wishlist, it would actually be nice to make call_user_func implicit, so that this was possible :
    PHP Code:
    class Foo
    {
      function 
    blah() { }
    }
    $foo = Array('Foo''blah');
    $foo(); 
    I agree, that would be a nice addition – and realistic, too.

  14. #39
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dbevfat
    that's a function call. How about a class/object method with array arguments?
    the first argument is a call back, so you can do:

    PHP Code:
    $func = array(array('Foo''bar'), array('arg1''arg2')); 
    for Foo::bar($arg1, $arg2);

    and:

    PHP Code:
    $func = array(array(& $foo'bar'), array('arg1''arg2')); 
    for $foo->bar($arg1, $arg2);

  15. #40
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dbevfat
    kyberfabrikken: how would you call "call_user_func_array" with that?
    I've read that eight times now, and I can't figure out what you mean ? This ?
    PHP Code:
    $callback = Array('Foo''blah');
    $result call_user_func_array($callback$args); 
    Or did you mean how would I do the same thing, if call_user_func was implicit ? If that's what you meant, the I'd say there is no reason to deprecate the existing api. We could still use call_user_func_array for thoose cases, which btw. are a bit rare anyway.

  16. #41
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    PHP Code:
    $func = array(array(& $foo'bar'), array('arg1''arg2')); 
    Is the ampersand needed if an object is passed into an array, or is this PHP4?

  17. #42
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ezku
    Is the ampersand needed if an object is passed into an array, or is this PHP4?
    That's PHP4.

  18. #43
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    leblanc: My post wasn't intended to be taken as you took it. I just think you are trying to make PHP more like C. If so, let's all use C. C and PHP are totally separate languages, C being much lower level and allowing a lot more control over memory, etc; that's why you have functionality for pointers, etc.

    I don't want to argue though, really.

    It's true callbacks could be seen as function pointers. i actually prefer the observer pattern, and now that it is very easy to implement in PHP5....

    I'm not questioning your skill level. I'm just questioning your understanding of PHP's use as a scripting language.

    kyberfabrikken:

    Interesting idea about the implicit call_user_func. Don't exactly see the purpose though. It seems a little counterintuitive, IMO.

    I wouldn't mind seeing support though for some more data structures. Right now there's basically just a hash/map/dictionary/whatever you want to call it, mixed with an array. Wouldn't mind having these separated into different functionality, like stacks and queues and regular numerically-indexed arrays. Maybe even a tree or something.

    Oh, as weird as this sounds, I wish PHP had enums. I find myself wanting to use them all the time for when you have several options of which one must be selected. Something like:

    PHP Code:
    enum Color
    {
    sundaymondaytuesdaywednesdaythursdayfridaysaturday
    Stupid example, but then you could do something like:

    PHP Code:
    function whatever(Color $color)
    {

    Laudetur Iesus Christus!
    Christ's Little Flock
    Jesus is the Good Shepherd

  19. #44
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    368
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    namespaces please please! and overloading will be nice

    other than that php5 is nice language (i despise php4 tho)

  20. #45
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On the more nerdy level, a feature to tell the interpreter to disregard a variable in the gc reference count would be practical too. Right now, cyclic references prevents gc and thus leaks memory in long running scripts. (At least until the process ends)

  21. #46
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    On the more nerdy level, a feature to tell the interpreter to disregard a variable in the gc reference count would be practical too. Right now, cyclic references prevents gc and thus leaks memory in long running scripts. (At least until the process ends)
    Wouldn't the solution to this be a better gc system? How do other (interpreted) languages handle this issue?

  22. #47
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    Wouldn't the solution to this be a better gc system? How do other (interpreted) languages handle this issue?
    Yes precisely. The place to "fix" this problem is not to give users some kind of functionality to do it, but to just take care of it in the garbage collection system. I think Python uses some kind of cyclic checker to avoid the issue. Both Java and Ruby use some kind of mark-and-sweep algo. Not sure about other languages.

  23. #48
    SitePoint Guru dbevfat's Avatar
    Join Date
    Dec 2004
    Location
    ljubljana, slovenia
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    Or did you mean how would I do the same thing, if call_user_func was implicit ? If that's what you meant, the I'd say there is no reason to deprecate the existing api. We could still use call_user_func_array for thoose cases, which btw. are a bit rare anyway.
    Yes, that's what I meant, I appologise for not being clear. Sorry all, I know how to call call_user_func_array very well.

    I have to disagree with you here, kyber, because if "call_user_func" is implicit, you can't call the "array" version that way. If any of these two is impicit, it should be the "array" function, because you can easily "simulate" the original call_user_func with it. Also, I've used "_array" many times, so I don't think the usage is rare. I'm guessing it's used a lot in Delegates, Proxies, plugin-type code and just about anywhere else where you can't/won't/shouldn't predict the number of arguments.

    But after looking at the code (by 33degrees) ...
    PHP Code:
    $func = array(array(& $foo'bar'), array('arg1''arg2')); 
    ... I think that this is actually a piece of quite ugly (unclear and confusing) code and I prefer the old way.

  24. #49
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    The Netherlands
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    While we're sharing wishlists... I'd love to see shorthand array notation support, a la JavaScript object literals/JSON . This can make your code a lot easier to read IMO, especially when passing arrays to methods/functions. And named parameters, but that seems to be out of the window (Minutes 4.8).

  25. #50
    SitePoint Enthusiast CrucialWebHost's Avatar
    Join Date
    Jun 2006
    Location
    Arizona
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mmm. PHP6 sounds like fun Personally, I'm waiting for CSS3 to hit the market! Some great, great features they're going to include with that. I'm still touching up on my PHP5 though, and have been diving more into classes. It's really improved my coding, both in terms of function and elegance.
    Crucial Web Hosting Our new site is live!
    Introducing Split-Shared and Split-Dedicated
    hosting products! Join our new Developer Network
    and check out the updated Site Showcase!


Bookmarks

Posting Permissions

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