How do hackers drive?
Rahul Siddharthan
rsidd at online.fr
Sat Nov 1 15:04:37 PST 2003
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
More information about the freebsd-chat
mailing list