Thanks for the explanation of b/c. I didn't know PHP is this rigid. Now I do...
On Sun, Mar 3, 2019 at 1:30 AM Alexandru Pătrănescu <dreal...@gmail.com> wrote: > Steven, Ryan, > > Adding new functions is also considered BC break because users might have > those functions in their code. > Over the years new functions were added to PHP core but mostly there were > functions that saved in the userland code more than one line of code. > Like array_first_key was accepted but array_first_value didn't. > > And would you all stop with PHP_EOL? If my code will ever run on something > different than Linux, I want it to be portable, not generate files > differently. I think we should define PHP_EOL_N constant so people will use > it more... > > Jokes aside, each case might need a different version of they println/say > implementation. > Maintaining it in core is probably not worth the effort as it could be more > easily maintained in userland. > > You can use https://packagist.org/packages/print/ln in the meantime. Or > publish you own and use it. > > Regards, > Alex > > On Sun, Mar 3, 2019, 08:49 Joe Watkins <krak...@gmail.com> wrote: > > > Sara, where do I send pull requests? > > > > <?php > > function println(string $format, ...$args) : void { > > \vprintf($format . \PHP_EOL, $args); > > } > > > > function fprintln($stream, string $format, ...$args) : void { > > if (!\is_resource($stream)) { > > throw new \TypeError(\sprintf( > > "Argument 1 passed to %s expected to be a resource, %s > given", > > __FUNCTION__, > > \is_object($stream) ? > > \sprintf( > > "instance of %s", \get_class($stream) > > ) : \gettype($stream))); > > } > > > > \vfprintf($stream, $format . \PHP_EOL, $args); > > } > > > > function sprintln(string $format, ...$args) : string { > > return \vsprintf($format . \PHP_EOL, $args); > > } > > > > Jokes aside, this is so trivially achievable in userland that there is no > > justification whatever for an internal function or functions, or > > constructs, or opcodes. > > > > Cheers > > Joe > > > > On Sun, 3 Mar 2019 at 06:50, Ryan Jentzsch <ryan.jentz...@gmail.com> > > wrote: > > > > > I've always wondered why PHP didn't have a built in command or function > > > that behaved as `echo` but with a EOL. > > > I propose not to modify `print` or `echo` (as this was rightly pointed > > out > > > to cause b/c). How difficult would it be to add a new statement and/or > > > function to the PHP core called `say` / `say()` that has an EOL? > > > > > > This seems to me to be simple to do. The benefit is less code to type > in > > > user land (ex: `say 'Hello World';` as opposed to `echo 'Hello World' . > > > PHP_EOL;` > > > > > >