[sac-user] SAC source code

Andrew Pennebaker andrew.pennebaker at gmail.com
Mon Oct 24 21:32:54 CEST 2011


Ah, okay. I was unsure if SAC was closed-source or just neglected to provide
a link to the source on the downloads page. I was mainly interested in
combining the Makefiles and adding an install: option to copy sac to a
directory and add that directory to PATH in ~/.bashrc (or ~/.profile on
Mac).

I've been following the SAC Tutorial. The examples are really helpful by the
way, though I would like to see the output be included in the manual just to
double-check my output.

The tutorial describes function definitions using multiple return types,
mimicking Python tuples. I was saddened to read that SAC doesn't support
tuples in expressions, only as a kind of hack in calling functions. I would
really like to see first-class tuples in SAC; when I read that SAC's
fundamental data structure is an n-dimensional array, I thought "Wow, that's
cool! All you would need to build other kinds of data structures is arrays
and tuples, I hope SAC has those." Even C structs would suffice, but it
would be nice to have something more like tuples and as dynamic as SAC
arrays.

Also, I was *really* surprised to read on page 10:

In a sequence of variable definitions, the scope of a variable starts with
the left-hand side of its definition and either reaches down to the end of
the function, or, provided at least one further definition of a variable
with the same name exists, to the right-hand side of the next such
definition. This measure allows us to reuse variable names.

It seems like a bit of a misnomer to call the language Single Assignment C.
I know, I know, "the place-holder property always holds!" I realize this
scope behavior is there to make it more convenient for coders, but it feels
*wrong*.

Have you used Haskell, another single assignment language? One way to get
around the problem of creating so many variable names is to allow the prime
(') character in variable names:

x = 5
x' = x + 5
x'' = x * 10
x''' = x ^ 2

It's straight out of mathematics, and it becomes second nature to code like
this.

Side note: the print( arbitrary_array ) function is extremely handy. I'd
like to modify the formatting, though, I feel there's a lot of extra space,
and the alignment sometimes looks forced.

$ cat ars.sac
use StdIO: all;
use Array: all;

int main() {
    print(reshape([5], [1, 2, 3, 4, 5]));
    print(reshape([3, 2], [1, 2, 3, 4, 5, 6]));
    print(reshape([3, 2, 1], [1, 2, 3, 4, 5, 6]));

    return(0);
}
$ ./ars
Dimension:  1
Shape    : <  5>
< 1  2  3  4  5 >
Dimension:  2
Shape    : <  3,  2>
| 1  2 |
| 3  4 |
| 5  6 |

Dimension:  3
Shape    : <  3,  2,  1>
< 1 > < 2 >
< 3 > < 4 >
< 5 > < 6 >

$

Why not clean the formatting up a bit?

$ ./ars
Dimension: 1
Shape: <5>
<1 2 3 4 5>
Dimension: 2
Shape: <3, 2>
|1 2|
|3 4|
|5 6|

Dimension: 3
Shape: <3, 2, 1>
<1><2>
<3><4>
<5><6>
$

And why do shapes use commas, but the actual arrays do not?

$ ./ars
Dimension: 1
Shape: <5>
<1 2 3 4 5>
Dimension: 2
Shape: <3 2>
|1 2|
|3 4|
|5 6|

Dimension: 3
Shape: <3 2 1>
<1><2>
<3><4>
<5><6>
$

Does SAC have a function like print() that shows an array as a string, but
without showing the dimension and shape?

Does SAC have a function like print() that returns a string like C's
sprintf()?

How do you like my solution to Exercise 3 on page 8?

Exercise 3

Given the language constructs introduced so far, can you define an array
that would print as

Dimension: 3
Shape :< 5, 2, 2> <0 0><0 0>
<1 0><0 0>
<0 1><0 0>
<0 0><1 0>
<0 0><0 1>

, but whose definition does not contain the letter 1 more than once?

$ cat ex3.sac
use StdIO: all;
use Array: all;

int main() {
    print(genarray([5, 2, 2], 3) - reshape([5, 2, 2], [
        3, 3, 3, 3,
        2, 3, 3, 3,
        3, 2, 3, 3,
        3, 3, 2, 3,
        3, 3, 3, 2
    ]));

    return(0);
}

Since array addition and subtraction weren't introduced yet, I had to guess
that (-) worked intuitively. It's a bit odd that the exercise would require
you to use these methods, since they aren't even introduced yet, so I have
to wonder if there's another way to do this.

Finally, I made a quick vector image of the SAC logo using Inkscape, if
anyone's interested.

http://www.yellosoft.us/public/images/sac.svg

Cheers,

Andrew Pennebaker
www.yellosoft.us

On Mon, Oct 24, 2011 at 3:11 AM, Clemens Grelck <
clemens.grelck at googlemail.com> wrote:

> Your understanding is correct indeed. For a number of reasons, that
> I do not want to elaborate here, the SAC compiler is currently not
> open source. This may change in the future (or not). For now you can
> download a binary distribution here:
>  http://www.sac-home.org/index.**php?p=.%2F55_Download<http://www.sac-home.org/index.php?p=.%2F55_Download>
>
> If you are seriously interested in how the compilation works, the
> compiler is very verbose in its doing, for instance you can stop
> the compilation after any of the several hundred passes and look
> at the intermediate code. This might be more interesting in practice
> than looking at the sources.
>
> If you are seriously interested in contributing to the SAC project,
> we are under certain conditions happy to welcome you in the team and
> provide you with access to the sources.
>
> Cheers,
>  Clemens
>
>
> On 10/24/2011 05:35 AM, Ivan Shmakov wrote:
>
>>  Andrew Pennebaker<andrew.pennebaker@**gmail.com<andrew.pennebaker at gmail.com>>
>>>>>>>  writes:
>>>>>>>
>>>>>>
>>  >  Where is the SAC repository? Is it CVS, Subversion, or something
>>  >  else?  Cheers,
>>
>>        It was my understanding that SAC is non-free.  (In the sense of
>>        the first freedom, which reads: “The freedom to study how the
>>        program works, and change it so it does your computing as you
>>        wish (freedom 1).  Access to the source code is a precondition
>>        for this.” [1].)
>>
>>        I'd be glad should someone point out that I'm wrong.
>>
>>        TIA.
>>
>> [1] http://www.gnu.org/philosophy/**free-sw.html<http://www.gnu.org/philosophy/free-sw.html>
>>
>>
>
> --
> ------------------------------**------------------------------**----------
> Dr Clemens Grelck                                     Science Park 904
> University Lecturer                                   1098XH Amsterdam
>                                                           Netherlands
> University of Amsterdam
> Institute for Informatics                        T +31 (0) 20 525 8683
> Computer Systems Architecture Group              F +31 (0) 20 525 7490
>
> Office C3.105                               www.science.uva.nl/~grelck<http://www.science.uva.nl/%7Egrelck>
> ------------------------------**------------------------------**----------
>
> ______________________________**_________________
> sac-user mailing list
> sac-user at sac-home.org
> http://lists.sac-home.org/**mailman/listinfo.cgi/sac-user<http://lists.sac-home.org/mailman/listinfo.cgi/sac-user>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sac-home.org/pipermail/sac-user/attachments/20111024/0ef9f8c8/attachment-0002.html>


More information about the sac-user mailing list