The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2012, 05:35:00 AM

Login with username, password and session length


Pages: 1 [2]
  Print  
Author Topic: php wordpress plug in design and oo question  (Read 1336 times)
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« Reply #15 on: September 13, 2009, 07:58:54 PM »

Ok, thanks... so this thing is monkey rigged? it actually works...

so in the doparse() below where they call

$this->q->add($c, &$this);

the ampersand is redundant and that just calling

$this->q->add($c, $this); would be the same?

Code:
class Parser {
    function doparse()
{
//                                               
//                                  +-------> are you saying they dont need the &$this here?
//                                  | and that $this would pass by reference anyway?
//                                  v     
              $this->q->add($c, &$this);
}

class Q extends N {
       var $t;
       var $s;
       var $st;
       function add($x, & $parser) {
                if ($x == '_'&&$this->t!='b') {
                       $d = $parser->readahead();
                       if ($d == '_') {
                               $this->t = 'b';
                       }
                }
               
                return $parser->setstate('c', $this);
        }
}  // end class q


Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 9896



View Profile
« Reply #16 on: September 13, 2009, 08:05:29 PM »

In PHP4, most things were passed by value by default: but I thought that objects were passed by reference no matter what. I only ever really saw wide use of explicit passing by reference used for arrays in PHP4.

In any case, in PHP5 objects are CERTAINLY passed by reference, so yes, the & would be redundant.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« Reply #17 on: September 13, 2009, 08:22:38 PM »

okay thanks... makes a little bit more sense to know that was funky and to now know why...   

and finally,

I see private , protected and public is there no 'published' ?
Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 9896



View Profile
« Reply #18 on: September 14, 2009, 09:02:49 AM »

No, because the notion of published was for usage in IDEs like Delphi. Published was actually a Borland extension to the spec so that you could have drag/dropable objects with methods and events that would show in the object inspector.

Everything is public by default, so exposure-unspecified vars and functions will be public. Private and protected work as you would expect. Checkout the magic methods for more fun and entertainment: http://us2.php.net/manual/en/language.oop5.magic.php

Note that __get and __set are underused for a reason: they sort of suck compared to a real early-bind OO implementation.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: 1 [2]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!