"A rose by any other name would smell as sweet" - so what is the BEST name for "open_dev" function return?
-
Just experienced an interesting behavior of my code AFTER getting cute and using "socket" for name of the return from
hci_open_dev
. The particular return was really described as "socket" - connection between processor and bluetooth "adapter" - but was originally named "sock". After much search I realized that "hci" API names the return "device descriptor" and other known "opening device" function calls it "file descriptor". Then I discovered "file handle " ! Is "handle" an ancient "windows OS" term ? After this unpleasant experience I'll definitely NOT name anything "socket" , but I am curious what name would be really descriptive ( no pun intended ) for the return of generic "open_x" function ?
dev_descriptor = hci_open_dev(dev_id);
And if you feel it is a matter of personal preference, you do not need to state that. Maybe it is covered in today's "ANSI C standards" - if there is such a thing. Cheers
-
Just experienced an interesting behavior of my code AFTER getting cute and using "socket" for name of the return from
hci_open_dev
. The particular return was really described as "socket" - connection between processor and bluetooth "adapter" - but was originally named "sock". After much search I realized that "hci" API names the return "device descriptor" and other known "opening device" function calls it "file descriptor". Then I discovered "file handle " ! Is "handle" an ancient "windows OS" term ? After this unpleasant experience I'll definitely NOT name anything "socket" , but I am curious what name would be really descriptive ( no pun intended ) for the return of generic "open_x" function ?
dev_descriptor = hci_open_dev(dev_id);
And if you feel it is a matter of personal preference, you do not need to state that. Maybe it is covered in today's "ANSI C standards" - if there is such a thing. Cheers
-
Just experienced an interesting behavior of my code AFTER getting cute and using "socket" for name of the return from
hci_open_dev
. The particular return was really described as "socket" - connection between processor and bluetooth "adapter" - but was originally named "sock". After much search I realized that "hci" API names the return "device descriptor" and other known "opening device" function calls it "file descriptor". Then I discovered "file handle " ! Is "handle" an ancient "windows OS" term ? After this unpleasant experience I'll definitely NOT name anything "socket" , but I am curious what name would be really descriptive ( no pun intended ) for the return of generic "open_x" function ?
dev_descriptor = hci_open_dev(dev_id);
And if you feel it is a matter of personal preference, you do not need to state that. Maybe it is covered in today's "ANSI C standards" - if there is such a thing. Cheers
What windows calls a handle, linux calls a descriptor. They are very broad concepts which can basically be called a unique reference to something and/or anything. Internally they are usually opaque pointers to some structure that is hidden from the caller for the exact reason you just found out. They have no real meaning outside the API other than something to identify something inside the API. Generally I would call it a HANDLE on windows or a descriptor on linux. It really isn't a problem you should be able to recognize one of your own HANDLES/Descriptors because you have to allocate it from somewhere and then just typecast it to what it is. RULE 1: Don't expose anything on an API you don't need too.
In vino veritas
-
Just experienced an interesting behavior of my code AFTER getting cute and using "socket" for name of the return from
hci_open_dev
. The particular return was really described as "socket" - connection between processor and bluetooth "adapter" - but was originally named "sock". After much search I realized that "hci" API names the return "device descriptor" and other known "opening device" function calls it "file descriptor". Then I discovered "file handle " ! Is "handle" an ancient "windows OS" term ? After this unpleasant experience I'll definitely NOT name anything "socket" , but I am curious what name would be really descriptive ( no pun intended ) for the return of generic "open_x" function ?
dev_descriptor = hci_open_dev(dev_id);
And if you feel it is a matter of personal preference, you do not need to state that. Maybe it is covered in today's "ANSI C standards" - if there is such a thing. Cheers
Vaclav_ wrote:
Then I discovered "file handle " ! Is "handle" an ancient "windows OS" term ?
Pretty sure that it existed before windows. I believe I was using "file handles" in Fortran/Pascal just about the time Bill Gates was still figuring out that college just wasn't for him. But perhaps that is a generic term rather than a specific one.
-
Vaclav_ wrote:
Then I discovered "file handle " ! Is "handle" an ancient "windows OS" term ?
Pretty sure that it existed before windows. I believe I was using "file handles" in Fortran/Pascal just about the time Bill Gates was still figuring out that college just wasn't for him. But perhaps that is a generic term rather than a specific one.
File handles certainly existed in MS-DOS (2.0 and later, released March 1983), and the term probably wasn't new even then.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
-
File handles certainly existed in MS-DOS (2.0 and later, released March 1983), and the term probably wasn't new even then.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
Daniel Pfeffer wrote:
File handles certainly existed in ... 1983
and were a good decade old by then. Unix dates from the early 1970s, and the concept and terminology of
file handle
was well established. (With apologies to JSOP,"I'm old. I know things."
) PeterSoftware rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
Vaclav_ wrote:
Then I discovered "file handle " ! Is "handle" an ancient "windows OS" term ?
Pretty sure that it existed before windows. I believe I was using "file handles" in Fortran/Pascal just about the time Bill Gates was still figuring out that college just wasn't for him. But perhaps that is a generic term rather than a specific one.
jschell wrote:
"file handles" in Fortran/Pascal
Maybe in Pascal. (Early) Fortran used
Unit numbers
Cheers, PeterSoftware rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
Daniel Pfeffer wrote:
File handles certainly existed in ... 1983
and were a good decade old by then. Unix dates from the early 1970s, and the concept and terminology of
file handle
was well established. (With apologies to JSOP,"I'm old. I know things."
) PeterSoftware rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
OK. I thought that Unix called them descriptors. :-O
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
-
OK. I thought that Unix called them descriptors. :-O
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.