User: Password:
Subscribe / Log in / New account

methods and functions

methods and functions

Posted Aug 20, 2004 23:08 UTC (Fri) by giraffedata (subscriber, #1954)
In reply to: The end of the fcntl() method by iabervon
Parent article: The end of the fcntl() method

Every time I've heard someone talk about a method, he was talking about the function, not the pointer to it. It's like, "when the dir_notify method executes..." Pointers don't execute. The functions to which they point do.

It's true that "dir_notify" isn't usually the name of the function, but it's clearly a description of one, like "the garbage collector function."

(Log in to post comments)

methods and functions

Posted Aug 21, 2004 0:04 UTC (Sat) by iabervon (subscriber, #722) [Link]

But "dir_notify" isn't an English description like "the garbage collector function"; it's a description in terms of the structure member that it is suitable for. "The dir_notify method" means "the function that the dir_notify field points to", which is what "method" usually means in programming language terms (although the details of how you find the method are often hidden a bit). "The dir_notify function" would be something entirely different, and "the dir_notify pointer" would be something else again. Clearly, then, the term "method" is a useful description of the actual situation. It would be just as wrong to talk about the "dir_notify function" as it would be to talk about the "vfs_create method".

Actually, in C, you can execute a function pointer; file->f_op->flush(file) is a perfectly good equivalent for (*file->f_op->flush)(file).

methods and functions

Posted Aug 21, 2004 2:14 UTC (Sat) by giraffedata (subscriber, #1954) [Link]

I think "dir_notify" is as good a word as any English dictionary word, notwithstanding its weird spelling. It's as descriptive as "int" and "errno," two other words found in English conversations about kernel programming. It's as legitimate as "directory change notification." So I can't see any problem with describing a certain function as a "dir_notify" function.

In the paradigm in which you make an OOP language out of C, you represent an object with a struct and a method with a function, and put a function pointer in the struct to declare the binding. It's the fact that the function is used like an OOP method that makes it a method, not the fact that it's called through a C function pointer. I wouldn't talk about the "vfs_create method" because there isn't a type of function called in the OOP paradigm that fits that description.

I/O request descriptors usually have a function pointer to an "endio" function in them. The endio function is not a method (neither is the pointer to it). This is a much more primitive technology than OOP.

I would accept that the "method" is actually the combination of both the function and the pointer to it in the "object" struct. But I can't accept that the pointer itself is the method.

Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds