[m-dev.] Re: type_info bug fix
Tyson Richard DOWD
trd at students.cs.mu.oz.au
Fri Feb 28 15:00:33 AEDT 1997
>
> I think the code would be clearer if you implement the above macros
> by actually defining a C struct for the types, and just casting the
> argument to a pointer to this struct.
Yep.
> It is a little bit tricky in the case of structs with two variable
> sized bits, i.e. type_layout, but I think it would help even for
> those cases.
Nope, type_layouts are as large as the number of tags we use (fixed
size), the things type_layouts point to only ever have one variable sized
part. And we can move that to the end. In fact, I think I will, so
your approach will work quite nicely, and if we ever need two variable
size parts... we know it can be done.
> It might perhaps be better to require a cast to MR_TypeLayout in the caller
> rather than casting the argument to MR_TypeLayout_part1 in the macros --
> I'm not sure whether it is better to have the cast in the macros or in
> the caller.
There are arguments for both - you can get some typechecking if you do
it in the caller, since you can cast the results... Hmmm... with some
use of unions, it would probably work out nicely.
--
Tyson Dowd # "Most people's C code should be indented
# six feet downward and covered with
trd at cs.mu.oz.au # dirt."
http://www.cs.mu.oz.au/~trd # - Blair Houghton, on C code indentation
More information about the developers
mailing list