Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37381 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18758 invoked from network); 30 Apr 2008 18:21:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2008 18:21:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=jeremy@omegavortex.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=jeremy@omegavortex.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain omegavortex.net from 207.210.105.196 cause and error) X-PHP-List-Original-Sender: jeremy@omegavortex.net X-Host-Fingerprint: 207.210.105.196 unknown Linux 2.5 (sometimes 2.4) (4) Received: from [207.210.105.196] ([207.210.105.196:35923] helo=vps.omegavortex.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/E0-13507-0B8B8184 for ; Wed, 30 Apr 2008 14:21:36 -0400 Received: from host196-37.dissent.birch.net ([69.53.196.37] helo=[192.168.2.4]) by vps.omegavortex.net with esmtpa (Exim 4.68) (envelope-from ) id 1JrGvq-0005A0-LF; Wed, 30 Apr 2008 14:21:31 -0400 Message-ID: <4818B8A6.7050403@omegavortex.net> Date: Wed, 30 Apr 2008 13:21:26 -0500 Organization: Omega Vortex Corporation User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 To: Nathan Nobbe CC: internals@lists.php.net References: <7dd2dc0b0804300921y4d87fa25k3530cb864367aa24@mail.gmail.com> <4818B531.7040505@omegavortex.net> <7dd2dc0b0804301112j72dec359j3b2c042cfa4a6dda@mail.gmail.com> In-Reply-To: <7dd2dc0b0804301112j72dec359j3b2c042cfa4a6dda@mail.gmail.com> Content-Type: multipart/alternative; boundary="------------070503060404080400060809" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vps.omegavortex.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - omegavortex.net X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] why interfaces ? From: jeremy@omegavortex.net (Jeremy Privett) --------------070503060404080400060809 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Nathan Nobbe wrote: > On Wed, Apr 30, 2008 at 12:06 PM, Jeremy Privett > wrote: > > >> Nathan Nobbe wrote: >> >> >>> all, >>> >>> in recent weeks there has been a lot of arguing about what interfaces are, >>> arent (on php-general and now on the internals list as well) etc. etc. >>> >>> i am quite curious, why interfaces were added to the language in the first >>> place. note, i am not criticizing them, i am overjoyed that the language >>> has them, however i am curious about the history. is this something php >>> borrowed from java? does it have anything to do with 'entirely virtual >>> classes' in c++ ? i think that the history behind the addition of >>> interfaces to php, would shed a lot of light on their intended purpose for >>> use by php developers. >>> >>> thanks, >>> >>> -nathan >>> >>> >>> >>> >> "Interfaces" exist in different OO-enabled languages. PHP strengthened its >> object model in PHP 5, and thus the introduction of interfaces. I'm pretty >> sure the intended purpose of interfaces was just like pretty much every >> other language. You implement interfaces in order to provide a consistent >> API. As long as class A implements interface B, I can be for certain that >> it's going to contain methods C and D. Interfaces also give you the ability >> to "type hint" against them, requiring objects that implement that >> interface, thus ensuring you know what methods are on that object. >> >> Interfaces are a very powerful feature, when implemented properly. >> > > > thank you for you response Jeremy. i understand what interfaces are and i > have stressed their importance and power on php-general more than once. im > just curious more about what influenced the addition of them to php. im not > as old as many of them members in the community, so i know there are many > people who have dealt with more languages than i on a daily basis during > their careers. from my limited base of knowledge, i think java was the > first language to add the keyword 'interface'. and my presumption is that > that grew from the convention of creating 'interfaces' in c++ by writing > entirely virtual classes (as mentioned in gang of four). i have heard > different perspectives on this, but i figured, what better place to get to > the bottom of it than to ask the people who decided to add the interface > construct to php in the first place. > > -nathan > > Absolutely. I vaguely remember the discussion on php-general, though I don't think I participated. I think Java was the first language to implement the keyword, but the concept has definitely been around since C++. If I had to guess, the reasoning was probably that it felt a natural part of the object model, possibly influenced from Java. The whole reason I asked the other question previously about the properties in interfaces is because I've been working in C# lately, and it allows implementing properties in interfaces. I never needed the functionality before, but now that I've actually used it in another language, I've found a use-case for it and attempted in PHP only to find that it resulted in a fatal error. Thus, the inquiry to php-internals. -- Jeremy Privett C.E.O. & C.S.A. Omega Vortex Corporation http://www.omegavortex.net Please note: This message has been sent with information that could be confidential and meant only for the intended recipient. If you are not the intended recipient, please delete all copies and inform us of the error as soon as possible. Thank you for your cooperation. --------------070503060404080400060809--