[#88925] [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical — ko1@...
Issue #15095 has been updated by ko1 (Koichi Sasada).
4 messages
2018/09/09
[#88927] Re: [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical
— Eric Wong <normalperson@...>
2018/09/09
ko1@atdot.net wrote:
[#88926] [Ruby trunk Feature#15095] [PATCH] share VM stack between threads and fibers if identical — ko1@...
Issue #15095 has been updated by ko1 (Koichi Sasada).
3 messages
2018/09/09
[#89218] [Ruby trunk Bug#15130] open-uri hangs on cygwin — duerst@...
Issue #15130 has been updated by duerst (Martin D端rst).
5 messages
2018/09/30
[ruby-core:89141] Re: [Ruby trunk Feature#15149] extend string format to nil safe
From:
Austin Ziegler <halostatue@...>
Date:
2018-09-24 04:36:31 UTC
List:
ruby-core #89141
Libraries that want to support versions of Ruby before 2.3(?) can’t use the
safe navigation operator, either. I’m aware that those versions are no
longer supported, but regardless of the utility of `'%&…'` as a format,
that’s not a great argument against it. I’m mostly neutral on the concept
for positional format arguments, extremely negative on the proposed result
(it should be *either* a blank string or a change of the format function
from `Integer(z)` to `z.to_i`, for example).
I think that there’s a better argument for this with named formatting:
```ruby
'%&{cost}' % Hash.new # => "", as %{cost} is equivalent to %<cost>s.
'%&0.2<cost>f' % Hash.new # => "0.00"
```
This, especially if the `%&` formats were implemented as calling `#to_i`,
`#to_f`, `#to_s`, etc. on `nil` would make format more resilient to
externally-provided content.
-a
On Sun, Sep 23, 2018 at 10:47 PM <nobu@ruby-lang.org> wrote:
> Issue #15149 has been updated by nobu (Nobuyoshi Nakada).
>
>
> Rather it feels the role of `inspect`, that is used by `%p`.
> Regarding the compatibility, that new format string can't work with
> earlier versions.
> That means libraries which want to support earlier versions can't use it.
>
> ----------------------------------------
> Feature #15149: extend string format to nil safe
> https://bugs.ruby-lang.org/issues/15149#change-74174
>
> * Author: foonlyboy (Eike Dierks)
> * Status: Open
> * Priority: Normal
> * Assignee:
> * Target version:
> ----------------------------------------
> I'd like to suggest a new modifier for the string format
> (aka the printf-style format string)
>
> ## Examples
>
> ### Current
> ~~~
> '%s' % nil => ''
> '%d' % nil => Exception: TypeError: can't convert nil into Integer
> ~~~
>
> ### Suggestion
> ~~~
> '%&s' % nil => 'nil'
> '%&d' % nil => 'nil'
> ~~~
>
> ## Explanation
>
> I suggest to introduce a new modifier for the format strings.
> (in the examples above I used the ampersand char: **&**)
>
> That modifier should change the behaviour of string formatting in two ways:
> - accept nil as an argument *for all conversion formats*
> - display explicit **'nil'** when **nil** is given as an argument
>
> ## Rationale
>
> This feature would be most helpful for log messages and printf style
> debugging
>
> - currently only the %s format accepts nil, but returns an empty string.
> - all other formats raise on nil
>
> - when displaying strings, nil args show up indiscernible from empty
> strings
> - when displaying anything else (like %d, %f etc) things just break
>
> ## Compatibility
>
> I believe that this new feature would be fully compatible with any
> existing code.
> Up to now the ampersand was not allowed as a modifier and results in an
> Exception:
> ~~~
> '%&d' % nil => ArgumentError: malformed format string - %&
> ~~~
>
> As far as I know, the ampersand has not been used in other variations of
> printf, yet.
>
>
> ## Design
>
> I suggest to use the **&** (ampersand) because that would be in line with
> the ruby nil safe operator.
>
> I opt for *explicitly* showing 'nil' for nil args (instead of the empty
> string)
>
>
>
>
>
> --
> https://bugs.ruby-lang.org/
>
> Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
>
--
Austin Ziegler • halostatue@gmail.com • austin@halostatue.ca
http://www.halostatue.ca/ • http://twitter.com/halostatue
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>