From ruby-talk-admin@ruby-lang.org Fri Dec 16 01:19:03 2005 Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (8.12.3/8.12.3/Debian-6.6) with ESMTP id jBFGJ3Zk027426; Fri, 16 Dec 2005 01:19:03 +0900 Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 4E83F5CB9; Fri, 16 Dec 2005 01:19:04 +0900 (JST) Received: from localhost (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 41EAEF0486E; Fri, 16 Dec 2005 01:19:08 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 0A6C7F0486B; Fri, 16 Dec 2005 01:19:07 +0900 (JST) Received: from beryllium.ruby-lang.org (beryllium.ruby-lang.org [210.163.138.100]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id C440E63002B; Fri, 16 Dec 2005 01:19:09 +0900 (JST) Received: from beryllium.ruby-lang.org (beryllium.ruby-lang.org [127.0.0.1]) by beryllium.ruby-lang.org (Postfix) with ESMTP id D744233F3C; Fri, 16 Dec 2005 01:19:04 +0900 (JST) Received: from localhost (beryllium.ruby-lang.org [127.0.0.1]) by beryllium.ruby-lang.org (Postfix) with ESMTP id 042F133F41 for ; Fri, 16 Dec 2005 01:18:56 +0900 (JST) Received: from beryllium.ruby-lang.org ([127.0.0.1]) by localhost (beryllium.ruby-lang.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 31814-05 for ; Fri, 16 Dec 2005 01:18:55 +0900 (JST) Received: from wobblini.net (wobblini.net [69.55.234.105]) by beryllium.ruby-lang.org (Postfix) with ESMTP id 7D42833F40 for ; Fri, 16 Dec 2005 01:18:55 +0900 (JST) Received: from wobblini.net (wobblini.net [127.0.0.1]) by wobblini.net (8.12.11/8.12.11) with ESMTP id jBFGIlUN003917 for ; Thu, 15 Dec 2005 08:18:47 -0800 Received: from localhost (dblack@localhost) by wobblini.net (8.12.11/8.12.11/Submit) with ESMTP id jBFGIlq5003914 for ; Thu, 15 Dec 2005 08:18:47 -0800 Delivered-To: ruby-talk@ruby-lang.org Date: Fri, 16 Dec 2005 01:18:56 +0900 Posted: Thu, 15 Dec 2005 08:18:47 -0800 (PST) From: dblack@wobblini.net Reply-To: ruby-talk@ruby-lang.org Subject: Re: Easy Duck-Typing To: ruby-talk@ruby-lang.org (ruby-talk ML) Message-Id: In-Reply-To: <43a1914f$0$144$edfadb0f@dread11.news.tele.dk> References: <43a1914f$0$144$edfadb0f@dread11.news.tele.dk> X-ML-Name: ruby-talk X-Mail-Count: 58 X-MLServer: fml [fml 4.0.3 release (20011202/4.0.3)]; post only (only members can post) X-ML-Info: If you have a question, send e-mail with the body "help" (without quotes) to the address ruby-talk-ctl@ruby-lang.org; help= X-Original-To: ruby-talk@ruby-lang.org X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ruby-lang.org X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on beryllium.ruby-lang.org X-Spam-Level: X-Spam-Status: No, score=-5.9 required=7.0 tests=AWL,BAYES_00, CONTENT_TYPE_PRESENT,NO_REAL_NAME,RCVDFRMLOCALIP autolearn=no version=3.0.3 Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Precedence: bulk Lines: 24 List-Id: ruby-talk.ruby-lang.org List-Software: fml [fml 4.0.3 release (20011202/4.0.3)] List-Post: List-Owner: List-Help: List-Unsubscribe: X-Virus-Scanned: by AMaViS snapshot-20020531 Hi -- On Fri, 16 Dec 2005, Daniel Schierbeck wrote: > This will make it easier to add type checking to your methods. Let me know if > you think the method belongs in Object or another class, rather than in the > Kernel module. This may be useful to you, but it isn't duck typing. In fact, it appears to be more or less the opposite, in concept. Here, you're checking class ancestry and gatekeeping your method calls and return values based on that ancestry. The thrust of duck typing, as I understand it, is that you just ask an object to do something -- without regard to its class, and quite likely without doing a respond_to? call first. David -- David A. Black dblack@wobblini.net "Ruby for Rails", forthcoming from Manning Publications, April 2006!