Req #74362 [Wfx]: Make echo and print equivalent
| From: | olafvdspek at gmail dot com | Date: | Wed, 05 Apr 2017 15:37:31 +0000 |
| Subject: | Req #74362 [Wfx]: Make echo and print equivalent | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-208338@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74362&edit=1
ID: 74362
User updated by: olafvdspek at gmail dot com
Reported by: olafvdspek at gmail dot com
Summary: Make echo and print equivalent
Status: Wont fix
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Thx
The example syntax ("void echo ( string $arg1 [, string $... ] ) is still using parenthesis
though it doesn't work with multiple arguments and nikic says it's not the
'correct' syntax.
https://bugs.php.net/bug.php?id=74363
Previous Comments:
------------------------------------------------------------------------
[2017-04-05 14:50:37] fractalesque at gmail dot com
Ignoring the other points, the documentation have been fixed.
------------------------------------------------------------------------
[2017-04-03 19:50:10] olafvdspek at gmail dot com
1. Could the docs be fixed?
2. Is the return value of print of any use?
3. I'd love the multiple arguments with parentheses variant to work but I guess that's a
bridge too bar.
------------------------------------------------------------------------
[2017-04-03 03:55:04] pollita@php.net
Oh, and because I missed bwoebi@'s comment... That's exactly the kind of edge case I
included "[citation needed]" in my reply for. :)
Taht said, we could resolve that ambiguity by requiring parenthesis for print with multiple args,
but at that point you have an exeption to the grammar rule, and you're not longer bringing
echo/orint in line with each other and any consistency benefit flies away.
------------------------------------------------------------------------
[2017-04-03 03:52:36] pollita@php.net
True about the difference being slightly larger, but as far as the original question goes: Yes, we
could allow print to accept multiple arguments.
For that matter we could make echo return a value. Neither is going to break anything[citation
needed], and due to the way the compiler handles both statements, neither will perform worse (fun
fact: the compiler turn both into ZEND_ECHO opcodes, just with a different extended_value which it
doesn't even use).
Should we? It'd be a grammar change, so you'll need an RFC and a 2/3 vote in favor of it.
Without a compelling reason, I doubt you'll get that.
------------------------------------------------------------------------
[2017-04-02 15:33:01] bwoebi@php.net
Small example:
foo(print 1, 2);
^ is 2 a second argument to print or to foo?
That's ambiguous, hence we do not allow that.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=74362
--
Edit this bug report at https://bugs.php.net/bug.php?id=74362&edit=1