On 26.05.2017 19:04, Andrew Schorr wrote:
> On Friday, May 26, 2017 at 11:42:34 AM UTC-4, Janis Papanagnou wrote:
[...]
>> In the given case where you can't control it from inside of awk I'd
>> rather would externalize the task, i.e. do the discrimination where
>> I am forced to do that anyway; on the command line (or environment)
>> where I will have to specify "-M" or not.[*]
>
> I don't follow this comment. Are you suggesting a change from current
> behavior?
No, no. What I meant is that given what we have _I_ (probably not the
OP who may have requirements I don't yet recognize) would put the test
(if necessary) statically in the environment; the calling environment
will require adding -M (if you need it) or keep the default anyway, if
all I want to do is to abort any lacking precision functionality, so I
don't seem to need the test inside awk. (Having the test inside an awk
module might be necessary if you have independent library modules that
can be called from other awk programs that might or might not be called
with -M; for me the procedure to test precision in library modules looks
a bit strange, so I'm not really sure why that would be necessary, but I
cannot deny if someone has good uses for it. But GNU awk's handling is,
IMO, anyway not perfect in this case as [partly] discussed previously.)
>
>> [*] Note that this not related any more to the original request of
>> this thread to test "-M" (for which there seems to be a solution
>> already, and one that is probably available with the next release).
>
> But as you point out, why is this type of behavioral test advisable?
Behavioural tests are necessary if one is confronted with unknown systems.
Usually you test a specific instance, depending on the type of the system,
at a specific time, evolution stage, or version.
If the system will behave differently when there's larger numbers involved
it's necessary to make tests before you use it. (GNU awk, though, has its
[current] behaviour specified in the manual, AFAIR.) Undesired behaviour
is for example if there's at some point silently an computational overflow
that you don't get reported and produce (probably hazardous) results thereby.
Or to check out where's the limit actually is so that you have to bite the
performance-degradation bullet and use MPFR, but with the next release, or
with the next CPU/ALU generation the limits may have changed again, so that
using less performant MPFR would not be necessary to use any more.
Declaring what you need and letting awk decide whether to use native or MPFR
functions would solve that. But then the performance-degradation might also
be a requirement. If awk would decide the library to use you couldn't tell
as well what's used and whether your performance will drop or not. (Arguably,
this can and probably should be done as part of the system regression tests
so I'm not completely convinced.) Slower computation - specifically in the
contexts where awk is used - is usually a lesser issue than silent overflows
or similar.
As explained, I cannot tell for sure in this case - this is a question the
OP might answer (or has he already elaborated on it?).
> If one wants to test behavior, I still think it is wiser to test actual
> calculation precision rather than whether a given flag was supplied
> on the command line.
(Both are not what I would want or need.)
Janis