From: Steven Lumos Date: 2008-09-26T08:22:34+09:00 Subject: [ruby-core:18963] Re: [RCR] $ABOUT.ts "Laurent Sansonetti" writes: > This is a very nice idea. > > My 2 cents, > > Laurent Can $ABOUT._why be an array? Steve > On Thu, Sep 25, 2008 at 10:57 AM, _why wrote: >> I don't want to be indelicate and we can address this some other >> time. Maybe a good place for an easter egg would be as a virtual >> global variable. Global vars are a rather open namespace and if we >> kept the code in C none of the strings here would be allocated until >> needed. I think ts would appreciate that efficiency, perhaps? >> >> Anyway, what do you think about an $ABOUT with a singleton? >> >> $ABOUT = %{"Maybe because Ruby is a mansion, a backdoor is bigger than you expect."\n - matz} >> def $ABOUT.ts >> %{"I know nothing, I just ask ruby what it do."\n - Guy Decoux (1955 - 2008)} >> end >> >> From [ruby-talk:20662] and [ruby-talk:5795], respectively. >> >> In ruby.c, this becomes: >> >> static VALUE >> rb_about_ts(VALUE self) >> { >> return rb_str_new2("\"I know nothing, I just ask ruby what it do.\"\n - Guy Decoux (1955 - 2008)"); >> } >> >> static VALUE >> rb_about() >> { >> VALUE about = rb_str_new2("\"Maybe because Ruby is a mansion, a backdoor is bigger than you expect.\"\n - matz"); >> rb_define_singleton_method(about, "ts", rb_about_ts, 0); >> return about; >> } >> >> Then, in ruby_prog_init: >> >> rb_define_virtual_variable("$ABOUT", rb_about, 0); >> >> _why >> >>