[sac-user] SaC beginner: modularization, declaration

Carl Alan Joslin carl.joslin at joslinfamily.co.uk
Thu Dec 9 12:09:09 CET 2010


The type system is run many times as optimisations may make it possible
to improve the types, this can then allow more optimisations and so on.

Carl

On Thu, 2010-12-09 at 11:37 +0100, Juhasz David wrote:
> Hi Carl,
> 
> Thanks for your answer. I thought the entire type checking is executed 
> before the optimizations, and didn't know about the laziness of the type 
> system. Now it is completely clear.
> 
> Best,
> David
> 
> On Wed, 2010-12-08 at 15:47 +0000, Carl Alan Joslin wrote:
> > One of my collages has pointed out that I have missed out the type
> > conversions:
> > 
> > x = (:array)[10] 
> > ((:int[1])x)[0] = 10
> > 
> > print is also not defined on type array so you need
> > print( (:int[1]) x);
> > 
> > Sorry about that
> > 
> > Carl
> > 
> > On Wed, 2010-12-08 at 14:56 +0000, Carl Alan Joslin wrote:
> > > On Wed, 2010-12-08 at 14:50 +0100, Juhasz David wrote:
> > > > Hi,
> > > > 
> > > > I'm participant of a project in Eötvös Loránd University, Hungary. In this 
> > > > project we want to develop a general programming language for multicore 
> > > > and distributed systems, wich is not hardware-specific, but can make an 
> > > > effective code from the source. My actual assignment is to write a summary 
> > > > about SaC and its compiling issues. There are useful papers on SAC 
> > > > homepage. But as I can see, the module subsystem section doesn't reflect 
> > > > the current syntax for modularization. So I have two questions about this 
> > > > topic:
> > > > * What is the difference between the use and the import instructions?
> > > > * How is it possible to define uniqueness type explicitly? Classtypes are 
> > > >   uniqueness, but I'd like to define uniqueness types on a general way.
> > > > 
> > > > And one more question about variable declaration. I don't know that it's a 
> > > > bug or just I don't understand the impact of declarations. Consider the 
> > > > following example:
> > > > 
> > > > import Array: all;
> > > > import StdIO: all;
> > > > 
> > > > typedef int[1] array;
> > > > 
> > > > int main()
> > > > {
> > > > 	array x;
> > > > 	x = 10;
> > > > 
> > > > #ifndef EXCLUDE_ERRORS
> > > > 	print(x);
> > > > #endif
> > > > 
> > > > 	return(0);
> > > > }
> > > > 
> > > > Without the print there is no error, but with the print there is a typing 
> > > > error for the assignment. I wonder, why succeed the compiling without the 
> > > > print. What's the matter in this case? If this is actually a bug, I'll 
> > > > report it more detailed in SaC-Zilla.
> > > I will cover your last question.
> > > 
> > > This is not a bug.  You have defined array to be of type int[1] this
> > > means an array with one dimension of length 1 AKA a vector of one
> > > element.  However you assign 10 to a variable (x) of type array.  10 is
> > > a scalar, therefor the types are different.  Perhaps what you meant to
> > > do was x = [10] or x[0] = 10?
> > > 
> > > The reason that this does not show up when you remove the print is that
> > > without the print there is no use of x and there for x = 10 and array x
> > > are not needed to compute the answer to your program and therefor can be
> > > removed.  It would seem that the compiler works out that x is not needed
> > > before it tries to check that the right hand side of your assignment is
> > > valid.
> > > 
> > > The reason that print is not dead code is that it affects an uniqueness
> > > type the terminal.  It may help seeing a SIMPLIFIED version of how your
> > > code looks inside the compiler is:
> > > 
> > > int main()
> > > {
> > >   array x;
> > >   term = initTerminal( );
> > >   x = 10;
> > >   term' = print( term, x);
> > >   return( term', 0);
> > > }
> > > > 
> > > > Thanks for any advice!
> > > > 
> > > > Best regards,
> > > > David
> > > > _______________________________________________ sac-user mailing list sac-user at sac-home.org http://lists.sac-home.org/mailman/listinfo.cgi/sac-user
> > > 
> > > 
> > > _______________________________________________
> > > sac-user mailing list
> > > sac-user at sac-home.org
> > > http://lists.sac-home.org/mailman/listinfo.cgi/sac-user
> _______________________________________________ sac-user mailing list sac-user at sac-home.org http://lists.sac-home.org/mailman/listinfo.cgi/sac-user





More information about the sac-user mailing list