Michael Widenius wrote:
> Hi!
>
>>>>>> "Mats" == Mats Kindahl <mats@stripped> writes:
>
> <cut>
>
>>>> Actually, I think that is a productive use of engineer time. I tried
>>>> to work out
>>>> the dependencies of lex.h (to make it self-sufficient), and this is
>>>> what I got:
>>>>
>>>> class Table_ident; /* Need to be before include of sql_yacc.h */
>>>> class Item_num;
>>>> class String;
>>>> class Key_part_spec;
>>>> struct TABLE_LIST;
>>>> typedef struct st_udf_func udf_func;
>>>> typedef struct st_lex_user LEX_USER;
>>>> #include "sql_list.h" /* Pull in List<> */
>>>> #include "set_var.h" /* Pull in sys_var_with_base */
>>>> #include "sql_yacc.h" /* Pull in symbol definitions */
>>>>
>>>> For each line, I had to do a symbol search to find the definition of
>>>> it and see
>>>> how and where it was defined. Most other files have similar
>>>> dependencies...
>>>>
>>>> /Matz
>>> wow!
>>> Each header file should have been self-contained of course, there should
>>> be no need for forward declarations before #include
>
> Mats> ... except in some special circumstances, of course.
>
> Mats> However, the problem is that we have the following different ways of
> introducing
> Mats> type definitions:
>
> Mats> typedef struct st_whatever { ... } WHATEVER;
> Mats> struct WHATEVER { ... };
> Mats> class WHATEVER { ... };
>
> <cut>
>
> Mats> However, this means that in order to be able to use forward declarations
> without
> Mats> having to look them up every time, we should standardize on "class Whatever"
> and
> Mats> change all existing code so that it matches.
>
> I think that it's better to never use forward declarations at all and
> instead always, if possible, us the file where the declarations is
> made. This eliminates typo errors and late linker errors that can be
> very confusion.
>
> For example, forward declarations can causes a lot of problems if one
> does a name changes or uses macros.
<tongue in cheek>
I don't find linker errors very confusing at all unless, of course, one uses
macros or typedefs to introduce aliases for class names (or other names, like
functions or variables). :)
Best wishes,
Mats Kindahl
--
Mats Kindahl
Senior Software Engineer
Database Technology Group
Sun Microsystems