[Aldor-l] is sal_sfloat.as buggy?

Oleg Golubitsky oleg.golubitsky at gmail.com
Mon Sep 24 12:43:49 EDT 2007


I am not getting any warnings for
       (a:%) ^ (b:%):% == {
               import { powf: (%, %) -> % } from Foreign C;
               powf(a, b);
       }
or
         (a:%) ^ (b:%):% == {
               import { powf: (Rep, Rep) -> Rep } from Foreign C;
               per powf(rep a, rep b);
       }
Imho, they are both correct, though have a potential for an
error: if we decide to change the representation, e.g. box the
SFlo, the Aldor compiler won't notice the type mismatch
in the import.
To prevent this potential problem, one could write
         (a:%) ^ (b:%):% == {
               import { powf: (SFlo, SFlo) -> SFlo } from Foreign C;
               coerce powf(coerce a, coerce b);
       }


This one
       (a:%) ^ (b:%):% == {
               import { powf: (%, %) -> % } from Foreign C;
               per powf(rep a, rep b);
       }
however does produce a type mismatch error:
"/data/oleg/aldor_tree/aldor/install/aldor/linux/1.1.0/include/aldor.as",
line 22:
        rep x == ((x)@%) pretend Rep;
.........................^
[L22 C26] #2 (Error) (After Macro Expansion) Argument 1 of `powf' did not
match any possible parameter type.
    The rejected type is Rep.
    Expected type %.
Expanded expression was: a @ % pretend Rep

Oleg


2007/9/24, Stephen Watt <watt at scl.csd.uwo.ca>:
>
> David, what warnings are you getting?
>
> All three versions should give the right widths for the values.
>
> We want to be careful about the pretends implied by the rep operators
> because we dont want any unsigned->float conversions to take place.
> We just ant a re-interpretation cast in the generated C.
>
> If the import statement reads  ... from Foreign C("math.h")  then that
> should generate a #include <math.h> rather than a prototype.
>
> -- Stephen
>
>
> On Mon, Sep 24, 2007 at 10:48:23AM +0200, Ralf Hemmecke wrote:
> > Hi David,
> >
> > Looks like a bug to me. But it should rather read...
> >
> >       (a:%) ^ (b:%):% == {
> >               import { powf: (%, %) -> % } from Foreign C;
> >               per powf(rep a, rep b);
> >       }
> >
> > Would someone disagree?
> >
> > Ralf
> >
> >
> >
> > On 09/24/2007 05:24 AM, David Casperson wrote:
> > > sal_sfloat.as in lib/aldor/src/arith/ contains the lines
> > >
> > > ----------------------------------------------------------------------
> > >      Rep == SFlo;
> > >
> > > -- ...
> > >
> > >     (a:%) ^ (b:%):% == {
> > >             import { powf: (%, %) -> % } from Foreign C;
> > >             powf(a, b);
> > >     }
> > > ----------------------------------------------------------------------
> > >
> > > am I hallucinating or shouldn't this be?
> > >
> > > ----------------------------------------------------------------------
> > >      Rep == SFlo;
> > >
> > > -- ...
> > >
> > >     (a:%) ^ (b:%):% == {
> > >             import { powf: (Rep, Rep) -> Rep } from Foreign C;
> > >             per powf(rep a, rep b);
> > >     }
> > > ----------------------------------------------------------------------
> > >
> > > The current version gives warning messages about type mismatches.
> >
> > _______________________________________________
> > Aldor-l mailing list
> > Aldor-l at aldor.org
> > http://aldor.org/mailman/listinfo/aldor-l_aldor.org
>
> _______________________________________________
> Aldor-l mailing list
> Aldor-l at aldor.org
> http://aldor.org/mailman/listinfo/aldor-l_aldor.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://aldor.org/pipermail/aldor-l_aldor.org/attachments/20070924/dce2c101/attachment.html 


More information about the Aldor-l mailing list