Forum: Ruby-core [ruby-trunk - Feature #6074][Open] Allow alias arguments to have a comma

Posted by Thomas Sawyer (7rans)
on 2012-02-24 12:32
(Received via mailing list)
Issue #6074 has been reported by Thomas Sawyer.

----------------------------------------
Feature #6074: Allow alias arguments to have a comma
https://bugs.ruby-lang.org/issues/6074

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


This is one my biggest pet peeves with Ruby. I am always typing:

  alias :foo, :bar

And getting a damn syntax error.

Btw, is there a reason why `alias` is a keyword and not a method?
Posted by Marc-Andre Lafortune (Guest)
on 2012-02-24 23:42
(Received via mailing list)
Issue #6074 has been updated by Marc-Andre Lafortune.

Priority changed from Normal to Low

If that this is your biggest pet peeve, you must really love Ruby!

Just use `alias_method` instead. The `alias` keyword is more general and 
allows other aliases like global variables; also you don't need to give 
symbols to `alias`, you can write `alias foo bar`.
----------------------------------------
Feature #6074: Allow alias arguments to have a comma
https://bugs.ruby-lang.org/issues/6074

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


This is one my biggest pet peeves with Ruby. I am always typing:

  alias :foo, :bar

And getting a damn syntax error.

Btw, is there a reason why `alias` is a keyword and not a method?
Posted by Thomas Sawyer (7rans)
on 2012-02-25 00:08
(Received via mailing list)
Issue #6074 has been updated by Thomas Sawyer.


Yes, I have almost exclusively used #alias_method in the past, but it's 
always seems rather silly to have to use the longer term. And I bet it 
would be an easy adjustment to support a comma.

Btw, I really dislike using the non-symbol form of alias as it sticks 
out under syntax highlighters like a sore thumb.

----------------------------------------
Feature #6074: Allow alias arguments to have a comma
https://bugs.ruby-lang.org/issues/6074

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


This is one my biggest pet peeves with Ruby. I am always typing:

  alias :foo, :bar

And getting a damn syntax error.

Btw, is there a reason why `alias` is a keyword and not a method?
Posted by Yusuke Endoh (Guest)
on 2012-02-25 01:37
(Received via mailing list)
Hello,

2012/2/24 Thomas Sawyer <transfire@gmail.com>:
> Btw, is there a reason why `alias` is a keyword and not a method?

Just historical reason, I guess.  A keyword-style `alias` was
first introduced, and then alias_method was later introduced
as a reflection API for the feature.

I understand the feeling.  No keyword was needed for such a
feature.  If matz designed it now, he would implement it as
a method, I believe.


> Btw, I really dislike using the non-symbol form of alias as it sticks out under 
syntax highlighters like a sore thumb.

In this regard, you should blame your syntax highlighter?
Posted by Koichi Sasada (Guest)
on 2012-02-25 05:51
(Received via mailing list)
Issue #6074 has been updated by Koichi Sasada.

Category set to core
Target version set to 2.0.0

I think there are no reason why comma should be rejected.

----------------------------------------
Feature #6074: Allow alias arguments to have a comma
https://bugs.ruby-lang.org/issues/6074

Author: Thomas Sawyer
Status: Open
Priority: Low
Assignee:
Category: core
Target version: 2.0.0


This is one my biggest pet peeves with Ruby. I am always typing:

  alias :foo, :bar

And getting a damn syntax error.

Btw, is there a reason why `alias` is a keyword and not a method?
Posted by Nobuyoshi Nakada (nobu)
on 2012-02-25 12:13
(Received via mailing list)
Hi,

(12/02/25 13:51), Koichi Sasada wrote:
> I think there are no reason why comma should be rejected.

It's simple.


diff --git a/parse.y b/parse.y
index e47dac4..f55e754 100644
--- a/parse.y
+++ b/parse.y
@@ -979,40 +979,40 @@ stmt_or_begin  : stmt
         %*/
         }

-stmt    : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem
+stmt    : keyword_alias fitem opt_comma {lex_state = EXPR_FNAME;} fitem
         {
         /*%%%*/
-      $$ = NEW_ALIAS($2, $4);
+      $$ = NEW_ALIAS($2, $5);
         /*%
-      $$ = dispatch2(alias, $2, $4);
+      $$ = dispatch2(alias, $2, $5);
         %*/
         }
-    | keyword_alias tGVAR tGVAR
+    | keyword_alias tGVAR opt_comma tGVAR
         {
         /*%%%*/
-      $$ = NEW_VALIAS($2, $3);
+      $$ = NEW_VALIAS($2, $4);
         /*%
-      $$ = dispatch2(var_alias, $2, $3);
+      $$ = dispatch2(var_alias, $2, $4);
         %*/
         }
-    | keyword_alias tGVAR tBACK_REF
+    | keyword_alias tGVAR opt_comma tBACK_REF
         {
         /*%%%*/
       char buf[2];
       buf[0] = '$';
-      buf[1] = (char)$3->nd_nth;
+      buf[1] = (char)$4->nd_nth;
       $$ = NEW_VALIAS($2, rb_intern2(buf, 2));
         /*%
-      $$ = dispatch2(var_alias, $2, $3);
+      $$ = dispatch2(var_alias, $2, $4);
         %*/
         }
-    | keyword_alias tGVAR tNTH_REF
+    | keyword_alias tGVAR opt_comma tNTH_REF
         {
         /*%%%*/
       yyerror("can't make alias for the number variables");
       $$ = NEW_BEGIN(0);
         /*%
-      $$ = dispatch2(var_alias, $2, $3);
+      $$ = dispatch2(var_alias, $2, $4);
       $$ = dispatch1(alias_error, $$);
         %*/
         }
@@ -5432,6 +5432,10 @@ opt_nl    : /* none */
     | '\n'
     ;

+opt_comma  : /* none */
+    | ','
+    ;
+
 rparen    : opt_nl ')'
     ;
Posted by Marc-Andre Lafortune (Guest)
on 2012-02-25 20:13
(Received via mailing list)
Issue #6074 has been updated by Marc-Andre Lafortune.


I might have sounded more negative than I intended, so let me say that I 
also agree that we should allow a comma.
----------------------------------------
Feature #6074: Allow alias arguments to have a comma
https://bugs.ruby-lang.org/issues/6074

Author: Thomas Sawyer
Status: Open
Priority: Low
Assignee:
Category: core
Target version: 2.0.0


This is one my biggest pet peeves with Ruby. I am always typing:

  alias :foo, :bar

And getting a damn syntax error.

Btw, is there a reason why `alias` is a keyword and not a method?
Posted by Markus H. (markus_h)
on 2012-02-28 15:25
(Received via mailing list)
Issue #6074 has been updated by markus heiler.


I myself prefer "alias" because:

- It does not require a ','
- It is shorter to type
- It reads easier.

  def bar
    puts 'Hi from bar.'
  end

  alias foo bar
  alias_method :foo, :bar


The first way is more readable for my poor old eyes.
----------------------------------------
Feature #6074: Allow alias arguments to have a comma
https://bugs.ruby-lang.org/issues/6074

Author: Thomas Sawyer
Status: Open
Priority: Low
Assignee:
Category: core
Target version: 2.0.0


This is one my biggest pet peeves with Ruby. I am always typing:

  alias :foo, :bar

And getting a damn syntax error.

Btw, is there a reason why `alias` is a keyword and not a method?
Posted by mame (Yusuke Endoh) (Guest)
on 2012-03-29 17:59
(Received via mailing list)
Issue #6074 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to nobu (Nobuyoshi Nakada)

Sorry, I didn't know alias syntax accepts symbols as arguments!
Then I agree with this proposal.

Ruby always gives me a fresh surprise for me.

--
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Feature #6074: Allow alias arguments to have a comma
https://bugs.ruby-lang.org/issues/6074#change-25387

Author: trans (Thomas Sawyer)
Status: Assigned
Priority: Low
Assignee: nobu (Nobuyoshi Nakada)
Category: core
Target version: 2.0.0


This is one my biggest pet peeves with Ruby. I am always typing:

  alias :foo, :bar

And getting a damn syntax error.

Btw, is there a reason why `alias` is a keyword and not a method?
Posted by mame (Yusuke Endoh) (Guest)
on 2012-11-20 14:17
(Received via mailing list)
Issue #6074 has been updated by mame (Yusuke Endoh).

Target version changed from 2.0.0 to next minor


----------------------------------------
Feature #6074: Allow alias arguments to have a comma
https://bugs.ruby-lang.org/issues/6074#change-33269

Author: trans (Thomas Sawyer)
Status: Assigned
Priority: Low
Assignee: nobu (Nobuyoshi Nakada)
Category: core
Target version: next minor


This is one my biggest pet peeves with Ruby. I am always typing:

  alias :foo, :bar

And getting a damn syntax error.

Btw, is there a reason why `alias` is a keyword and not a method?
Posted by Thomas Sawyer (7rans)
on 2012-12-07 15:13
(Received via mailing list)
Issue #6074 has been updated by trans (Thomas Sawyer).


Is there any reason this can't make it into 2.0?
----------------------------------------
Feature #6074: Allow alias arguments to have a comma
https://bugs.ruby-lang.org/issues/6074#change-34507

Author: trans (Thomas Sawyer)
Status: Assigned
Priority: Low
Assignee: nobu (Nobuyoshi Nakada)
Category: core
Target version: next minor


This is one my biggest pet peeves with Ruby. I am always typing:

  alias :foo, :bar

And getting a damn syntax error.

Btw, is there a reason why `alias` is a keyword and not a method?
Posted by alexeymuranov (Alexey Muranov) (Guest)
on 2012-12-07 18:11
(Received via mailing list)
Issue #6074 has been updated by alexeymuranov (Alexey Muranov).


=begin
Just another idea in this direction: allow

  def :foo, :bar do
    puts bar
  end

in addition to

  def foo(bar)
    puts bar
  end

(the "(({do}))" in the first case can be optional).
=end

----------------------------------------
Feature #6074: Allow alias arguments to have a comma
https://bugs.ruby-lang.org/issues/6074#change-34513

Author: trans (Thomas Sawyer)
Status: Assigned
Priority: Low
Assignee: nobu (Nobuyoshi Nakada)
Category: core
Target version: next minor


This is one my biggest pet peeves with Ruby. I am always typing:

  alias :foo, :bar

And getting a damn syntax error.

Btw, is there a reason why `alias` is a keyword and not a method?
Posted by Eric Hodel (Guest)
on 2012-12-07 18:37
(Received via mailing list)
On Dec 7, 2012, at 9:10, "alexeymuranov (Alexey Muranov)" 
<redmine@ruby-lang.org> wrote:
> Issue #6074 has been updated by alexeymuranov (Alexey Muranov).
>
>
> =begin
> Just another idea in this direction:

If you have a separate idea open a separate feature request.

Do not hijack existing issues.

Hijacking issues makes them difficult for the committers to understand. 
Since this feature is delayed until next minor, continued off-topic 
discussion may lead to an issue being closed because its purpose is too 
difficult to determine.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.