What is the benefit of having an ever-defined framework?
Example in SQLite source code:
/ * structure is never defined sqlite3_stmt * / typedef struct sqlite3_stmt sqlite3_stmt; And the object is manipulated in such a way:
typedef struct Vdbe Vdbe; Struct Vdbe {/ * many members *}; Int sqlite3_step (sqlite3_stmt * pStmt) {Vdbe * v = (Vdbe *) pStmt; Do not use just a general abstract type, in actual fact, foo.c Define the actual structure of the source and a public typedef in foo.h header?
To clarify: What you are asking, why does it do the above instead:
Header file:
typedef struct sqlite3_stmt sqlite3_stmt; C file:
struct sqlite3_stmt {/ * lots of members * /}; Works with PTMT (sqlite3_stmt * pStmt) {/ * DOTS PSTMT ... * /} (This is an authentic form of the "opaque indicator" pattern associated with the reply of CanateM)
The only good reason why I can think is why SQLite does this:
Backend code, I'm guessing, came before API and named Use of Vdbe - The meaning of the name may be implemented on the lines of "Virtual Database Entry" Something related to the vehicle means (wildly estimating here).
It's time to create an API, no one realized that the required parameter for sqlite3_step was a Vdbe but it was not exactly the name that the API Will express a lot to the user. Therefore, from a user's point of view, a Vdbe is referred to as sqlite3_stmt .
Here the difference between the point, then, the two is to think about the idea of the same item: backend Vdbe s (in any case) because it is such a name Which makes sense in the context of the implementation , the API talks about the sqlite3_stmt s because it is a name in the context of the interface Makes sense.
EDIT: As Amarghosh tells, why not do this to achieve just one effect?
typedef struct Vdbe sqlite3_stmt; (Please vote it, I do not want to stop my representative from there): VDBE is only one of many potential backend; The interface uses "generic" sqlite3_stmt , and then it uses whatever backend is used to apply it.
Comments
Post a Comment