Re: Json.php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, April 18, 2007 4:27 am, Roman Neuhauser wrote:
> # chris.boget@xxxxxxxx / 2007-04-18 04:59:48 -0400:
>> >So only one of these is "kosher"
>> >static:
>> >return Services_JSON::decode($data);
>> >
>> >class:
>> >$json = new Services_JSON;
>> >return $json->decode($data);
>> >but not both.
>>
>> I'm not trying to start (or further add fuel to) any kind of war but
>> instead an earnest question: why not both?
>
> If you don't declare the method static, you might be using $this
> inside,
> possibly indirectly.
>
> class c
> {
>     function f()
>     {
>         if (its_second_friday_this_year()) {
>             return get_class($this);
>         }
>         return 'mostly harmless';
>     }
>     function g()
>     {
>         return self::f();
>     }
> }
>
> c::g();
>
> That's an incident waiting to happen, and forbidding static calls of
> instance methods is an (intended) anti-footshooting measure.

So...

The problem is, what?

That there's no "self" in g to call 'f' on?

There's no $this instance to get the class name inside of 'f'?

Some languages handle this by creating a canonical sort-of-Singleton
instance to 'be' the one 'self' when this sort of stuff happens.

I think Lisp does that.

Or maybe it was Logo that did it.

Scheme?

Whatever.

I suppose others just say "don't do that", probably C++ and, I
suspect, Java.

Guess that explains the two camps right there, eh?
[shrug]

Personally, I find that PHP non-OOP is a lot more pragmatic-minded
than PHP OOP seems to be going these days, and it feels to me kind of
multiple-personality when the PHP OOP stuff is so rigid...

But I cut my teeth on Lisp where data and program were often
interchangable, with self-modifying code, so there ya go.
[shrug]

I'll probably use the PHP OOP stuff so seldom that I don't really care
very strongly, but I would personally lean towards the more pragmatic
let the developer decide what to do that's convenient than locking
down things with error messages about stuff that bothers only the
purists.

Oh well.

If this thread goes on much longer, we should probably take it to
Internals or even off-list...

But I ain't got much more to say than what's here.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux