Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. "A rose by any other name would smell as sweet" - so what is the BEST name for "open_dev" function return?

"A rose by any other name would smell as sweet" - so what is the BEST name for "open_dev" function return?

Scheduled Pinned Locked Moved C / C++ / MFC
questionjson
9 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #1

    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

    L L J 3 Replies Last reply
    0
    • V Vaclav_

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      It is definitely personal preference.

      1 Reply Last reply
      0
      • V Vaclav_

        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

        L Offline
        L Offline
        leon de boer
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • V Vaclav_

          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

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          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.

          D P 2 Replies Last reply
          0
          • J jschell

            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.

            D Offline
            D Offline
            Daniel Pfeffer
            wrote on last edited by
            #5

            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.

            P 1 Reply Last reply
            0
            • D Daniel Pfeffer

              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.

              P Offline
              P Offline
              Peter_in_2780
              wrote on last edited by
              #6

              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.") Peter

              Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

              D 1 Reply Last reply
              0
              • J jschell

                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.

                P Offline
                P Offline
                Peter_in_2780
                wrote on last edited by
                #7

                jschell wrote:

                "file handles" in Fortran/Pascal

                Maybe in Pascal. (Early) Fortran used Unit numbers Cheers, Peter

                Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

                1 Reply Last reply
                0
                • P Peter_in_2780

                  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.") Peter

                  Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

                  D Offline
                  D Offline
                  Daniel Pfeffer
                  wrote on last edited by
                  #8

                  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.

                  J 1 Reply Last reply
                  0
                  • D Daniel Pfeffer

                    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.

                    J Offline
                    J Offline
                    jschell
                    wrote on last edited by
                    #9

                    Daniel Pfeffer wrote:

                    I thought that Unix called them descriptors

                    I think that is the formal way it is used. But I found the other usage elsewhere.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups