Re: [PHP-DEV] [RFC] Array Dereferencing
Hi This is great. Would it be equally simple to allow the syntax below? $result = new ResultMaker()-getIt(); and $resultOfFunc = returnsFunc()(); I think would add consistency because it would allow direct operations on any returned value. I agree that it is not the most reader friendly code. Jacob On 07/06/2010, at 18.58, Felipe Pena wrote: Hi all, I just edited the RFC page [1] about array dereferencing as now we have a patch for such. RFC page: http://wiki.php.net/rfc/functionarraydereferencing The patch is simple, it just required to change the grammar file. I also added some tests in the patch. Any objection? Thought? Improvements? Thanks. -- Regards, Felipe Pena -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] Array Dereferencing
On Tue, 2010-06-08 at 12:23 +0200, Jacob Oettinger wrote: Would it be equally simple to allow the syntax below? $result = new ResultMaker()-getIt(); does this mean $result = new (ResultMaker()-getIt()); or $result = (new ResultMaker())-getIt(); I assume the later, but that is non-obvious as we allow $result = new $class(); and $resultOfFunc = returnsFunc()(); Having closures this might make sense. (While I don't want to debug code like $foo(bar)[42]-do()(it); ) Oh and obviously +1 on the original patch. ;-) johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] Array Dereferencing
On 08/06/2010, at 12.41, Johannes Schlüter wrote: On Tue, 2010-06-08 at 12:23 +0200, Jacob Oettinger wrote: Would it be equally simple to allow the syntax below? $result = new ResultMaker()-getIt(); does this mean $result = new (ResultMaker()-getIt()); or $result = (new ResultMaker())-getIt(); I assume the later, but that is non-obvious as we allow $result = new $class(); Yes the later. I do not see how the above makes it non-obvious. As I see it the new operator will always instantiate the class name that comes after it. The name can be given as either a literal class name, or as a string variable or as a string variable in an array. It can not be given as a function or method that returns a string. Regardless, it was the direct calling of a function (or invokable) returned from a function I think was a good idea for consistency. Jacob -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] Array Dereferencing
$result = new ResultMaker()-getIt(); I know that this is not much of an argument, but it works the same way in Javascript too, which is very convenient. The intended behaviour is obvious...even though it could be (mis-)interpreted by php. Lars -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] Array Dereferencing
$result = new ResultMaker()-getIt(); Isn't this issue just a matter of defining one thing as being correct and then get on with it? There are lots of ambiguities in php's grammar already. -- troels -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] [RFC] Array Dereferencing
-Oorspronkelijk bericht- Van: Lars Schultz [mailto:lars.schu...@toolpark.com] Verzonden: dinsdag 8 juni 2010 16:04 Aan: internals@lists.php.net Onderwerp: Re: [PHP-DEV] [RFC] Array Dereferencing $result = new ResultMaker()-getIt(); I know that this is not much of an argument, but it works the same way in Javascript too, which is very convenient. The intended behaviour is obvious...even though it could be (mis-)interpreted by php. Lars -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php I agree, this is obviously the intended behaviour. As long as the door is still open to do: $result = new (ResultMaker()-getIt()); To create an object of the class returned by the getIt() method. -Dennis -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DEV] [RFC] Array Dereferencing
-Original Message- From: Jacob Oettinger [mailto:ja...@oettinger.dk] Sent: 08 June 2010 14:09 On 08/06/2010, at 12.41, Johannes Schlüter wrote: On Tue, 2010-06-08 at 12:23 +0200, Jacob Oettinger wrote: Would it be equally simple to allow the syntax below? $result = new ResultMaker()-getIt(); does this mean $result = new (ResultMaker()-getIt()); or $result = (new ResultMaker())-getIt(); I assume the later, but that is non-obvious as we allow $result = new $class(); Yes the later. I do not see how the above makes it non-obvious. I think the only problem with deciding which it means is that - and () are not defined as operators in the PHP documentation, and as such do not have a clearly-defined precedence and associativity. In Javascript, . (property access) and () (function call) both appear in the operator precedence table, so there are definite rules for ascertaining the meaning of such a construct. Up until recently this probably hasn't really been a problem, as it's not been possible to write constructs that needed these rules to decipher them. However, with the previous addition of object access chaining, and now array dereferencing, the time has almost certainly come to add - and () to the operator documentation, with appropriate precedence and associativity. (Incidentally, other operators which are not documented in the Operators section, and probably should be, include :: (which *is* described in the Classes and Objects section as the Scope Resolution Operator, and \ (namespace separator).) Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] Array Dereferencing
The operator that really determines this is 'new' - which is already documented. So there isn't any ambiguity. Not to say that documenting the other operators would be bad, just saying there's no ambiguity here :) Also, allowing new (blah()); would be a fairly big BC break I'd say. How? Maybe you don't understand what BC break means. Currently, new ( produces a parse error. So, no old code would ever be broken. That is what a BC break is. A change to the system that breaks old code. New code very often does not run on older versions of the parser. Of course I think all this chaining stuff is for really really lazy people that have more time to worry about the how cool their code looks and don't have real jobs that actual require them to get things done. =) Brian. In my day! -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [RFC] Array Dereferencing
On 8 June 2010 17:28, Brian Moon br...@moonspot.net wrote: The operator that really determines this is 'new' - which is already documented. So there isn't any ambiguity. Not to say that documenting the other operators would be bad, just saying there's no ambiguity here :) Also, allowing new (blah()); would be a fairly big BC break I'd say. How? Maybe you don't understand what BC break means. Currently, new ( produces a parse error. So, no old code would ever be broken. That is what a BC break is. A change to the system that breaks old code. New code very often does not run on older versions of the parser. I do understand what BC break means - I was probably just too quick on that one. I figured that allowing 'new (blahblah())' would introduce ambiguity for handling parentheses in general with regards to 'new', but I'm probably wrong. Regards Peter -- hype WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind BeWelcome/Couchsurfing: Fake51 Twitter: http://twitter.com/kafe15 /hype -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] Type hinting
Hi Lukas: On Fri, Jun 04, 2010 at 08:28:12AM +0200, Lukas Kahwe Smith wrote: Same deal as E_NOTICE. Either you care about them or you dont. Exactly. The type hinting situation is unique. It is something that applications will frequently want to handle gracefully in order to provide useful error messages. A new error level is needed, as is an API / function to obtain the failed parameter names, desired type and passed type. Thanks, --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver
Denis, I started reviewing the patch, but unfortunately things at work get a bit hectic so haven't made too much progress ;( On Thu, Jun 3, 2010 at 12:07 PM, Denis Gasparin denis.gaspa...@edistar.comwrote: Hi. Did you have the time to review the patches? Any problem with them? Thank you in advance, Denis - Messaggio originale - Da: Denis Gasparin denis.gaspa...@edistar.com A: Ilia Alshanetsky i...@prohost.org, Matteo Beccati p...@beccati.com Cc: internals@lists.php.net, pdo p...@lists.php.net Inviato: Mercoledì, 26 maggio 2010 13:11:17 Oggetto: Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver I attached to this mail a new version of the patch both in unified and single file format. I attached the unit tests for all the new methods too. They are three files: one for pgsqlIsInTransaction(), one for pgsqlCopyFrom* methods and one for pgsqlCopyTo* methods. I did a typo writing the documentation in my first mail. The typo is about the $fields parameter. It is actually a string (not an array) with field names separated by comma. If needed, I can write also documentation in a more suitable format for php web site. The updated documentation of the methods follows. Any feedback is appreciated. Thank you in advance, Denis pgsqlIsInTransaction() It uses the native Postgresql functions to check transaction status. It returns one of the following status codes: * PDO:GSQL_TRANSACTION_IDLE: connection in idle status * PDO:GSQL_TRANSACTION_ACTIVE: connection is executing a command * PDO:GSQL_TRANSACTION_INTRANS: connection is idle in a valid transaction block * PDO:GSQL_TRANSACTION_INERROR: connection is idle, in a failed transaction block * PDO:GSQL_TRANSACTION_UNKNOWN: connection is in a bad status pgsqlCopyFromArray($table,Array $data,$delimiter,$null, Array $fields) It uses the native Postgresql copy construct to append $data to $table. It returns boolean. Parameters: * (mandatory) $table: table to append data to * (mandatory) $data: Array of rows with data in table field order (or as specified in the $fields array). Fields must be separated by $delimiter or by postgresql standard \t) * $delimiter: alternative delimiter to use in place of the standard postgres delimiter (\t) * $null: alternative string to use as null value. Default is \N * $fields: string with table fields that are specified in $data parameter. Fields are separated by comma pgsqlCopyFromFile($table,$filename,$delimiter,$null,$fields) It uses the native Postgresql copy construct to append $filename contents to $table. It returns boolean. Parameters: * (mandatory) $table: table to append data to. * (mandatory) $filename: file with contents to append to $table. See Postgresql documentation for the format. * $delimiter: alternative delimiter to use in place of the standard postgres delimiter (\t) * $null: alternative string to use as null value. Default is \N * $fields: string with table fields that are specified in $filename file. Fields are separated by comma pgsqlCopyToArray($table,$delimiter,$null,$fields) It uses the native Postgresql copy construct to retrieve $table contents and store them to an array. It returns an array of rows or false in case of problems. The format of the rows into the array is indicated in the $delimiter, $null and $fields parameters. Parameters: * (mandatory) $table: table to retrieve data from. * $delimiter: alternative delimiter to use in place of the standard postgres delimiter (\t) * $null: alternative string to use as null value. Default is \N * $fields: string with table fields to include in the row of the array. Fields are separated by comma pgsqlCopyToFile($table,$filename,$delimiter,$null,$fields) It uses the native Postgresql copy construct to retrieve $table contents and store them into a file. It returns boolean. The format of the rows stored into the file is indicated in the $delimiter, $null and $fields parameters. Parameters: * (mandatory) $table: table to retrieve data from. * (mandatory) $filename: file where to store the contents of the table * $delimiter: alternative delimiter to use in place of the standard postgres delimiter (\t) * $null: alternative string to use as null value. Default is \N * $fields: string with table fields to include in the row of the array. Fields are separated by comma - Messaggio originale - Da: Ilia Alshanetsky i...@prohost.org A: Denis Gasparin denis.gaspa...@edistar.com Cc: internals@lists.php.net Inviato: Martedì, 25 maggio 2010 18:40:09 Oggetto: Re: [PHP-DEV] [PATCH] New PDO methods for PostgreSQL driver Good reason, I'll review the patch in the next day or two. On Mon, May 24, 2010 at 5:55 PM, Denis Gasparin denis.gaspa...@edistar.com wrote: The copy to/from sql statements accept