Re: [PHP-DEV] Q on Primitives

2008-12-19 Thread Robin Burchell
Just a random thought I have from reading over that: Would it not be more 'natural' to change 'function' to indicate a method with a variant return type, and allow e.g. 'int somefunc()' instead of 'function (int) somefunc()' to indicate an int return? It would be a bit more in fitting with

Re: [PHP-DEV] Q on Primitives

2008-12-19 Thread Nathan Rixham
Robin Burchell wrote: Just a random thought I have from reading over that: Would it not be more 'natural' to change 'function' to indicate a method with a variant return type, and allow e.g. 'int somefunc()' instead of 'function (int) somefunc()' to indicate an int return? it would break

Re: [PHP-DEV] Q on Primitives

2008-12-19 Thread Robin Burchell
Hmm. How would it break it? By leaving 'function' to mean variant, it's only adding new functionality by overriding types to replace 'function', which should have no issue with older code, surely? To clarify: current method declaration: function foo() public static function foo() public

Re: [PHP-DEV] Q on Primitives

2008-12-19 Thread troels knak-nielsen
On Fri, Dec 19, 2008 at 3:31 PM, Nathan Rixham nrix...@gmail.com wrote: type hints are all ready there so adding primitives /should/ be possible without any bc issues PHP is loosely typed. Adding typehints to primitives would change this. The only reason that it is working with object types, is

Re: [PHP-DEV] Q on Primitives

2008-12-19 Thread Robin Burchell
On Fri, Dec 19, 2008 at 2:40 PM, troels knak-nielsen troel...@gmail.com wrote: PHP is loosely typed. Adding typehints to primitives would change this. The only reason that it is working with object types, is because you can't automatically coerce object types anyway. -- troels I'm not sure

Re: [PHP-DEV] Q on Primitives

2008-12-19 Thread Nathan Rixham
Robin Burchell wrote: Hmm. How would it break it? By leaving 'function' to mean variant, it's only adding new functionality by overriding types to replace 'function', which should have no issue with older code, surely? To clarify: current method declaration: function foo() public static

Re: [PHP-DEV] Q on Primitives

2008-12-19 Thread Robin Burchell
Ugh. Apparantly I forgot to CC the list on those last two mails.. Sorry. Pasted so others stay in on the conversation: On Fri, Dec 19, 2008 at 3:18 PM, troels knak-nielsen troel...@gmail.com wrote: snip That's an interesting mail, expresses a viewpoint I hadn't considered, so, thanks for that.

Re: [PHP-DEV] Q on Primitives

2008-12-19 Thread Ionut Gabriel Stan
On 12/19/2008 17:39, Robin Burchell wrote: Ugh. Apparantly I forgot to CC the list on those last two mails.. Sorry. Pasted so others stay in on the conversation: On Fri, Dec 19, 2008 at 3:18 PM, troels knak-nielsentroel...@gmail.com wrote: snip That's an interesting mail, expresses a

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Dave Ingram
Nathan Rixham wrote: [...] while I'm here I may as well also ask about further adding type hinting for the existing scalars and array. +1, but I don't know what might have stopped it being implemented before (time, parsing API changes, etc), so it would be interesting to look into the history.

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Nathan Rixham
2008/12/18 Dave Ingram d...@dmi.me.uk Also, what about this case: class MyTestClass { public function blah(Foo $f); public function blah(Bar $b); public function blah($v); } I would argue that the most specific function should be called, but how costly would that be to determine?

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Giorgio Sironi
2008/12/18 Dave Ingram d...@dmi.me.uk Nathan Rixham wrote: [...] while I'm here I may as well also ask about further adding type hinting for the existing scalars and array. +1, but I don't know what might have stopped it being implemented before (time, parsing API changes, etc), so it

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Cristian Rodríguez
Dave Ingram escribió: class MyTestClass { public function blah(Foo $f); public function blah(Bar $b); public function blah($v); } Looks like you are using the wrong language, you need JAVA instead. -- We have art in order not to die of the truth - Friedrich Nietzsche Cristian

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Dave Ingram
I remember that multiple signatures was said to have a possible very difficult implementation. However, a similar behaviour can be achieved by some instanceof(). I thought it probably would be awkward, but we do already have some type hinting that can also be accomplished with instanceof()

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Dave Ingram
Cristian Rodríguez wrote: class MyTestClass { public function blah(Foo $f); public function blah(Bar $b); public function blah($v); } Looks like you are using the wrong language, you need JAVA instead. Yes, I'll admit it does look like Java (or any C++-like OO language) -

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Nathan Rixham
Dave Ingram wrote: I remember that multiple signatures was said to have a possible very difficult implementation. However, a similar behaviour can be achieved by some instanceof(). I thought it probably would be awkward, but we do already have some type hinting that can also be

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Nathan Rixham
Dave Ingram wrote: Cristian Rodríguez wrote: class MyTestClass { public function blah(Foo $f); public function blah(Bar $b); public function blah($v); } Looks like you are using the wrong language, you need JAVA instead. Yes, I'll admit it does look like Java (or any C++-like OO

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Nathan Rixham
Nathan Rixham wrote: Dave Ingram wrote: Cristian Rodríguez wrote: class MyTestClass { public function blah(Foo $f); public function blah(Bar $b); public function blah($v); } Looks like you are using the wrong language, you need JAVA instead. Yes, I'll admit it does look like

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Kalle Sommer Nielsen
2008/12/18 Nathan Rixham nrix...@gmail.com: Nathan Rixham wrote: and strongly typed returns.. nearly forgot public static function parseByte( Number $var ):bool { or public static function bool parseByte( Number $var ) { or such like Theres already an RFC for this:

[PHP-DEV] Q on Primitives

2008-12-17 Thread Nathan Rixham
Don't want to take up much of you're time, just wondered if anybody could point me to the reason why some primitives aren't in php. Would find it very very useful to have byte, short, long, float, double and char in php. (primarily byte and char). while I'm here I may as well also ask about

Re: [PHP-DEV] Q on Primitives

2008-12-17 Thread Graham Kelly
Hi, I think the reason there aren't more primitive types in PHP is because of the nature of the language. One of the main features of PHP over say, C (and even Java), is that the memory managment is completely transparent to the devloper. This means that it really shouldent matter to the devloper

Re: [PHP-DEV] Q on Primitives

2008-12-17 Thread Nathan Rixham
Graham Kelly wrote: Hi, I think the reason there aren't more primitive types in PHP is because of the nature of the language. One of the main features of PHP over say, C (and even Java), is that the memory managment is completely transparent to the devloper. This means that it really shouldent