Re: nano & mega
- From: "Trans" <transfire@xxxxxxxxx>
- Date: 3 Sep 2005 18:10:19 -0700
Florian Groß wrote:
> Luckily, I have already mapped the special method names. Let me use the
> look up table from extract.rb:
>
> {
> "+" => "op_plus",
> "-" => "op_minus",
> "+@" => "op_plus_self",
> "-@" => "op_minus_self",
> "*" => "op_mul",
> "**" => "op_pow",
> "/" => "op_div",
> "%" => "op_mod",
> "<<" => "op_lshift",
> ">>" => "op_rshift",
> "~" => "op_tilde",
> "<=>" => "op_cmp",
> "<" => "op_lt",
> ">" => "op_gt",
> "==" => "op_equal",
> "<=" => "op_lt_eq",
> ">=" => "op_gt_eq",
> "===" => "op_case_eq",
> "=~" => "op_apply",
> "|" => "op_or",
> "&" => "op_and",
> "^" => "op_xor",
> "[]" => "op_fetch",
> "[]=" => "op_store"
> }
>
> I'd suggest using foo_bang for foo!, foo_p for foo? and foo_setter for foo=.
I've given this some more thought. If I do this, I could enforce a rule
that says no nono-method is to start with 'op_'. While that's skirting
potential clash, I think it would be okay. But I still have two others
problems.
How to deal with ?, !, =. That's a bit trickier, as its hard to enforce
a rule related to those. Things like '_p', '_setter', have too great a
chance for some actual method clash. So I have to figure something else
out for that.
Also, I have to distinguish class methods. Right now I do it with '::'
prefix, which under URI translation if '%3A%3A'. What will I do here?
"class_" prefix desn't work for the same reason as the above.
Also, am I overlooking any other potential pitfalls?
So here's an idea. While Ruby techinically allows any non-blank string
as a method name (ie. define_method "whatever you want!@#$%") I am as
sure as I can ever be that I will never use such a thing in Nano. Given
this, I need only worry about the literal cases. Now in file systems
the dash characeter '-' is pretty much unviserally accepted, but it's
not allowed in literal method names (expect for the op) So what if I
use that characeter as a distinguishing element? Would that work for
you?
So foo-bang, foo-p, foo-set, and class-foo, plus I might as well do:
{
"+" => "op-plus",
"-" => "op-minus",
"+@" => "op-plus-self",
"-@" => "op-minus-self",
"*" => "op-mul",
"**" => "op-pow",
"/" => "op-div",
"%" => "op-mod",
"<<" => "op-lshift",
">>" => "op-rshift",
"~" => "op-tilde",
"<=>" => "op-cmp",
"<" => "op-lt",
">" => "op-gt",
"==" => "op-equal",
"<=" => "op-lt-eq",
">=" => "op-gt-eq",
"===" => "op-case-eq",
"=~" => "op-apply",
"|" => "op-or",
"&" => "op-and",
"^" => "op-xor",
"[]" => "op-fetch",
"[]=" => "op-store"
}
I thik also I'd like to reduce all of them to a single dash if
reasonably possible, which would change a few of them.
What do you think of this?
Thanks,
T.
.
- Follow-Ups:
- Re: nano & mega
- From: Florian Groß
- Re: nano & mega
- From: Trans
- Re: nano & mega
- References:
- nano & mega
- From: Jeff Wood
- Re: nano & mega
- From: Trans
- Re: nano & mega
- From: Jeff Wood
- Re: nano & mega
- From: Dave Burt
- Re: nano & mega
- From: Florian Groß
- Re: nano & mega
- From: James Edward Gray II
- Re: nano & mega
- From: Gavin Kistner
- Re: nano & mega
- From: David A. Black
- Re: nano & mega
- From: Trans
- Re: nano & mega
- From: Florian Groß
- nano & mega
- Prev by Date: Re: Still looking for a Ruby MUD client
- Next by Date: Kerberos module for ruby?
- Previous by thread: Re: nano & mega
- Next by thread: Re: nano & mega
- Index(es):
Relevant Pages
|