ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:40697] [ruby-trunk - Feature #5558][Open] String#% strange arity errors
@ 2011-11-03  1:25 Thomas Sawyer
  2012-03-27 14:44 ` [ruby-core:43740] [ruby-trunk - Feature #5558][Assigned] " mame (Yusuke Endoh)
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Sawyer @ 2011-11-03  1:25 UTC (permalink / raw
  To: ruby-core


Issue #5558 has been reported by Thomas Sawyer.

----------------------------------------
Feature #5558: String#% strange arity errors
http://redmine.ruby-lang.org/issues/5558

Author: Thomas Sawyer
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


When the number of arguments do not match the number of % parameters, the String#% method has some odd behavior.

When too many, it seems to work fine, ignoring the extra arguments.

  "%s" % [1,2]  #=> "1"

But if `$DEBUG = true`,

  "%s" % [1,2]  #=> ArgumentError: too many arguments for format string

That doesn't seem right. Is it an error or isn't it?

For too few arguments it is always an error:

  "%s" % []   #=> ArgumentError: too few arguments

Personally, I think it should use '' for missing arguments. That would make it more flexible in practice.

I consider the first $DEBUG issue a bug, and the later a feature. But I'll just call it a feature altogether to make things easier.



-- 
http://redmine.ruby-lang.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ruby-core:43740] [ruby-trunk - Feature #5558][Assigned] String#% strange arity errors
  2011-11-03  1:25 [ruby-core:40697] [ruby-trunk - Feature #5558][Open] String#% strange arity errors Thomas Sawyer
@ 2012-03-27 14:44 ` mame (Yusuke Endoh)
  0 siblings, 0 replies; 2+ messages in thread
From: mame (Yusuke Endoh) @ 2012-03-27 14:44 UTC (permalink / raw
  To: ruby-core


Issue #5558 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to matz (Yukihiro Matsumoto)

This behavior is certainly intended.  See [ruby-core:5161].

There is another example that behavior changes whether it is 
debug mode or not: Thread#abort_on_exception.

    Thread.new { raise }
    sleep 1

The above will terminate normally without -d.
But it will blow up with -d.
So, we should know that -d affects the behavior, IMO.

-- 
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Feature #5558: String#% strange arity errors
https://bugs.ruby-lang.org/issues/5558#change-25247

Author: trans (Thomas Sawyer)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: 


When the number of arguments do not match the number of % parameters, the String#% method has some odd behavior.

When too many, it seems to work fine, ignoring the extra arguments.

  "%s" % [1,2]  #=> "1"

But if `$DEBUG = true`,

  "%s" % [1,2]  #=> ArgumentError: too many arguments for format string

That doesn't seem right. Is it an error or isn't it?

For too few arguments it is always an error:

  "%s" % []   #=> ArgumentError: too few arguments

Personally, I think it should use '' for missing arguments. That would make it more flexible in practice.

I consider the first $DEBUG issue a bug, and the later a feature. But I'll just call it a feature altogether to make things easier.



-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-27 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-03  1:25 [ruby-core:40697] [ruby-trunk - Feature #5558][Open] String#% strange arity errors Thomas Sawyer
2012-03-27 14:44 ` [ruby-core:43740] [ruby-trunk - Feature #5558][Assigned] " mame (Yusuke Endoh)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).