|
Posted by "Christopher J. Bottaro" on 05/24/05 18:25
<posted & mailed>
Jochem Maas wrote:
>>>On Sun, May 22, 2005 3:24 pm, Christopher J. Bottaro said:
>>>
>>>>And what would make it any different from a normal recursive function?
>>>
>>>The fact that *ANY* attempt to access a mis-typed property would kick in
>>>a __get() call, and that's too frickin' easy to happen in code that's too
>>>easy to fly by QA in large-scale applications springs to mind...
>
> don't forget the noob factor - a noob could spend days trying to figure
> out WTF is going on in such a situation..... we might even lose him to ASP
> in that time :-/
I didn't realize that PHP had such an emphasis on the "noob factor".
>>>Not saying you're "wrong" or they're "right" just that it's not quite as
>>>simple as a normal recursive function or loop iteration.
>>
>>
>> I completely disagree. I don't mean any offense to anyone here, but I
>> find it kind of ridiculous for a language to restrict itself that like in
>> this
>> case. Its insulting to our intelligence as programmers.
>>
>
> er whatever, interesting to see how easily you are insulted - I mean its a
> programming language with a certain kind of implementation, which may not
> be perfect, but I don't think they we're thinking of you when they wrote
> it.
I just don't like being talked down to, who does? You can be immature and
poke fun at my choice of words if you want. All I meant to say is that I
find it weird that PHP assumes that I don't understand how recursion works.
>>>>Every recursive function runs the risk of going into infinite loop if
>>>>the programmer doesn't understand the basic concept (or makes a silly
>>>>mistake).
>>>
>>>Just saying it's an easier silly mistake to mis-type: $whatever->fooo
>>>instead of $whatever->foo and have that escape QA somehow.
>>>
>>>
>>>>Loops run the risk of going on indefinitely as well. Maybe PHP should
>>>>disable all forms of loops/recursion to protect the programmers from
>>>>themselves.
>>>
>>>That does seem a bit excessive...
>>
>>
>> I was making a point. I don't see why recursion is allowed in every
>> other
>> function except for __get(). I think your argument is weak about
>> protecting people from typos. If PHP wanted to protect people from
>> typos, it should force you to declare your variables.
>>
>
> you think its a weak argument, maybe you are missing the point - ask
> yourself what the average level of php programmers is? part of the php
> philosophy is about making/keeping php accessible.
Again, I didn't realize was so geared towards "noobs".
> I think you will find that if you we're forced to declare you [class]
> variables that your __get() implementation would stop working they way it
> does now...
No, I use __get() to provide property like access to calculated values.
There is no corresponding class var for these values. If I wanted access
to class vars, I'd just declare them and then __get() wouldn't be used.
>>>Maybe __get() should allow recursion and let the developer worry about
>>>infinite recursion.
>
> Is that the 11th commandment?
I have no idea what you are talking about. I meant to say, "Maybe __get()'s
implicit invocation should work like normal functions."
>>>But, today, it doesn't, so deal with it and move on.
>
> ditto.
Do yall really think I have halted my work because of this? I just want to
discuss it.
>> I was bringing the to the table a discussion of the current behavior of
>> __get(). I proposed that I might be broken or maybe should be changed,
>> and
>
> maybe you are broken, hard to tell from here.
Way to make me look stupid because I made a typo.
>> you start insulting my abilities as a programmer and suggest that we
>> shouldn't consider "moving forward" and just deal with what we have?
>>
>
> I think Richard is a fairly intelligent person, if he had been insulting
> you I'm quite sure that he would have done a much better job ;-)
Thats great, I'm sure he's the reigning "cut down contest" champ on this
list. I don't care. Like I said, I don't like being talked down to. I
found it very unnecessarily presumptuous of him to say stuff like "without
knowing anything about you, I assume you have made bad design decisions,
painted yourself in a corner, etc". What the hell does any of that have to
do with the discussion?
>> Painted myself into this corner? Why? Because I think its easier to
>> write
>> $this->myvar than it is to write $this->attrs['myvar']? Its PHP's job to
>
> given the number of chars in the email you wrote you could have written
> the extra "attrs['']" (9 chars) god knows how many times,
Yeah, I've written more in these threads than the entire class that spawned
them. ?...?.......?
> besides if you
> admit you can solve all your issues by writing the 'long' form then your
> argument
> [below] that you need to call __get() from inside __get() in order to
> [retrieve
> 1 or more calculated values to calculate the originally requested
> attribute sounds bogus.
Err, not following ya. The point is that I don't want to use the long form.
__get() is recursive when using the long form. Its the implicit invocation
that isn't.
> php isn't perfect, neither are you - find a balance, get over it.
Sigh. PHP's motto: "Get over it, we oppose change." (According to you and
Richard).
>> make my life easier and more convenient.
>
> I didn't realise php had a job, I thought it was me who had the job and
> php was what I used to accomplish it....
Clever, I personified PHP and you pointed out that PHP isn't a person. (in
Stewie's voice) Clever girl you are! (I don't mean to say you are a girl,
I just thought of that family guy episode).
>>>Obviously, it's entirely possible that your Design is the most elegant
>>>beautiful disciplined bit of code since John von Nueman... But it's more
>>>likely, without knowing anything about you, that you've come up with this
>>>as a result of some bad Design decisions.
>>>
>>>Review your Design. :-)
> notice the fecking smiley [hint: Richard is trying to help you, trying to
> get into an argument with him is making you look bad.]
I already addressed this.
>> Wow, how pompous of you. Bad design, huh? Since when is it bad design
>> to
>> calculate attribute values on the fly? Many "cookbook" style books have
>
> and 'cooking' is the same as 'engineering'? (I think I'll try something
> new with the cement today....)
You're right, all those "cookbooks" are stupid.
>> Speaking of "good design", Python's __getattr__() behaves how I expect.
>
> use it then?
I would if I could, but I can't. Besides, PHP is pretty fun/easy to program
with, I'd say its my 2nd favorite language right now. Again, I don't see
whats wrong with trying to get fixed what I think is wrong.
OK, all the subtle stabs at each other (and yes, they are subtle) aside, you
brought up some good points about __get()'s behavior if it's implicit
invocation allowed for recursion. Thats all I really wanted, thanks for
that.
-- C
[Back to original message]
|