Created
January 6, 2014 15:22
-
-
Save mbj/8284308 to your computer and use it in GitHub Desktop.
ruby returns take blocks?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mbj@mbj ~/devel/unparser (master*) % bundle exec ruby-parse return-a.rb return-b.rb | |
Using Parser::Ruby21 to parse 2 files. | |
(block | |
(return | |
(send nil :foo | |
(send nil :arg))) | |
(args | |
(arg :bar)) nil) | |
(return | |
(block | |
(send nil :foo | |
(send nil :arg)) | |
(args | |
(arg :bar)) nil)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return foo arg do |bar| | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return foo(arg) do |bar| | |
end |
In contrast RBX:
mbj@mbj ~/devel/unparser (master*) % ruby compile -S return-a.rb return-b.rb
[:script,
[:return,
[:iter,
[:call,
nil,
:foo,
[:arglist, [:call, nil, :arg, nil], [:iter, [:args, :bar], [:nil]]]],
[:args, :bar],
[:nil]]]]
[:script,
[:return,
[:iter,
[:call,
nil,
:foo,
[:arglist, [:call, nil, :arg, nil], [:iter, [:args, :bar], [:nil]]]],
[:args, :bar],
[:nil]]]]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I expect both are parsed like
return-b.rb
.