On Thu, Mar 02, 2000 at 10:20:39PM +0200, Dekel Tsur wrote:
> Consider the code of LyXTextClass::readOutputType:
> 
> | void LyXTextClass::readOutputType(LyXLex & lexrc)
> | {
> |         keyword_item outputTypeTags[] = {
> |                 { "docbook", DOCBOOK },
> |                 { "latex", LATEX },
> |                 { "linuxdoc", LINUXDOC },
> |                 { "literate", LITERATE }
> | };
> 
> Why isn't outputTypeTags declared static?
> 
> |         pushpophelper pph(lexrc, outputTypeTags, LITERATE);
> 
> It is not a good idea to use the tag LITERATE because someone might change
> enum OutputType by adding a new tag after LITERATE, but he may forget to 
> change the line above.
> 
> A better idea is to use sizeof(outputTypeTags)/sizeof(keyword_item),

No, that's a bad idea.  It's ugly, and it's not (AFAIK) a formal requirement
of the C++ spec that sizeof(array) = num_elts * sizeof(elt).  For example,
and implementation can store bookkeeping information at the end if it wants
to. Also it may pad for efficient access.

> (another option is to add a line "OutputType_LAST = LITERATE" to
> enum OutputType, and then use OutputType_LAST instead of LITERATE)

That's better, IMO.

Jules

-- 
Jules Bean                          |        Any sufficiently advanced 
jules@{debian.org,jellybean.co.uk}  |  technology is indistinguishable
[EMAIL PROTECTED]              |               from a perl script

Reply via email to