From: Yamal Soueidan Date: 2007-03-28T22:23:48+09:00 Subject: Re: general question (different between methods and functions)? ------=_Part_31231_30404550.1175088224573 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Well, in Ruby everything is a object, so we don't have any functions? In VB you can have functions inside modules, so you can call them by their name.. PHP have many functions available on their site, which you use in your projects www.php.net without using any class C# doesn't have any functions, because you cannot call any functions direct, but you can only make methods static and call them, but you still need to to use class.method. The answer does depend on the language in question! In general it must be like you described. Functions: A function in the strictest sense is a bit of code that is defined and named and can be called and run by that name. Methods: The main difference is that a method is "part" of an object. This must be the best definition. :D On 3/28/07, John Joyce wrote: > > The answer does depend on the language in question! > The difference is small and (arguably) unimportant in Ruby. In C++ or > Objective-C the difference and distinction is more clear and more > important. > > Some people would argue the semantic difference between a function > and a method, but in most cases, in most languages they're pretty > much the same. > The main difference is that a method is "part" of an object. It must > understand (respond to) or "have" the method in its definition. (or > inherit the method from an ancestor class) > > A function in the strictest sense is a bit of code that is defined > and named and can be called and run by that name. It may take > arguments (parameters) and / or return a value of some sort. > > In Ruby almost everything is an object... > > Objective-C, has a similar concept of methods and messages to Ruby, > but also has C as it's strict subset, it is a good place to find out > about the differences and similarities. > On Mar 28, 2007, at 9:34 PM, Yamal Khaled Soueidan wrote: > > > Thats what I meant, functions is used without the object, and are > > called > > direct, whereas the methods is used with the object. > > > > puts "this is a function" > > > > File.puts "this is object.method" > > > > Is this how everyone see it or do many people have different > > opinion on this > > subject? > > > > On 3/28/07, James Edward Gray II wrote: > >> > >> On Mar 28, 2007, at 3:42 AM, SonOfLilit wrote: > >> > >> > Methods are associated with a receiver object. > >> > > >> > Functions are not. > >> > > >> > The only things you can call functions in Ruby are lambdas, blocks, > >> > ... Even then it's not clear whether they are methods or functions. > >> > > >> > Everything else is methods. > >> > >> The above is all true, but we do sometimes refer to calling methods > >> in a "function-style" in Ruby. That's when you call a method without > >> an explicit receiver. For example: > >> > >> puts "Hello world!" # function-style > >> file.puts "Hello world!" # normal method call > >> > >> Everything is still a method, this is just a name we use for the call > >> style. > >> > >> I only bring it up because it is sometimes referred to in the > >> documentation for things like private scope and module_function. > >> > >> James Edward Gray II > >> > >> > >> > > > ------=_Part_31231_30404550.1175088224573--