'Special' method highlighting - a list

Gavin Sinclair gsinclair at soyabean.com.au
Fri Aug 22 01:32:48 EDT 2003


On Tuesday, August 19, 2003, 8:45:50 AM, Gavin wrote:

>> OK, do you feel like making a more specific list? Are then any others
>> missing?

> All right; I'll try to do that in the very near future.


I've had a look at the "special" methods (those in Module, Class,
Object and Kernel), and here is what I think should be highlighted, in
addition to what we have now.

  attr, attr_accessor, attr_reader, attr_writer
  alias_method (?)
  callcc
  fork
  public, private, protected

My heuristic is as follows.  A "special" method, worthy of
highlighting, is one which:
 (a) is called without a receiver
 (b) performs a magic trick not typically achievable in Ruby alone,
     such that it is easily mistaken for genuine keyword

Reason (a) excludes "new" and "exclude".  I think highlighting a
method that has an explicit receiver is ugly.

Reason (b) covers "callcc" and "fork", which seem magical enough to
me.  Ditto "private" et al.  The "attr" family can be implemented
in Ruby easily, but they are so commonly used as to be almost part of
the language and come in for special mention.

"alias_method" I put in because "alias" is highlighted.  Then again,
that goes for "undef_method" as well.  I am unsure about that one.  I
always just use "alias" anyway.  I wish Ruby could lose some of this
clutter, like "attr".  I mean, really...

Anyway, discussion is welcomed on these items, especially the "attr"
family and "alias_method", which can be argued either way.  The others
are clear cut in my mind.

Cheers,
Gavin




More information about the vim-ruby-devel mailing list