Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67105 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71592 invoked from network); 21 Apr 2013 22:55:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Apr 2013 22:55:48 -0000 Authentication-Results: pb1.pair.com header.from=rstoll@tutteli.ch; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rstoll@tutteli.ch; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: rstoll@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:57026] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FD/B4-46657-17E64715 for ; Sun, 21 Apr 2013 18:55:46 -0400 Received: (qmail 11761 invoked from network); 22 Apr 2013 00:55:42 +0200 Received: from ip-31-205-11-203.ask4internet.com (HELO RoLaptop) (31.205.11.203) by ns73.kreativmedia.ch with (AES128-SHA encrypted) SMTP; 22 Apr 2013 00:55:42 +0200 To: "'Igor Wiedler'" , References: <5170E1F8.9060203@sugarcrm.com> In-Reply-To: Date: Sun, 21 Apr 2013 23:55:40 +0100 Message-ID: <000e01ce3ee3$597521f0$0c5f65d0$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQDR4e9hShiwSV6EU2x2O0YxHqUWAwGMYeDeAZOoBR8Ck4uld5qsY+Zw Content-Language: de-ch Subject: AW: [PHP-DEV] Importing namespaced functions From: rstoll@tutteli.ch ("Robert Stoll") I agree with Igor. The readability could be improved and I do not see = the problem of hiding built-in php functions (however, I would not recommend it). I would say, if someone hides the normal php built-in function then he = or she is doing that on purpose and is aware of the consequences. Thus it = is also fine if the same person imports the function, which hides the = normal php built-in function, in another namespace.=20 -----Urspr=FCngliche Nachricht----- Von: Igor Wiedler [mailto:igor@wiedler.ch]=20 Gesendet: Sonntag, 21. April 2013 23:36 An: internals@lists.php.net Betreff: Re: [PHP-DEV] Importing namespaced functions Let me give you two specific cases where I think importing a function significantly improves the readability of code. A) Tiny libraries I recently released a "library" that really just consists of two = functions. Those functions are named compose() and pipeline(), and the library is = named "igorw/compose". I didn't want to risk conflicts in the global = namespace, so I just put them in the "igorw" namespace. Now users need to do this: $x =3D igorw\compose('foo', 'bar', 'baz'); It's distracting to have my vendor name in there every time they call = the function. They can alias it, but then they just need to come up with a random word that makes no sense. compose\compose(...); c\compose(...); foo\compose(...); B) Domain specific languages I hope I'm not mis-using the term "DSL" here, so just let me explain = what I mean. When building some kind of representation of something, it can sometimes be quite nice to have a set of functions representing the elements, and nest those calls. An example of this could be building HTML (you can apply it to building workflows, business rules, graphs, configuration, etc). use html\div, html\p, html\em; $html =3D div(p('Some', em('Text'))); Having to prefix the namespace in either of these cases leads to a lot = of noise. Hopefully that gives you a better idea of where I'm coming from. Regards, Igor -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, = visit: http://www.php.net/unsub.php