Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Nov 2003 18:04:38 -0500
From:      Rahul Siddharthan <rsidd@online.fr>
To:        Greg Pavelcak <g.pavelcak@comcast.net>
Cc:        freebsd-chat@freebsd.org
Subject:   Re: How do hackers drive?
Message-ID:  <20031101230438.GA2023@online.fr>
In-Reply-To: <20031101205412.GA15226@bishop.my.domain>

next in thread | previous in thread | raw e-mail | index | archive | help
Greg Pavelcak wrote:
> I'm a non-programmer. Is it the OO languages that talk about
> "methods" when it looks like they're talking about something like
> functions, or is that something else?

I'm largely a non-programmer too, but yes.

> Choosing an appropriate technical term can be that difficult, but
> it's downright silly to choose a weird term for something that
> already has a perfectly good name.

But you want to distinguish between "functions" that accept parameters,
and "methods" that operate on the objects they're a part of.

In python for example, a lot of string operations are implemented both
as functions (part of the "string" module, retained largely for
backward-compatibility reasons) and as methods of the string object
itself.  Thus,
    string.split("Hello world")
is a function call that accepts "Hello world" as a parameter, while
    "Hello world".split()
is a method call; the method is part of the "string" object.  Of course, 
methods can accept parameters too, as in
    "Hello world".split('o')
which will yield
    ['Hell', ' w', 'rld']

Ultimately I don't believe there is a difference in functionality but
the object-oriented approach sometimes feels cleaner, though it took me
a long time to see it.  Eg, if you want to make sure a function only
operates on the data it really should and not overwrite other data
accidentally, OO can safeguard you better.  C has pretty much no checks,
you can overwrite any part of the memory owned by you and never realise
it.

Perhaps some real programmer wants to correct/expand the above...

Rahul



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031101230438.GA2023>