--------------enigA67865A63B20749F167CD947 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Yamal Khaled Soueidan wrote: > Hello everyone, > > I have been discussing the difference between methods and functions with a > friend, but we couldn't agree on what method and function is? > Potayto, potahto. Both are names for an abstraction over some bit of code that has Stuff Going In and Stuff Going Out. For methods, commonly, what bit of code gets executed depends on one of the things going in - some form of polymorphic dispatch depending on an argument (this, in Ruby, being the implicit self), and most commonly, on the type of this argument. Of course, in Ruby, the type of self is -really- a Class object holding a hash of methods. So the polymorphic dispatch depends on what's actually some special value in the type system. Doing away with the "special" role of self.class, we might as well say that if you put lambdas (which seem function -ish enough) in a hash and then call one depending on some value (a key in this hash), you're making a method call (HI MR. GRAHAM!). Going ad absurdum, if we accept that a "method" is anytime when semantics of a message send / function call / etc. depends on the value of an argument (or more (yay CLOS, the inexhaustible source of obscure views on OO (and nested parens))), you could as well argue that OCaml pattern matching is a form of polymorphic dispatch, making OCaml functions methods. (Good luck trying to persuade those guys about that without getting weird looks and getting asked "And this is important why?") My $0.02 say that the distinction made more sense in C++, and keeping both lingos was implementation details leaking into language syntax leaking into programmer mindset, or in another language where a polymorphic dispatch was a more ostentatious affair (Smalltalkesque "we do it everywhere!"), and where noone bothered to think just how common and trivial what's happening under the hood (a table lookup of one sort of another) is. David Vallner End Rant --------------enigA67865A63B20749F167CD947 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFGCu8ay6MhrS8astoRAtKsAJ4n3uf6eJpUgHxcSeTqJYhZq8M30gCfe7D0 fB6tCHZm7Lt5nIU89jzN1Gk VD -----END PGP SIGNATURE----- --------------enigA67865A63B20749F167CD947--