Feature #3922

Syntax awkwardness

Added by Ragmaanir (Lasse Fabisch) over 1 year ago. Updated 4 months ago.

[ruby-core:32731]
Status:Rejected Start date:10/09/2010
Priority:Low Due date:
Assignee:matz (Yukihiro Matsumoto) % Done:

0%

Category:core
Target version:-

Description

[code]
1 + (2; 1) #=> 2
puts(1; 2) #=> syntax error
puts((1; 2)) # like: puts 2
puts (3)*2 #=> 6
puts(3)*2 #=> nil-error
puts (1; 2) #=> syntax error
puts (1; 2)*3 #=> syntax error
puts ((1; 2))*3 # like: puts 6
[/code]

IMO this is awkward behavior (but maybe it is intended). I think the same results can be achieved with a newline instead of ';'.

History

Updated by matz (Yukihiro Matsumoto) over 1 year ago

Hi,

In message "Re: [ruby-core:32731] [Ruby 1.9-Bug#3922][Open] Syntax awkwardness"
    on Sat, 9 Oct 2010 22:39:10 +0900, Lasse Fabisch <redmine@ruby-lang.org> writes:

|[code]
|1 + (2; 1) #=> 2
|puts(1; 2) #=> syntax error
|puts((1; 2)) # like: puts 2
|puts (3)*2 #=> 6
|puts(3)*2 #=> nil-error
|puts (1; 2) #=> syntax error
|puts (1; 2)*3 #=> syntax error
|puts ((1; 2))*3 # like: puts 6
|[/code]
|
|IMO this is awkward behavior (but maybe it is intended). I think the same results can be achieved with a newline instead of ';'.

It's intended.  Do you have any proposal of 'non-awkward' syntax?

							matz.

Updated by matz (Yukihiro Matsumoto) over 1 year ago

  • Category changed from YARV to core
  • Status changed from Open to Feedback
  • Assignee changed from ko1 (Koichi Sasada) to matz (Yukihiro Matsumoto)

Updated by Ragmaanir (Lasse Fabisch) over 1 year ago

Ok, first i was surprised by the fact that it is possible to embed
multiple statements inside a parenthesised expression:
[code]
(4; 1) #=> 1
### OR:
(4
1) #=> 1
[/code]
But ok, maybe this is needed somewhere (do you have an example? i could
not come up with one yet).

This is what i think should not behave like it does:
[code]
puts (1; 2) # syntax error
[/code]
If im not mistaken the space in front of the parenthesis prevents that
the statement is interpreted as a parenthesized method call, so the `(1;
2)` should be interpreted as an expression. But then, why does it raise
an error?

Updated by ko1 (Koichi Sasada) 12 months ago

  • Tracker changed from Bug to Feature

Updated by kosaki (Motohiro KOSAKI) 4 months ago

  • Status changed from Feedback to Rejected
no progress very long time.

Also available in: Atom PDF