[#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:71722] [Ruby trunk - Feature #9098] Indent heredoc against the left margin by default when "indented closing identifier" is turned on.
From:
andrewm.bpi@...
Date:
2015-11-28 17:37:45 UTC
List:
ruby-core #71722
Issue #9098 has been updated by Andrew M.
Right. I guess what I'm saying is that tabs shouldn't be treated as equivalent to spaces at all, since the number of spaces they are "equivalent" to is different for every developer, depending on what they have their editor set to display.
This can and will result in unexpected behavior (aka bugs) when tabs and spaces are mixed in indentation by mistake. I'd much rather these bugs be caught by the compiler and brought to the developer's attention with a clearly-worded error message then simply ignored and left for the developer to find out about later.
Tabs should be treated as tabs, and spaces should be treated as spaces. I'm not really sure what the argument is for treating one character as equivalent to another in the first place. Is there any situation where a developer might _want_ that behavior? What's the use-case here? I honestly can't think of one.
To me, this just feels like a way to make it easy for developers to unknowingly create bugs in their code.
----------------------------------------
Feature #9098: Indent heredoc against the left margin by default when "indented closing identifier" is turned on.
https://bugs.ruby-lang.org/issues/9098#change-55128
* Author: Prem Sichanugrist
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
tl;dr: I would like to port +String#strip_heredoc+ (http://api.rubyonrails.org/classes/String.html#method-i-strip_heredoc) from Rails and enable it on `<<-` heredoc.
Hi,
I've been using here document (heredoc) for a while, and I've found out that it's very annoying that the content is always treated as flushed left. Per syntax doc:
Note that the while the closing identifier may be indented, the content is
always treated as if it is flush left. If you indent the content those spaces
will appear in the output.
So, this is the current result if you use heredoc in Ruby:
class FancyHello
def self.hello
puts <<-README.inspect
Hello
World!
README
end
end
FancyHello.hello # => " Hello\n World!\n"
In Rails, the core team has implemented +String#strip_heredoc+, which handles this scenario by remove leading white spaces from the string. However, not many user know that Rails has that method, and instead doing this to get around it:
class FancyHello
def self.hello
puts <<-README.inspect
Hello
World!
README
end
end
FancyHello.hello # => "Hello\n World!\n"
I really think that we could do better on this by removing the leading white spaces, matching +String#strip_heredoc+ method.
So, after the change, I want to be able to do this, and get this result:
class FancyHello
def self.hello
puts <<-README.inspect
Hello
World!
README
end
end
FancyHello.hello # => "Hello\n World!\n"
Note: the behavior on `<<HEREDOC` will stay the same, as I feel like in that case you really want the input to be flushed left.
I'll write up a patch and submit it if you think this is a good idea. Please let me know any question or concern you may have.
Thank you,
Prem
---Files--------------------------------
dedent_heredoc.patch (12.8 KB)
--
https://bugs.ruby-lang.org/