Nano & mega

What's up with the funky names ... AND, is there an easy way to just require
all of them ?
I'd like to have all of nano and all of mega easily includable without 400
separate require statements ( exagerated I know, but still )
j.

···

--
"So long, and thanks for all the fish"

Jeff Wood

Hi Jeff,

The nice thing about Nano is that you can require just the extension
methods you need, no more, no less. I realize at first that seems
unecessarily burdensome, but in practice it actually proves be quite
natural. And I highly recommend you try to use the library in this
manner. Nonetheless, there is indeed a way to include a many a method
at once.

  require 'nano/full'

But be forewarned, this is still experimental. The reason is that not
all of the methods in Nano "play nice" --some have very specific uses.
What I have done is make a list of these particular methods and
"subtract" them from the totality and this is what is in nano/full.rb.
But those lists are not complete/perfected yet, so don't be suprised if
something odd occurs when using 'full'. (And please let me know if you
run across something so I can adjust the lists!) To get more info on
what exactly these methods are try this:

  require 'nanosys'

  # list of method files in full
  NanoSystem.full

  # list of methods considered unsafe and not in full
  NanoSystem.unsafe

  # other methods not in full as a cautionary measure
  NanoSystem.noauto

To learn more I recommend the README doc which is included in the
package and is also the front page of the API RDocs on the website
(http://nano.rubyforge.org)

As for Mega, again it is not the standard usage, but you can do:

  require 'mega'
  autoload_classes

Now whenever you reference a Mega Module it will be automatically
required (w/ a few exceptions.) As of yet I haven't thought of creating
a require file that loads all of them, but I suppose I can. Thanks for
the suggestion.

T.

2 minutes looking at the library hierarchy shows:

require 'nano' #Same as require 'nano/base', a common set of functionality
require 'nano/array' #All the array items
require 'nano/full' #Everything

···

On Aug 31, 2005, at 3:33 PM, Jeff Wood wrote:

[snip] AND, is there an easy way to just require all of them ?
I'd like to have all of nano and all of mega easily includable without 400
separate require statements ( exagerated I know, but still )

Jeff Wood wrote:

What's up with the funky names ...

Since Ruby methods can have/be punctuation marks, it is necessary to
encode them in order to be compatible with all file systems. I have
used URI escaping so:

  : -> %3A
  ? -> %3F
  ! -> %21
  = -> %3D

etc.

Jeff Wood wrote...

What's up with the funky names ... AND, is there an easy way to just
require
all of them ?
I'd like to have all of nano and all of mega easily includable without
400
separate require statements ( exagerated I know, but still )

In the API docs at nano.rubyforge.org and mega.rubyforge.org, check out the
documentation for the _files_ nano.rb, nano/base.rb (and mega's
corresponding files) to see the list of what's included there.

For example, if you just do:
  require 'nano'
or:
  require 'nano/base'
you will get all of these for free:
  a.. nano/kernel/require_nano
  b.. nano/array/to_h
  c.. nano/binding/eval
  d.. nano/binding/self
  e.. nano/binding/caller
  f.. nano/comparable/cmp
  g.. nano/enumerable/collect_with_counter
  h.. nano/enumerable/each_slice
  i.. nano/float/round_off
  j.. nano/float/round_to
  k.. nano/float/round_at
  l.. nano/hash/slice
  m.. nano/hash/to_h
  n.. nano/kernel/fn
  o.. nano/kernel/called
  p.. nano/kernel/here
  q.. nano/matchdata/match
  r.. nano/module/basename
  s.. nano/nilclass/to_f
  t.. nano/nilclass/to_h
  u.. nano/object/metaclass
  v.. nano/proc/to_method
  w.. nano/range/to_r
  x.. nano/regexp/to_re
  y.. nano/string/blank%3F
  z.. nano/string/cmp
  aa.. nano/string/to_re
  ab.. nano/symbol/not
  ac.. nano/time/to_time
Then there's the require_* methods, require_all in particular.

Happy requiring!
Dave

Dave Burt wrote:

Jeff Wood wrote...

What's up with the funky names ... AND, is there an easy way to just require
all of them ?
I'd like to have all of nano and all of mega easily includable without 400
separate require statements ( exagerated I know, but still )
   
In the API docs at nano.rubyforge.org and mega.rubyforge.org, check out the documentation for the _files_ nano.rb, nano/base.rb (and mega's corresponding files) to see the list of what's included there.

For example, if you just do:
require 'nano'
or:
require 'nano/base'
you will get all of these for free:
a.. nano/kernel/require_nano
b.. nano/array/to_h
c.. nano/binding/eval
d.. nano/binding/self
e.. nano/binding/caller
f.. nano/comparable/cmp
g.. nano/enumerable/collect_with_counter
h.. nano/enumerable/each_slice
i.. nano/float/round_off
j.. nano/float/round_to
k.. nano/float/round_at
l.. nano/hash/slice
m.. nano/hash/to_h
n.. nano/kernel/fn
o.. nano/kernel/called
p.. nano/kernel/here
q.. nano/matchdata/match
r.. nano/module/basename
s.. nano/nilclass/to_f
t.. nano/nilclass/to_h
u.. nano/object/metaclass
v.. nano/proc/to_method
w.. nano/range/to_r
x.. nano/regexp/to_re
y.. nano/string/blank%3F
z.. nano/string/cmp
aa.. nano/string/to_re
ab.. nano/symbol/not
ac.. nano/time/to_time
Then there's the require_* methods, require_all in particular.

Happy requiring!
Dave

Yeah, about 10 seconds after I sent the mail I found that part of the docs ... Felt like a real goon. Anyways, thanks for putting the information into the docs, and for shooting me a note.

j.

Trans wrote:

Jeff Wood wrote:

What's up with the funky names ...
   
Since Ruby methods can have/be punctuation marks, it is necessary to
encode them in order to be compatible with all file systems. I have
used URI escaping so:

: -> %3A
? -> %3F
! -> %21
= -> %3D

etc.

Wow, I'd say that the punctionation ( with conversion or not ) should come out of the filenames... the %3A stuff is about as un-user-friendly as anything I've ever seen.

j.

Jeff Wood wrote:

Wow, I'd say that the punctionation ( with conversion or not ) should
come out of the filenames... the %3A stuff is about as un-user-friendly
as anything I've ever seen.

You'd have to have a better alternative, and I can't think of one.
Consistent naming's important, and I'd rather not be using interesting
suffixes like "nano/array/rotate_bang".

To ease the pain, instead of:
  require 'nano/array/rotate%21'
nano provides:
  require 'nanoreq' # or nanosys or nano or nano/base
  require_nano 'array/rotate!'
and I presume mega has an analog.

Cheers,
Dave

Dave Burt wrote:

You'd have to have a better alternative, and I can't think of one. Consistent naming's important, and I'd rather not be using interesting suffixes like "nano/array/rotate_bang".

Why not? I think I would prefer this over uri escaping. It's also the convention Ruby uses for the C method names.

Dave Burt wrote:

Jeff Wood wrote:

Wow, I'd say that the punctionation ( with conversion or not ) should
come out of the filenames... the %3A stuff is about as un-user-friendly
as anything I've ever seen.
   
You'd have to have a better alternative, and I can't think of one. Consistent naming's important, and I'd rather not be using interesting suffixes like "nano/array/rotate_bang".

To ease the pain, instead of:
require 'nano/array/rotate%21'
nano provides:
require 'nanoreq' # or nanosys or nano or nano/base
require_nano 'array/rotate!'
and I presume mega has an analog.

Cheers,
Dave

well, there are many alternatives.. I'd just have require 'nano/array' or if you still want the one-by-one functionality ... require 'nano/array/rotate'

ymmv.

j.

Yeah, I have to agree here. I can translate ! to _bang a lot easier than I can think up what the URI escape code is.

James Edward Gray II

···

On Sep 1, 2005, at 8:59 AM, Florian Groß wrote:

Dave Burt wrote:

You'd have to have a better alternative, and I can't think of one. Consistent naming's important, and I'd rather not be using interesting suffixes like "nano/array/rotate_bang".

Why not? I think I would prefer this over uri escaping. It's also the convention Ruby uses for the C method names.

It thought nano tweaks include to do the conversion behind the scenes.
Such that you can do

require 'file/exists?'

and require first escapes the ? and then calls the old require.

But I have not used this libs so far.

regards,

Brian

···

On 01/09/05, James Edward Gray II <james@grayproductions.net> wrote:

On Sep 1, 2005, at 8:59 AM, Florian Groß wrote:

> Dave Burt wrote:
>
>
>> You'd have to have a better alternative, and I can't think of one.
>> Consistent naming's important, and I'd rather not be using
>> interesting suffixes like "nano/array/rotate_bang".
>>
>
> Why not? I think I would prefer this over uri escaping. It's also
> the convention Ruby uses for the C method names.

Yeah, I have to agree here. I can translate ! to _bang a lot easier
than I can think up what the URI escape code is.

James Edward Gray II

--
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/

Bang is pretty easy. What are suggestions for #= or #foo versus #foo= ?

···

On Sep 1, 2005, at 8:11 AM, James Edward Gray II wrote:

Yeah, I have to agree here. I can translate ! to _bang a lot easier than I can think up what the URI escape code is.

Gavin Kistner wrote:

···

On Sep 1, 2005, at 8:11 AM, James Edward Gray II wrote:

Yeah, I have to agree here. I can translate ! to _bang a lot easier than I can think up what the URI escape code is.

Bang is pretty easy. What are suggestions for #= or #foo versus #foo= ?

This is what I mean ... why not just package them all based on the class they use ?

Or maybe extend require to actually allow you to be selective about what you require from a file .... like a require 'blah=' from 'nano/array' ???

j.

Yeah, I have to agree here. I can translate ! to _bang a lot easier than I can think up what the URI escape code is.

Bang is pretty easy.

You're probably right.

What are suggestions for #=

Good example. That's a tough one. My best thought:

indexed_equals

or #foo versus #foo= ?

This one seems obvious to me:

foo
foo_equals

To be perfectly honest though, I haven't even downloaded the library in question, so I have literally no say here. I was just agreeing that I code remember a word better than a code.

I'll go back to minding my own business now. :wink:

James Edward Gray II

···

On Sep 1, 2005, at 9:25 AM, Gavin Kistner wrote:

On Sep 1, 2005, at 8:11 AM, James Edward Gray II wrote:

Hi --

···

On Thu, 1 Sep 2005, Gavin Kistner wrote:

On Sep 1, 2005, at 8:11 AM, James Edward Gray II wrote:

Yeah, I have to agree here. I can translate ! to _bang a lot easier than I can think up what the URI escape code is.

Bang is pretty easy. What are suggestions for #= or #foo versus #foo= ?

Maybe set_at and foo_set or something like that...?

David

--
David A. Black
dblack@wobblini.net

$ grep "rb_define_.*\[\]" ~/src/ruby/ruby.head/array.c
    rb_define_singleton_method(rb_cArray, "", rb_ary_s_create, -1);
    rb_define_method(rb_cArray, "", rb_ary_aref, -1);
    rb_define_method(rb_cArray, "=", rb_ary_aset, -1);

···

On Thu, Sep 01, 2005 at 11:35:00PM +0900, James Edward Gray II wrote:

>What are suggestions for #=

Good example. That's a tough one. My best thought:

indexed_equals

--
Mauricio Fernandez

While _bang and _equals might be easy to remember, how easy will it be
to remember the many others if they all have some made up name?

  array/[]= -> array/aset
  hash/[]= -> hahs/hset
  proc/* -> proc/compose_op
  enumerable/** -> enumerable/cross_op
  ...

So if you think remebering a handful or two URI escape codes is hard,
think how much harder it would be to remember dozens and dozens of
semi-inconsistent names and the punctuation they correspond-to. I do
not say this w/o inexperience either, since the last version of Facets
actually did just that. It wasn't nice. The escapes look weird but they
quickly become old hat, and are easy enough to look up:

  ruby -ruri -e'p URI.escape( "!", "!" )'

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/[]='

T.

Trans wrote:

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=.

Florian Groß:

Luckily, I have already mapped the special method names. Let me use the
look up table from extract.rb:
<snip>

Yes, nice. I was disagreeing until I saw this list, now I figure the task of
actually coming up with the names was the barrier.

I'd suggest using foo_bang for foo!, foo_p for foo? and foo_setter for
foo=.

Why foo_p? What's the p? ZenSpider's ZenTest suggests foo_eh. I could see
maybe _q or _bool. Also I'd prefer _set to _setter.

It's not a big thing, but it means filenames that are more human-legible, if
a little less machine-readable.

Cheers,
Dave