Re: [PHP] PHP 5 && OO && performance && exceptions
read the internals@ archive - there is a chap there who is developing an php module that makes objects wrappers for basic types available. but imho: $str = new String("W T F !!"); echo $str->getValue(), $str, $str->__toString(); is just a bit OTT. also creating and rolling out (to a group of developers) a set of classes to use in place of basic types on the basis of a _belief_ that it may eliminate some development errors seems to be not an unsound basis for such as decision. chances are that half the time developers will 'forget' the 'basetype' classes, your dealing with egos you know :-). but then again maybe in a couple of years we will only have objects to represent types - although so long as at least Rasmus is 'on the bridge' of starship NCC-17-PHP I imagine that won't be happening - IFAIR the creator is a fan of straigtforward procedural code in most cases - apologies to Rasmus if I misread him. [EMAIL PROTECTED] wrote: Some more thought. To solve this problem would be necessary to create some utility class like System in java and that way should be possible to do a System::echo($string) based on type, i guess this can be accomplished using overloading. Am I making any sense? - Original Message - From: <[EMAIL PROTECTED]> To: Sent: Thursday, November 10, 2005 6:47 PM Subject: Re: [PHP] PHP 5 && OO && performance && exceptions I was not considering that, I was using $obj_string->getValue(), the __toString method and type casting could save me some keystrokes :) Anyway, did you abandon the development with the basic types class? Angelo - Original Message - From: "Jake Gardner" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, November 09, 2005 1:37 PM Subject: Re: [PHP] PHP 5 && OO && performance && exceptions I myself was considering creating classes such as String, but I ran into more basic problems before performance, for example: class String { protected $Value; function __construct($Value) { $this->Value = $Value; } } $SomeString = new String("Hello World!"); Print($SomeString); // Does not print "Hello World!" The way around this was still unsatisfactory: class String { protected $Value; function __construct($Value) { $this-> Value = $Value; } function __toString() { return $this->Value; } } $SomeString = new String("Hello World!"); Print($SomeString); // Prints "Hello World!" Because this has obvious limitations, and is only a fix for strings; this doesnt work for functions that expect integer values. In reality, there really is no way to use PHP to rewrite a type in PHP without using the PHP "omni-type". However, you can use type casting as it is: http://us2.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting http://us2.php.net/manual/en/function.settype.php On 11/9/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hello, Currently I'm make some utilities classes and I took the idea from java to make some wrappers class like String, Integer and so on. This allows me to use the type hint for basic types in php. Anyone have a clue if replacing the all in one type in php for objects types will degrade the performance? Also for every controller class that I'm making I'm also making exceptions class of every error that it can generate. Same questions: It will degrade performance to throw an exception instead of lest say a pear error or return false? Just for know, I'm doing this because I believe that it will eliminate some o problems o development and will eliminate some basic validations. Any tips appreciate Angelo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5 && OO && performance && exceptions
Some more thought. To solve this problem would be necessary to create some utility class like System in java and that way should be possible to do a System::echo($string) based on type, i guess this can be accomplished using overloading. Am I making any sense? - Original Message - From: <[EMAIL PROTECTED]> To: Sent: Thursday, November 10, 2005 6:47 PM Subject: Re: [PHP] PHP 5 && OO && performance && exceptions > I was not considering that, I was using $obj_string->getValue(), the > __toString method and type casting could save me some keystrokes :) > > > > Anyway, did you abandon the development with the basic types class? > > > > Angelo > > > > - Original Message - > From: "Jake Gardner" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, November 09, 2005 1:37 PM > Subject: Re: [PHP] PHP 5 && OO && performance && exceptions > > > I myself was considering creating classes such as String, but I ran > into more basic problems before performance, for example: > > class String { >protected $Value; >function __construct($Value) { >$this->Value = $Value; >} > } > $SomeString = new String("Hello World!"); > Print($SomeString); // Does not print "Hello World!" > > The way around this was still unsatisfactory: > class String { >protected $Value; >function __construct($Value) { > $this-> Value = $Value; > } > function __toString() { > return $this->Value; > } > } > $SomeString = new String("Hello World!"); > Print($SomeString); // Prints "Hello World!" > > Because this has obvious limitations, and is only a fix for strings; > this doesnt work for functions that expect integer values. > > In reality, there really is no way to use PHP to rewrite a type in PHP > without using the PHP "omni-type". > > However, you can use type casting as it is: > > http://us2.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting > > http://us2.php.net/manual/en/function.settype.php > > > On 11/9/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hello, > > > > > > > > Currently I'm make some utilities classes and I took the idea from java to > > make some wrappers class like String, Integer and so on. This allows me to > > use the type hint for basic types in php. Anyone have a clue if replacing > > the all in one type in php for objects types will degrade the performance? > > > > > > > > Also for every controller class that I'm making I'm also making exceptions > > class of every error that it can generate. Same questions: It will > > degrade performance to throw an exception instead of lest say a pear error > > or return false? > > > > > > > > Just for know, I'm doing this because I believe that it will eliminate > > some o problems o development and will eliminate some basic validations. > > > > > > > > > > > > Any tips appreciate > > > > > > > > Angelo > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5 && OO && performance && exceptions
I was not considering that, I was using $obj_string->getValue(), the __toString method and type casting could save me some keystrokes :) Anyway, did you abandon the development with the basic types class? Angelo - Original Message - From: "Jake Gardner" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, November 09, 2005 1:37 PM Subject: Re: [PHP] PHP 5 && OO && performance && exceptions I myself was considering creating classes such as String, but I ran into more basic problems before performance, for example: class String { protected $Value; function __construct($Value) { $this->Value = $Value; } } $SomeString = new String("Hello World!"); Print($SomeString); // Does not print "Hello World!" The way around this was still unsatisfactory: class String { protected $Value; function __construct($Value) { $this-> Value = $Value; } function __toString() { return $this->Value; } } $SomeString = new String("Hello World!"); Print($SomeString); // Prints "Hello World!" Because this has obvious limitations, and is only a fix for strings; this doesnt work for functions that expect integer values. In reality, there really is no way to use PHP to rewrite a type in PHP without using the PHP "omni-type". However, you can use type casting as it is: http://us2.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting http://us2.php.net/manual/en/function.settype.php On 11/9/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hello, Currently I'm make some utilities classes and I took the idea from java to make some wrappers class like String, Integer and so on. This allows me to use the type hint for basic types in php. Anyone have a clue if replacing the all in one type in php for objects types will degrade the performance? Also for every controller class that I'm making I'm also making exceptions class of every error that it can generate. Same questions: It will degrade performance to throw an exception instead of lest say a pear error or return false? Just for know, I'm doing this because I believe that it will eliminate some o problems o development and will eliminate some basic validations. Any tips appreciate Angelo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 5 && OO && performance && exceptions
Hello, Currently I'm make some utilities classes and I took the idea from java to make some wrappers class like String, Integer and so on. This allows me to use the type hint for basic types in php. Anyone have a clue if replacing the all in one type in php for objects types will degrade the performance? Also for every controller class that I'm making I'm also making exceptions class of every error that it can generate. Same questions: It will degrade performance to throw an exception instead of lest say a pear error or return false? Just for know, I'm doing this because I believe that it will eliminate some o problems o development and will eliminate some basic validations. Any tips appreciate Angelo