T
Trans
Florian said:Trans said:But also, you do not need to bother with them at all. There are a
couple of options for forgetting about the whole thing. The simplest
is:
require 'nanosys'
Then you can use the actual punctuation all you want --and w/o any
special require method:
require 'nano/array/[]='
But I'd rather see this based on meaningful, easy to understand naming
scheme under the hood.
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=.
Hi Florian,
While I agree that this is a well thought out transform, I wonder, what
is the motivation exactly? The URI transform allows the computer to
deal with the methods in a straightforward manner, such as in the
NanoSystem metainfo and it's capabilities like:
String.use :[]=
Also I have an interesting experiment using method_missing to
automatically require nano-methods. Of course I can still do those
things with the above, but I would noless have to run it through your
transform rather then URI's. So there's still a need for a require_esc
and require_nano, etc.
BTW, I wonder, have you enumerated every possibility? Also there are
some odd looking fringe cases like: '__send__!' => '__send___bang'. At
worst though, what if a method is actually called #foo_p? Hmm... now
that I think of it, there is already a method called 'attr_setter'.
I'll give it some more consideration though. In the mean time I added
two new kernel methods #uri and #unuri. So there's another way:
require uri('nano/array/[]=')
Additionlly I created an exectuable called uri which makes it easy to
look up on the command line:
uri '+@'
%2B%40
And for reference, here's a chart:
{
"!" => "%21"
"%" => "%25"
"&" => "%26"
"*" => "%2A"
"+" => "%2B"
"-" => "%2D"
"/" => "%2F"
":" => "%3A"
"<" => "%3C"
"=" => "%3D"
">" => "%3E"
"?" => "%3F"
"@" => "%40"
"[" => "%5B"
"]" => "%5D"
"^" => "%5E"
"`" => "%60"
"|" => "%7C"
"~" => "%7E"
}
T.