Subject: Re: [sv-cc] DirectC C Layer - revised - pure functions
From: Andrzej Litwiniuk (Andrzej.Litwiniuk@synopsys.com)
Date: Tue Feb 04 2003 - 16:46:57 PST
> > 3.6 'Pure' functions
> >
> > The functions specified as 'pure' in their corresponding SV external
> > declarations must have no side effects whatsoever directly or indirectly.
KEVIN:
> Should be:
>
> The functions specified as 'pure' in their corresponding SV external
> declarations will be assumed to have no side effects. Their result
> is assumed to depend solely on the values of their input arguments.
> Calls to such functions may be removed by SV compiler optimizations.
>
> I may want to use a "debug" version of such a routine that might write to
> files etc. - I wouldn't want it optimized differently.
Thanks! This looks good.
I would keep, however, specific examples of undesired side effects. Just be
more verbose. What about the following phrasing:
------------
3.6 'Pure' functions
Only non-void functions with no output or inout arguments may be specified as 'pure'.
The functions specified as 'pure' in their corresponding SV external
declarations will be assumed to have no side effects. Their result
is assumed to depend solely on the values of their input arguments.
Calls to such functions may be removed by SV compiler optimizations
or replaced with the values previously computed for the same values of input
arguments.
Specifically, 'pure' function is assumed not to do directly or indirectly
(i.e. by calling other function):
- perform any file operations
- read or write anything
- access any persistent data like global or static variables.
If a 'pure' function does not obey the above restrictions, then SV compiler
optimizations may cause the behaviour different than expected, due to eliminated
calls or wrong results used.
------------
Andrzej
This archive was generated by hypermail 2b28 : Tue Feb 04 2003 - 16:47:26 PST