may the source_be_with_you

68
May the Source Be with You Chimpr Learning Ruby by Reading Ruby Source Code 12128日星期六

Upload: eddie-kao

Post on 06-May-2015

227 views

Category:

Documents


0 download

TRANSCRIPT

  • 1.May the Source Be with YouLearning Ruby by Reading Ruby Source CodeChimpr12128

2. 12128 3. Im a Flash guy 8 years12128 4. also a Ruby guy 4 years12128 5. but not a C guy, yet!12128 6. Ruby > Rails12128 7. share Ruby learning experiences inOpenFoundry and some developer party.12128 8. a SHOW-OFF person!12128 9. Learning Ruby by Reading Ruby Source Code12128 10. - why read source code?- how o sart?- anything ineresting?- wrie a simple Ruby Exension with C.12128 11. Why read source code?12128 12. see how the Ruby Core Team wrie Ruby12128 13. fun :)12128 14. "once you sart digging around in someone elses code base, youll learn a lot about your own strengths and weaknesses" - Ruby Best Practicehttp://blog.rubybestpractices.com/posts/gregory/005-code-reading-stdlib.html12128 15. pre-requirement?12128 16. C language12128 17. curiosity and enthusiasm12128 18. What if I dont have any skill of C?12128 19. Just learn it :)12128 20. How o Sart?12128 21. get Ruby source codedownload from Ruby websie:http://www.ruby-lang.org/en/or from github:https://github.com/ruby/ruby12128 22. Ruby Source Code:- *.c + *.h- *.rb (Sdlib)12128 23. Tools- Vim12128 24. Ruby 1.9.2 p29012128 25. Quick Browsing.. :)12128 26. whats a Ruby object?12128 27. sart from basic structure, like Object,Class, String, Array, Hash, Basic...12128 28. Object = RObject,Class = RClass,String = RString,Array = RArray,Hash = RHash,Basic = RBasic12128 29. ruby.h12128 30. object.c12128 31. Init_XXXX12128 32. class.c#350-354all Classs class is Class!12128 33. class.c#556rb_define_module()12128 34. class.c#1170rb_define_method()12128 35. Object.c#2556~2560 Integer(), Float(), String(), Array() are all global methods12128 36. class.c#1332 rb_define_global_function()= rb_define_module_method on kernel= rb_define_private_method on kernel +rb_define_singleton_method on kernel12128 37. new12128 38. class Adef initializeputs "hello"endenda = A.new12128 39. object.c#2624new ->rb_class_new_instance ->rb_obj_alloc -> rb_obj_call_init12128 40. o_s v.s o_str12128 41. String.c#7488rb_define_method(rb_cString, "to_s", rb_str_to_s, 0);rb_define_method(rb_cString, "to_str", rb_str_to_s, 0);12128 42. Array.c#4504rb_define_alias(rb_cArray, "to_s", "inspect");but no `to_str`12128 43. proc.c#2105how to execute a Proc?- proc.call- proc[]- proc === 123- proc.yield12128 44. object.c#2592- attr- attr_reader- attr_writer- attr_accessor12128 45. push v.s ["yellow", "[email protected]"]}people.map { |name, (_, email)|puts [name, email]}parse.y#8277-8299 shadowing_lvar_gen()12128 52. vm_eval.c#224method_missing12128 53. ineresting naming :)12128 54. ext/ripper/ripper.c#15890rb_intern, rb_intern2, rb_intern312128 55. array.c#325rb_ary_new, rb_ary_new2, ary_new,rb_ary_new3, rb_ary_new412128 56. Simple Ruby Exension from Scrach12128 57. Conclusion12128 58. from basic structure12128 59. and dont be afraid12128 60. References12128 61. Ruby by http://i.loveruby.net/ja/rhg/book/12128 62. Ruby Under a Microscope by Pat Shaughnessyhttp://patshaughnessy.net/ruby-under-a-microscope12128 63. still not nish..12128 64. Ian Ruotsala12128 65. Hope can become aChimprJedi Master someday :)12128 66. thank you all :)12128 67. any question?12128 68. Conacts WebsieBlog http://www.eddie.com.tw http://blog.eddie.com.twPlurkhttp://www.plurk.com/aquarianboyFacebook http://www.facebook.com/eddiekaoGoogle Plus http://www.eddie.com.tw/+Twiterhttps://twiter.com/#!/[email protected] +886-928-617-687photo by Eddie12128