Re: [AD] 4.3 graphic drivers |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Friday 11 November 2005 10:31, Peter Hull wrote:
> I would vote for static vtables; I think the benefits of the string-based
systems are small, given that the vtable wouldn't change much. How about a
versioned structure, ie. with a version number as the first element?
>
> typedef struct VTABLE {
> int version;
> void (*some_func)(void);
> ...
> };
That will still somehow break typechecking if entries are added and it will
break completely in the case of addons trying to support older versions of
Allegro while taking advantage of new features.
The immediate Allegro problem we want to solve is this: say I'm working on
the graphics system in Linux. I add an entry to the vtable. At this point,
I don't want to have to look up every source file on every platform that
has graphics vtables and add a NULL entry.
Granted, your system offers a way around this but I'm not sure it will work
well in practice.
I agree that static structs are the most `pretty' way of doing this but in
terms of code maintenance and flexibility I think they leave much to be
desired. That said, there's no principle reason you can't create a static
vtable rather than filling it up dynamically. Think of it as a way to do
both.
I like Elias' version of Bob's suggestion, but I can see the disadvantage
and complexities of juggling around version numbers and not having type
checking. Perhaps Peter's suggestion of accessing the members directly is
easiest.
As for strings versus ID's... I don't have a strong preference either way
apart from a feeling that strings are somehow overkill. Other people seem
to prefer strings too (Thomas Harte comes to mind) so there's obviously no
pleasing everyone.
Evert