Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 403
    • Issues 403
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #1022
Closed
Open
Created Feb 21, 2012 by BugZilla@bugzillaGuest

Can not print from a fold function

Bugzilla Link 914
Created on Feb 21, 2012 20:07
Version 1.00beta
OS Linux
Architecture Other
Reporter snowgoon2003

Extended Description

From Bodos mail in the tread "using fold on vectors in a matrix"
----------------*****------------------------------
If you write something like this:
use Array: all;
int[.] american(int[.] a, int[.] b){
StdIO::print(b);
return (b);
}
int main()
{
  a = [1,2,3,4,5,6];
  c = american( a, a);
  return( 0);
} 
Then, in principle, you might think that print is just a side effect.
But no, in reality, SaC is very much aware of these things and print
operates on a global object named TheTerminal.
As a consequence, the compiler makes this explicit by converting the code into:
use Array: all;
int[.], Terminal american(int[.] a, int[.] b, Terminal TheTerminal){
TheTerminal' = StdIO::print(b, TheTerminal);
return (b, TheTerminal');
}
int, Terminal main(Terminal TheTerminal)
{
  a = [1,2,3,4,5,6];
  c, TheTerminal' = american( a, a, TheTerminal);
  return( 0, TheTerminal');
}
This works fine as long as both sides, the function definition AND the function call are
being modified consistently.
Now, by using american within the fold operation, the function call is implicit, at least
in the beginning. Later in the compiler, we make it explicit. Seemingly, at that stage,
we have forgotten that we may have to adjust the call by any potentially affected objects :-((((
As a consequence, the compiler looks for a function american that only has two parameters,
which, at that stage no longer exists as the signature of american has been expanded into 3
arguments!
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking