Subject: Re: Clarification to section 3.5 - user-defined types.
From: Paul Graham (pgraham@cadence.com)
Date: Thu Apr 11 2002 - 10:38:12 PDT
> > generate if (exp)
> > typedef int T;
> > else
> > typedef shortint T;
> > endgenerate
> > T i; // data type depends on exp
> >
> > Regards,
> >
> > Peter.
>
> That doesn't look very legal to me - I would have expected the definition
> of T to expire at the endgenerate.
You're assuming that something declared in a generate statement lives in the
"scope" of the generate statement. But a generate statement does not create
a scope. Only named begin/end blocks (and modules and subprograms) create
scope. So if the example were coded:
generate if (exp)
begin: block1
typedef int T;
end
else
begin: block2
typedef shortint T;
end
endgenerate
then you would be correct in saying that the declaration T "expires" within
the generate statement.
I know what you're going to say -- this doesn't make modular compilation any
easier. Lookup of *local* symbols can't be done by the parser, since the
symbol table, even for symbols local to the module, is not complete until
generate statements have been elaborated.
Paul
This archive was generated by hypermail 2b28 : Thu Apr 11 2002 - 10:39:24 PDT