On 12/13/10 06:55, Dennis Wassel wrote:
> Hi Bruce, hi list,
> 
> FYI a small gotcha I stumbled over today:
> 
> Suppose I have a template file that produces both foo.c and foo.h, and says
> 
>   #include "[+ (. header-file) +]"
> 
> somewhere. This will nicely expand to
>   #include "foo.h"
> in the usual cases. If I issue --select-suffix=c though, because I do
> not want to regenerate foo.h right now, it expands to
>   #include "/dev/null"
> which is pretty irritating (and betrays the option's implementation :)

Don't do that.  ;-)  I confess, when writing the option templates
I only really considered --select-suffix=h.  But you are correct.
It is a template bug to have the "c" suffix code presume that the
"h" suffix code has run and left behind a scheme variable for it
to use.

> A workaround is to use
> 
>   #include "[+ (string-substitute (out-name) ".c" ".h") +]"

#include "[= (base-name) =].h"

since the option templates append the suffixes to the base name.
Each template needs to solve the problem for itself.

> instead.
> I am not saying this is a bug that needs fixing, but IMO it does
> somewhat violate the "least-surprise" principle.

Only ever use --select-suffix=h like I expected you to.  :-D

Regards, Bruce

P.S. I held my email while looking through the use of the "header-file"
scheme variable.  I've concluded that it is a difficult implementation
problem to say that these options are viable for all templates.
Templates are, by their nature, highly state-ful.  The template author
is, therefore, required to say whether or not a particular suffix
is optional or required.  In the case of a template that emits
  #include "/dev/null"
into a .c file in the absence of emitting the .h file, then emitting
the .h is required for emitting the .c.  As noted, though, fixing
this one is quite simple.  That is *not* the case with the options
template.  I construct a number of hash tables during the header
generation that are required to be there for the code generation.
So, I consider this an RFE for annotating the pseudo macro with
something that says, "this suffix is optional" and suffixes are required
by default.  Someday.  Not today. :)

Syntax suggestion: append a '?' character to the end of the suffix.
The character gets stripped and the suffix gets marked as "optional".

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Autogen-users mailing list
Autogen-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/autogen-users

Reply via email to