Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23254 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68466 invoked by uid 1010); 11 May 2006 17:09:47 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 68450 invoked from network); 11 May 2006 17:09:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 May 2006 17:09:47 -0000 X-PHP-List-Original-Sender: ralph@smashlabs.com X-Host-Fingerprint: 69.2.42.244 unknown Linux 2.4/2.6 Received: from ([69.2.42.244:38696] helo=users.smashlabs.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 89/FF-19568-ADF63644 for ; Thu, 11 May 2006 13:09:46 -0400 Received: (qmail 28809 invoked by uid 210); 11 May 2006 12:09:25 -0500 Received: from 66.179.208.36 by users.smashlabs.com (envelope-from , uid 201) with qmail-scanner-1.24st (perlscan: 1.24st. Clear:RC:0(66.179.208.36):. Processed in 0.070017 secs); 11 May 2006 17:09:25 -0000 X-Qmail-Scanner-Mail-From: ralph@smashlabs.com via users.smashlabs.com X-Qmail-Scanner: 1.24st (Clear:RC:0(66.179.208.36):. Processed in 0.070017 secs Process 10000) Received: from unknown (HELO ?216.136.107.158?) (ralph@smashlabs.com@66.179.208.36) by 244.42.ntg.com with AES256-SHA encrypted SMTP; 11 May 2006 12:09:24 -0500 Message-ID: <446370F9.9060105@smashlabs.com> Date: Thu, 11 May 2006 12:14:33 -0500 User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 To: Jochem Maas CC: Antony Dovgal , internals@lists.php.net References: <446222C8.3090101@smashlabs.com> <44623E75.4070304@zend.com> <446273F7.2090702@iamjochem.com> In-Reply-To: <446273F7.2090702@iamjochem.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP6 OOP compiler feature question / request From: ralph@smashlabs.com (Ralph Schindler) Precisely. The point I was trying to make is that there should be fewer restrictions on method names of classes so that developers that are maintaining some distributable classes can keep the API clean. I've found myself in a situation where instead of using a method call isset(), I must use something like has().. and instead of unset(), I use remove(). All the while, when I overload the __isset() and __unset() methods, they actually forward the request to has() and remove(). I can think of several classes where the common sense method is a keyword: $session->isset($variable); $session->unset($variable); $trash->empty(); $long_hallway->echo(); $stage->exit(); $baseball_player->catch(); $baseball_player->throw(); $game_of_life_member->die(); $wood->break(); $vegetarian->food->steak->try(); $lawyer->case->try(); // double fault ;) Now I'm getting silly, but that was what my point was ;) -ralph Jochem Maas wrote: > Antony, I believe Ralph was using isset() and unset() purely > as arbitrary examples, e.g: > > class TestReservedKeywordMethods > { > function unset() { echo "unset
"; } > function echo() { echo "echo
"; } > function empty() { echo "empty
"; } > } > > $test = new TestReservedKeywordMethods(); > $test->unset(); > $test->echo(); > $test->empty(); > > PS: the underlying example does work, which gives me the feeling that > it not so much an architechural limitation but rather a performance issue > with regard to doing extra checks as to the context of an encoutered > T_UNSET (for example) to determine whether it's okay, but I'm guessing > really - (and it's probably is not exactly what Ralph is looking for): > > class TestReservedKeywordMethods > { > function __call($m) { echo "$m
"; } > } > > $test = new TestReservedKeywordMethods(); > $test->unset(); > $test->echo(); > $test->empty(); > > > > Antony Dovgal wrote: >> >> __isset() and __unset() methods are what you're looking for. >> They are available since 5.1.0. >> >> See http://www.php.net/manual/en/language.oop5.overloading.php >> >> On 10.05.2006 21:28, Ralph Schindler wrote: >> >>> Architectural restrictions aside, is it far off to ask if something >>> like this could be possible in PHP6: >>> >>> >> >>> class TestReservedKeywordMethods >>> { >>> public $value = "2"; >>> >>> public function isset() >>> { >>> if (is_null($this->value)) >>> return false; >>> else >>> return true; >>> } >>> >>> public function unset() >>> { >>> $this->value = 0; >>> } >>> >>> } >>> >>> $test = new TestReservedKeywordMethods(); >>> $test->isset(); >>> $test->unset(); >>> >>> ?> >>> >> >> > >