rfc:println

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:println [2021/03/13 19:29] tandrerfc:println [2021/03/15 13:26] (current) tandre
Line 3: Line 3:
   * Date: 2021-03-13   * Date: 2021-03-13
   * Author: Tyson Andre   * Author: Tyson Andre
-  * Status: Under Discussion+  * Status: Withdrawn
   * First Published at: http://wiki.php.net/rfc/println   * First Published at: http://wiki.php.net/rfc/println
   * Implementation: https://github.com/php/php-src/pull/6639   * Implementation: https://github.com/php/php-src/pull/6639
Line 196: Line 196:
  
 (e.g. changing ''puts("test")'' to ''fputs(STDERR, "test")'' would unexpectedly not print a terminating newline to STDERR (''fputs'' is an alias of ''fwrite'')) (e.g. changing ''puts("test")'' to ''fputs(STDERR, "test")'' would unexpectedly not print a terminating newline to STDERR (''fputs'' is an alias of ''fwrite''))
 +
 +==== Choice of Unix newline(\n) ====
 +
 +Some programming languages such as Java use a platform-specific or configurable newline https://docs.oracle.com/javase/6/docs/api/java/io/PrintStream.html#println%28%29
 +Others, such as rust and golang, always use a unix newline.
 +
 +There have been some comments in favor of Unix newlines, and other comments in favor of PHP_EOL or configurable settings - e.g. https://externals.io/message/104545
 +
 +My reasons for unconditionally choosing the Unix newline are documented in the section [[#the_unix_newline_is_always_used|The Unix Newline is always used]].
 +
 +==== Should this be a language construct instead ====
 +
 +
 +https://github.com/php/php-src/pull/3918#issuecomment-502012735
 +
 +<blockquote>
 +Should't this be a language construct instead of a function, so it can be used without parenthesis just like echo or print?
 +
 +It would feel a little weird being able to do:
 +
 +<code php>
 +echo 'hello world';
 +print 'hello world';
 +</code>
 +... but not:
 +
 +<code php>
 +puts 'hello world';
 +</code>
 +</blockquote>
 +
 +Adding this as a language construct (i.e. new statement type) is something I'd expect to be contentious, and this is deliberately NOT done. Adding a new keyword would
 +
 +  - Cause a larger BC break.
 +  - Increase the complexity of the language specification and make the language a bit harder to learn; I'd prefer simplicity by using an ordinary global function in this case.
 +  - Be impossible to polyfill (when brackets weren't added) for older php versions.
 +
 +==== PHP already has a lot of ways to print a string ====
 +
 +https://externals.io/message/113504#113530
 +
 +<blockquote>
 +This isn't solving any problem that anyone is actually having.
 +Yes, that includes you. You're not having this problem because it doesn't
 +exist.
 +
 +We already have twice as many ways to output a string as any language needs
 +and you want to add another because you'd rather type "LN" than "\N" ?
 +Hard, negative ten thousand no on this.
 +This is genuinely absurd.
 +</blockquote>
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
-Yes/No, requiring 2/3 majority.+Yes/No, requiring 2/3 majority.
  
 ===== References ===== ===== References =====
 https://externals.io/message/104545 "print with newline" https://externals.io/message/104545 "print with newline"
  
 +https://github.com/php/php-src/pull/3918 "ext/standard/basic_functions.c: add puts function" has discussion on a similar proposal by a different author. My RFC uses ''\n'', while the other author's RFC proposed ''PHP_EOL''.
rfc/println.1615663791.txt.gz · Last modified: 2021/03/13 19:29 by tandre