[Aldor-l] Generators

Stephen Watt watt at scl.csd.uwo.ca
Tue Nov 13 09:11:40 EST 2007


Laurentiu,

What you say is true, but the language construct used in the last example
would have  'a' constant over the scope in which it is used as a type.

for (a: MachineInteger, b: SmallPrimeField(a) in g repeat {
    // here a and b are constant so it should be ok to use a in a type,
    // and in particular in the type of b.
}

-- Stephen


On Tue, Nov 13, 2007 at 08:30:50AM -0500, Laurentiu Dragan wrote:
> Martin Rubey wrote:
> > Peter Broadbery <p_broadbery at hotmail.com> writes:
> > 
> >>> I don't know whether we said it in tha AUG, but it is intended that you
> >>> cannot assign to loop variables inside the loop.
> >>>
> >>> Consequently they can be used in type expressions and having dependent
> >>> crosses as "for" indices should be allowed.
> > 
> > Oh, that's interesting.  So 
> > 
> >         for i in g repeat {
> >                 (a: MachineInteger, b: SmallPrimeField(a)) == i;
> >                 stdout << a << newline;
> >                 stdout << b << newline;
> >         }
> > 
> > should be OK?  But it doesn't work with -DDEBUG...
> > 
> >> Unfortunately, the compiler isn't keen on them being used in types.  
> >>
> >> "bug2.as", line 10:        (x, 0$SPF(x)) for x in 1..10;
> >>                     .........................^
> >> [L10 C26] #1 (Error) `x' is used in a type, so must be constant, and so cannot be assigned to.
> >>
> >> This seems to be built into scobind.c. I'll hit it with a stick & see what
> >> happens..
> > 
> > That would be great!
> > 
> > Another mistery, at least to me:  Bill sent this snippet:
> > 
> >        stdout << "test dependent:" << newline;
> >        for (a:MachineInteger, b:SmallPrimeField a) in g repeat {
> >                stdout << a << " " << b << newline;
> >        }
> > 
> > root at sage:~/aldor-src/aldor/install/aldor# aldor -fx  -lalgebra
> > -laldor crossiterator.as
> > "crossiterator.as", line 63:
> >        for (a:MachineInteger, b:SmallPrimeField a) in g repeat {
> > ............^
> > [L63 C13] #1 (Error) `a' is used in a type, so must be constant, and
> > so cannot be assigned to.
> > 
> > Any idea why it's C13 here and C26 above?
> 
> For type safety, types must constant. By allowing types to change at 
> runtime, a variable could have different types at runtime which makes 
> type checking at compile time impossible.
> 
> --
> Laurentiu
> 
> _______________________________________________
> Aldor-l mailing list
> Aldor-l at aldor.org
> http://aldor.org/mailman/listinfo/aldor-l_aldor.org




More information about the Aldor-l mailing list