[#65451] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...
Issue #10333 has been updated by Koichi Sasada.
ko1@atdot.net wrote:
Eric Wong <normalperson@yhbt.net> wrote:
Eric Wong <normalperson@yhbt.net> wrote:
On 2014/10/09 11:04, Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
[#65453] [ruby-trunk - Feature #10328] [PATCH] make OPT_SUPPORT_JOKE a proper VM option — ko1@...
Issue #10328 has been updated by Koichi Sasada.
[#65559] is there a name for this? — Xavier Noria <fxn@...>
When describing stuff about constants (working in their guide), you often
On 2014/10/09 20:41, Xavier Noria wrote:
On Thu, Oct 9, 2014 at 1:59 PM, Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
[#65566] [ruby-trunk - Feature #10351] [Open] [PATCH] prevent CVE-2014-6277 — shyouhei@...
Issue #10351 has been reported by Shyouhei Urabe.
[#65741] Re: [ruby-cvs:55121] normal:r47971 (trunk): test/ruby/test_rubyoptions.rb: fix race — Nobuyoshi Nakada <nobu@...>
On 2014/10/16 10:10, normal@ruby-lang.org wrote:
Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
2014-10-16 12:48 GMT+09:00 Eric Wong <normalperson@yhbt.net>:
[#65753] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...
Issue #10333 has been updated by Koichi Sasada.
[#65818] [ruby-trunk - Feature #10351] [PATCH] prevent CVE-2014-6277 — shyouhei@...
Issue #10351 has been updated by Shyouhei Urabe.
[ruby-core:65912] [ruby-trunk - Feature #8976] file-scope freeze_string directive
Issue #8976 has been updated by Akira Tanaka.
Eric Wong wrote:
>
> Right, "...".freeze is too ugly IMHO. Ruby should stay beautiful :)
Agreed.
> I also think needing to call "...".dup is ugly and will break much
> existing code[1].
I don't think "...".dup is ugly.
I agree changing the default breaks much existing code.
So changing the default is long term goal.
> > It makes us to prevent unintentional modification and
> > we can distinguish string literals to be modified or not, more easily.
>
> My concern is optimizing Ruby for the typical script language users[2],
> not the (few) Rubyists who understand VM internals.
Unnecessary string duplications problem is easy to understand.
I think there is possibility to change the users.
> I am against this; especially as a default for 3.0[1]. File scope
> directives makes refactoring and reorganization of code more difficult:
> move a method to a new file and behavior changes.
There are many context dependency for refactoring and reorganization now.
One more context dependency is not a big problem.
----------------------------------------
Feature #8976: file-scope freeze_string directive
https://bugs.ruby-lang.org/issues/8976#change-49649
* Author: Akira Tanaka
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version: current: 2.2.0
----------------------------------------
Yesterday, we had a face-to-face developer meeting.
https://bugs.ruby-lang.org/projects/ruby/wiki/DevelopersMeeting20131001Japan
Several committers attended.
matz didn't attended, though. (This means this issue is not concluded.)
We believe we found a better way to freeze static string literals for
less GC pressure.
"static string literal" is a string literal without dynamic expression.
Currently, f-suffix, "..."f, is used to freeze a string literal to avoid
String object allocation.
There are several problems for f-suffix:
* The notation is ugly.
* Syntax error on Ruby 2.0.
We cannot use the feature in version independent libraries.
So, it is difficult to deploy.
* Need to modify for each string literal.
This is cumbersome.
The new way we found is a file-scope directive as follows
# freeze_string: true
The above comment at top of a file changes semantics of
static string literals in the file.
The static string literals will be frozen and always returns same object.
(The semantics of dynamic string literals is not changed.)
This way has following benefits:
* No ugly f-suffix.
* No syntax error on older Ruby.
* We need only a line for each file.
We can write version independent library using frozen static string literals as follows.
* Use the directive at top of the file: # freeze_string: true
Older Ruby ignore this as a comment.
* Use "...".dup for strings to be modified.
Older Ruby has small disadvantage: useless dup is called.
Note that the directive effects all static string literals regardless of
single quotes, double quotes, %q-string, %qq-string and here documents.
The reason that the directive is effective not only single quotes is
we want to use escape sequences such as \n in frozen string literals.
Also note that similar directive is already exist:
% ruby -w -e '
def m
end
'
-e:3: warning: mismatched indentations at 'end' with 'def' at 2
% ruby -w -e '# -*- warn_indent: false -*-
def m
end
'
The directive, warn_indent: false, disables "mismatched indentations" warning.
nobu implemented this feature in the meeting.
Please attach the patch, nobu.
--
https://bugs.ruby-lang.org/