Hatena::ブログ(Diary)

urekatのスカンク日記3 このページをアンテナに追加 RSSフィード

2012-04-21

mruby

  • やっぱりいろいろ無い
  • Timeが無い、ppがない、とかいちいちつまずく
  • 文法だけ、なんだろうか
  • やっぱり、Rubyは(というよりプログラミング言語は)ライブラリも一心同体だなあ。
tkrmb2:~/proj% git clone git://github.com/mruby/mruby.git
tkrmb2:~/proj% cd mruby
tkrmb2:~/proj/mruby% make

tkrmb2:~/tmp% ruby -v                    
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10]

tkrmb2:~/tmp% ~/proj/mruby/bin/mruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
Usage: /Users/takeru/proj/mruby/bin/mruby [switches] programfile
  switches:
  -b           load and execute RiteBinary (mrb) file
  -c           check syntax only
  -v           print version number, then run in verbose mode
  --verbose    run in verbose mode
  --version    print the version
  --copyright  print the copyright

tkrmb2:~/tmp% cat a.rb 
p "hello mruby"

p Kernel.methods
p Module.constants

tkrmb2:~/tmp% ruby a.rb 
"hello mruby"
["inspect", "name", "private_class_method", "exit!", "chomp!", "tap", "print", "fail", "clone", "binding", "__send__", "object_id", "public_methods", "split", "Array", "method_defined?", "instance_variable_defined?", "readlines", "format", "chop", "iterator?", "catch", "equal?", "freeze", "trap", "extend", "getc", "send", "const_defined?", "methods", "ancestors", "module_eval", "instance_method", "hash", "putc", "caller", "dup", "autoload?", "proc", "instance_variables", "to_enum", "instance_methods", "public_method_defined?", "chomp", "block_given?", "throw", "class_variable_defined?", "p", "eql?", "sub!", "constants", "loop", "trace_var", "syscall", "id", "instance_eval", "singleton_methods", "exec", "module_exec", "Integer", "callcc", "const_missing", "puts", "exit", "load", "taint", "lambda", "srand", "instance_variable_get", "frozen?", "enum_for", "public_instance_methods", "private_method_defined?", "display", "instance_of?", "global_variables", "method", "to_a", "gsub!", "included_modules", "untrace_var", "open", "const_get", "`", "instance_exec", "type", "<", "protected_methods", "class_eval", "<=>", "Float", "method_missing", "system", "==", "gets", "sub", "abort", "require", "class_variables", ">", "===", "rand", "test", "instance_variable_set", "warn", "eval", "protected_instance_methods", "protected_method_defined?", "respond_to?", "kind_of?", "local_variables", ">=", "public_class_method", "chop!", "to_s", "<=", "scan", "raise", "const_set", "set_trace_func", "printf", "fork", "class", "private_methods", "=~", "tainted?", "__id__", "sleep", "class_exec", "select", "String", "autoload", "at_exit", "readline", "sprintf", "gsub", "untaint", "nil?", "private_instance_methods", "include?", "is_a?", "__method__"]
["ThreadError", "RUBY_PATCHLEVEL", "Regexp", "Numeric", "SystemStackError", "String", "Bignum", "IndexError", "SecurityError", "Exception", "NoMethodError", "FALSE", "Object", "PLATFORM", "Range", "IO", "Integer", "TypeError", "Dir", "RUBY_RELEASE_DATE", "ARGV", "ZeroDivisionError", "Signal", "SystemExit", "NotImplementedError", "Hash", "RegexpError", "Kernel", "VERSION", "TRUE", "STDOUT", "Math", "Interrupt", "SyntaxError", "Enumerable", "Struct", "Class", "Continuation", "IOError", "RangeError", "Data", "Thread", "RUBY_DESCRIPTION", "Proc", "Process", "Array", "NoMemoryError", "Time", "FileTest", "MatchData", "Method", "NIL", "StopIteration", "Comparable", "ARGF", "TOPLEVEL_BINDING", "FloatDomainError", "Float", "ArgumentError", "RUBY_PLATFORM", "ThreadGroup", "Precision", "UnboundMethod", "RuntimeError", "Fixnum", "STDERR", "FalseClass", "RELEASE_DATE", "Errno", "StandardError", "RUBY_VERSION", "EOFError", "LoadError", "STDIN", "TrueClass", "NameError", "NilClass", "GC", "RUBY_COPYRIGHT", "SystemCallError", "SignalException", "MatchingData", "File", "LocalJumpError", "Binding", "ENV", "ScriptError", "Symbol", "Module", "ObjectSpace", "Marshal"]
tkrmb2:~/tmp% ~/proj/mruby/bin/mruby a.rb 
"hello mruby"
[:loop, :raise, :require, :lambda, :"'", :iterator?, :global_variables, :eval, :local_variables, :block_given?, :include, :to_s, :alias_method, :===, :undef_method, :new, :dup, :eql?, :equal?, :extend, :initialize_copy, :hash, :instance_eval, :inspect, :==, :to_s, :!=, :require, :__printstr__, :print, :singleton_class, :puts, :clone, :p, :===, :pow, :class, :__send__, :sqrt, :putc, :__id__, :remove_instance_variable, :respond_to?, :send, :singleton_methods, :"'", :sprintf, :private_methods, :format, :object_id, :public_methods, :nil?, :protected_methods, :loop, :kind_of?, :raise, :methods, :instance_variables, :lambda, :is_a?, :local_variables, :iterator?, :instance_variable_set, :global_variables, :instance_variable_get, :instance_variable_defined?, :eval, :instance_of?, :block_given?, :!, :method_missing, :initialize]
#<NoMethodError: no method named constants>



tkrmb2:~/tmp% ~/proj/mruby/bin/mrbc a.rb 


tkrmb2:~/tmp% cat a.mrb 
RITE0009000000090000MATZ    000900000000010000010000        41FD00000100SC0002000400046F2800000011010000060180003D02000005010000A00100000601800091020000050180802002000005010000A00100000601800191020000050181002002000005010000A00000004AA547000000010F000Bhello mrubyBC73000000050001p0006Kernel0007methods0006Module0009constantsFAC700000000tkrmb2:~/tmp%


tkrmb2:~/tmp% ~/proj/mruby/bin/mruby a.mrb 
Invalid octal digit
syntax error, unexpected tINTEGER, expecting $end


tkrmb2:~/tmp% ~/proj/mruby/bin/mruby -b a.mrb
"hello mruby"
[:loop, :raise, :require, :lambda, :"'", :iterator?, :global_variables, :eval, :local_variables, :block_given?, :include, :to_s, :alias_method, :===, :undef_method, :new, :dup, :eql?, :equal?, :extend, :initialize_copy, :hash, :instance_eval, :inspect, :==, :to_s, :!=, :require, :__printstr__, :print, :singleton_class, :puts, :clone, :p, :===, :pow, :class, :__send__, :sqrt, :putc, :__id__, :remove_instance_variable, :respond_to?, :send, :singleton_methods, :"'", :sprintf, :private_methods, :format, :object_id, :public_methods, :nil?, :protected_methods, :loop, :kind_of?, :raise, :methods, :instance_variables, :lambda, :is_a?, :local_variables, :iterator?, :instance_variable_set, :global_variables, :instance_variable_get, :instance_variable_defined?, :eval, :instance_of?, :block_given

スパム対策のためのダミーです。もし見えても何も入力しないでください
ゲスト

コメントを書くには、なぞなぞ認証に回答する必要があります。

トラックバック - http://d.hatena.ne.jp/urekat/20120421/1335032173