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-nielsen wrote: That's an interesting mail, expresses a viewpoint I hadn't considered,

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 wrote: > That's an interesting mail, expresses a viewpoint I hadn't considered, so, thanks for that. However: If PHP provid

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 functi

Re: [PHP-DEV] Q on Primitives

2008-12-19 Thread Robin Burchell
On Fri, Dec 19, 2008 at 2:40 PM, troels knak-nielsen 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 what you are

Re: [PHP-DEV] Q on Primitives

2008-12-19 Thread troels knak-nielsen
On Fri, Dec 19, 2008 at 3:31 PM, Nathan Rixham 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 because you can

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 function

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 all

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 tradi

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Kalle Sommer Nielsen
2008/12/18 Nathan Rixham : > 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: http://wiki.php.net/rfc/typeh

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 Jav

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
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 accomplis

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

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 instanceo

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 Cristi

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Giorgio Sironi
2008/12/18 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 woul

Re: [PHP-DEV] Q on Primitives

2008-12-18 Thread Nathan Rixham
2008/12/18 Dave Ingram > > 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? What i

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 histo

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 m

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