the monopoly of classes

Jim Menard jimm at io.com
Fri May 23 01:03:30 UTC 2003


Andreas,

On Thursday, May 22, 2003, at 07:23  PM, Andreas Raab wrote:

>> What you're describing sounds somewhat similar to what Ruby
>> does - IIRC, there's a Kernel mixin whose methods are available
>> from any object, but which are also available in the global
>> scope.
>
> Yes, Ruby has been one of the inspirations for it. BTW, not being a 
> Ruby
> hacker is there an easy way to find out about _all_ the global 
> functions in
> a Ruby environment? I'd be interested in various things including how 
> many
> "global functions" there are (compared to what we see in class Object),
> what's covered there and how often people "feel the need" to extend the
> global environment.

% irb
irb(main):007:0> (self.public_methods + self.private_methods).sort
=> ["==", "===", "=~", "Array", "DelegateClass", "Float", "Integer", 
"String", "__id__", "__send__", "`", "abort", "at_exit", "autoload", 
"binding", "block_given?", "callcc", "caller", "catch", "chomp", 
"chomp!", "chop", "chop!", "class", "clone", "display", "dup", "eql?", 
"equal?", "eval", "exec", "exit", "exit!", "extend", "fail", "fork", 
"format", "freeze", "frozen?", "getc", "gets", "global_variables", 
"gsub", "gsub!", "hash", "id", "include", "initialize", "inspect", 
"install_alias_method", "install_aliases", "instance_eval", 
"instance_of?", "instance_variables", "irb", "irb_binding", 
"irb_change_binding", "irb_change_workspace", "irb_context", 
"irb_exit", "irb_fg", "irb_fork", "irb_jobs", "irb_kill", "irb_quit", 
"irb_source", "is_a?", "iterator?", "kind_of?", "lambda", "load", 
"local_variables", "loop", "method", "method_missing", "methods", 
"nil?", "open", "p", "print", "printf", "private", "private_methods", 
"proc", "protected_methods", "public", "public_methods", "putc", 
"puts", "raise", "rand", "readline", "readlines", 
"remove_instance_variable", "require", "respond_to?", "scan", "select", 
"send", "set_trace_func", "singleton_method_added", 
"singleton_methods", "sleep", "split", "sprintf", "srand", "sub", 
"sub!", "syscall", "system", "taint", "tainted?", "test", "throw", 
"to_a", "to_s", "trace_var", "trap", "type", "untaint", "untrace_var"]
irb(main):008:0>

There are also a few global variables available (all of these have 
human-readable English names as well):

irb(main):009:0> global_variables.sort
=> ["$!", "$\"", "$$", "$&", "$'", "$*", "$+", "$,", "$-0", "$-F", 
"$-I", "$-K", "$-a", "$-d", "$-i", "$-l", "$-p", "$-v", "$-w", "$.", 
"$/", "$0", "$:", "$;", "$<", "$=", "$>", "$?", "$@", "$DEBUG", 
"$FILENAME", "$KCODE", "$LOAD_PATH", "$SAFE", "$VERBOSE", "$\\", "$_", 
"$`", "$binding", "$defout", "$stderr", "$stdin", "$stdout", "$~"]
irb(main):010:0>

Jim
--
Jim Menard, jimm at io.com, http://www.io.com/~jimm/
"I have found that humans often use Smalltalk during awkward moments."
     -- Commander Data, ST TNG



More information about the Squeak-dev mailing list