|  | Posted by gosha bine on 06/12/07 10:15 
On 12.06.2007 10:49 Jerry Stuckle wrote:> gosha bine wrote:
 >> On 11.06.2007 20:58 Schraalhans Keukenmeester wrote:
 >>>
 >>> Imho implicit obj2str conversion is meaningless, and though I have
 >>> abused
 >>> the construct myself a few times I am glad they corrected this
 >>> behaviour.
 >>> Having to define your own stringifier forces you to think about and
 >>> implement what is logically the proper meaning of a conversion to an
 >>> otherwise incompatible type.
 >>
 >> That's exactly the point Zend developers are constantly missing. It is
 >> not the responsibility of language designers to remove constructs that
 >> may seem "useless" to them. An application programmer is the one who
 >> decides which syntax is appropriate for her particular task. The job
 >> of the language designer is to provide clean and consistent mechanism
 >> for generating any possible expression, including "useless" ones. You
 >> don't let a taxi driver decide where you're going to go, do you?
 >>
 >
 > No, but you let a taxi driver decide how you get there.
 
 You are not trying to refute a _metaphor_, are you? ;)
 
 >
 >> As to this specific case, removal of implicit toString is especially
 >> stupid, because _every other_ type in php and _every other_ comparable
 >> programming language supports it.
 >>
 >
 > No, every other type in php doesn't support it.  When was the last time
 > you tried to convert an object to an int, for instance?
 
 I meant, every other php type supports implicit toString:
 
 echo 123; - works
 echo array(1, 2, 3); - works
 echo fopen('blah', 'r'); - works
 
 echo new Blah(); - DOES NOT work
 
 >
 > And as for every other comparable programming language - no they don't.
 
 Most languages support implicit toString for objects:
 
 alert(new Blah()) - works in javascript
 puts Blah.new - works in ruby
 print Blah() - works in python
 System.out.println(new Blah()) - works in java
 
 echo new Blah() - DOES NOT work in php
 
 Are you saying other languages' designers care less about their
 programmers? Why do they allow such a "useless" thing?
 
 >  But who cares?  Other languages have features PHP doesn't have, and PHP
 > has features they don't have.  It's comparing apples and oranges.
 
 Comparing programming languages and technologies is always productive,
 there's always something to learn from each other.
 
 >
 > Personally, I've found the silent conversion allows for sloppy
 > programming and problems (like the one which started this thread).  I'm
 > glad to see the implicit conversion is gone.
 
 What exactly are the problems which are solved by removing the silent
 conversion?
 
 >
 > But if you really want it, the developers left a way for you to do so.
 > Good for them.
 >
 
 An object without toString  was converted to "object #x" or similar when
 being printed. So was the behaviour prior to 5.2. Useless or not, it
 simply worked. Now, it's broken and there's no way to make it work again.
 
 
 --
 gosha bine
 
 extended php parser ~ http://code.google.com/p/pihipi
 blok ~ http://www.tagarga.com/blok
  Navigation: [Reply to this message] |