Right, because I've never got them the wrong way round, that is completely logical, and this syntax makes it much harder. On Jul 19, 2012 1:17 AM, "Rasmus Lerdorf" <ras...@lerdorf.com> wrote:
> On 07/18/2012 05:10 PM, David Muir wrote: > > On 19/07/12 04:49, Rasmus Lerdorf wrote: > >> On 07/18/2012 01:02 AM, Pierre Joye wrote: > >>> hi, > >>> > >>> On Wed, Jul 18, 2012 at 9:35 AM, Stas Malyshev > >>> <smalys...@sugarcrm.com> wrote: > >>>> Hi! > >>>> > >>>>> See the other answers, clear APIs, no more argument mess, cleanness. > >>>> Cleanness has nothing to do with pseudo-objects.You don't have to use > >>>> -> to have clean APIs, and using -> doesn't automatically make your > >>>> APIs > >>>> clean. > >>> I really do not want to have a semantic discussion here. > >>> > >>> This syntax is sexy, allows us to clean our APIs, and is amazingly > >>> handy. > >> This makes no sense to me either. How does it let us clean the APIs? Can > >> you give an example? I have one: > >> > >> $a = -5; > >> $b = "-5"; > >> > >> echo $a->abs(); // Outputs 5 > >> echo $b->abs(); // should still output 5 > >> > >> What has been cleaned here over: > >> > >> echo abs($a); > >> echo abs($b); > >> > >> other than being 2 characters longer to type? It's not like you can > >> remove abs() from the string pseudo-object, so you are essentially just > >> taking all the functions in the global namespace and attaching them as a > >> method to every pseudo-object. Is that clean? > >> > >> I think there is something we can do around this, but an argument of "it > >> is sexy and clean" needs to be backed up with some actual implementation > >> details that make sense. > >> > >> -Rasmus > >> > > > > Which is the needle, and which is the haystack? > > $pos = strpos($string, 'a'); > > $pos = strpos('a', $string); > > > > vs > > $pos = $string->pos('a'); > > $pos = 'a'->pos($string); > > > > I'm not proposing to use pos() as the method name, just showing an > > example that this syntax can be cleaner. > > Or you could simply remember that it is always haystack,needle for > strings and needle,haystack for arrays. Not that complicated. > > -Rasmus > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >