[#71439] [Ruby trunk - Feature #11339] [PATCH] io.c: avoid kwarg parsing in C API — matz@...
Issue #11339 has been updated by Yukihiro Matsumoto.
7 messages
2015/11/11
[#71473] Re: [Ruby trunk - Feature #11339] [PATCH] io.c: avoid kwarg parsing in C API
— Eric Wong <normalperson@...>
2015/11/13
Entire series for sockets
[#71450] Ruby 2.3.0-preview1 Released — "NARUSE, Yui" <naruse@...>
Hi,
5 messages
2015/11/11
[#71617] [Ruby trunk - Feature #11664] [PATCH] introduce rb_autoload_value to replace rb_autoload — nobu@...
Issue #11664 has been updated by Nobuyoshi Nakada.
3 messages
2015/11/20
[#71721] [Ruby trunk - Feature #11741] Migrate Ruby to Git from Subversion — me@...
Issue #11741 has been updated by Jon Moss.
4 messages
2015/11/28
[ruby-core:71298] [Ruby trunk - Feature #8976] [Open] file-scope freeze_string directive
From:
ko1@...
Date:
2015-11-02 10:58:09 UTC
List:
ruby-core #71298
Issue #8976 has been updated by Koichi Sasada.
Status changed from Closed to Open
Quoted from
log: https://docs.google.com/document/d/1axnQv1A2SdRExw--_RzXXJAPrRyvN7MCIB0WrKcZaSE/pub
of https://bugs.ruby-lang.org/projects/ruby/wiki/DevelopersMeeting20151021Japan
```
Decide whether -*- should be required for frozen_string_literal magic comments [Feature #8976]
naruse: vim’s indicator is “vim: …” http://vim.wikia.com/wiki/Modeline_magic
nobu: should be have an indicator of pragrma.
matz: why?
nobu: to avoid misunderstanding with comments.
matz: nobody care about that.
nobu: line should not include any other information.
matz: i agree with it.
conclusion:
accept pragma without indicators
do not accept pragma in the comment (do not skip any words before pragma keywords)
matz: i don’t want to recommend indicators.
nobu: sould we remove indicators?
akr: should remain indicators to keep compatibility.
ko1: only coding pragma?
nobu: we have warn-indnent pragmra.
naruse: warn-indent is in 2010
nobu: i’ll make it to keep compatibility.
conclusion:
keep compatibility for current indicator (for any pragma)
naruse: should we put pragmas in one line? or multi-lines?
akr: there are possibilities to increase pragma, so that shold accept multi-lines.
matz: i do not care about multi-lines.
akr: people may want to write copyright early.
naruse: people may want to write a comment for pragmas
conclusion:
accept multi-lines at the beggining of programming.
accept comments between pragmas.
akr: how about dynamic strings “foo#{bar}baz”?
nobu: how about “#{‘baz’}”?
ko1: it is easy to understand all “...” is frozen. Shugo-san’s first comment is for “compatibility”.
matz: i agree to
matz: i have another idea +“...” -> mutable, -”...” -> immutable. it is more clean than “...”.freeze. how about that, instead of the magic comment? i don’t care about pull-requests, but care about the representation of source code.
akr: …
matz: I don’t like magic comment, so that I hesitate to introduce it.
a_matsuda: + and - seems string operation. << -”foo” can be seen as a here document.
matz: I understand. + and - is not good idea.
matz: another idea: make ‘’’foo’’’ frozen. incompatibility is negligible.
matz: yet another idea: make single quoted strings frozen. This is incompatible.
MISC:
akr: should we separate this topic to another ticket? this is “how to write a pragmra”.
ko1: we should describe syntax of “how to write pragmas”
matz: I don’t like pragmas but if it is required
ko1: this pragma is for experimental feature. if we decide to reject default frozen string literal, then you remove this pragma, or remain this pragma?
matz: i will remain it.
deep_freeze
→ traversal framework?
inspect に引数を渡したい
→ inspect2? not clean.
naruse: On 1.9 I tried to implement such logic, but I gave up and use Encoding.default_internal/Encoding.default_external
```
Maybe there are several incomprehensible sentences.
Please ask that and continue to discuss.
Thanks,
Koichi
----------------------------------------
Feature #8976: file-scope freeze_string directive
https://bugs.ruby-lang.org/issues/8976#change-54670
* Author: Akira Tanaka
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
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/