2 - Predicates can be based on arbitrary expressions, not just
3 "file X is older than file Y".
4 - Rules are more flexible and encourage structuring and reuse
6 - Goals can be parameterized.
7 - Program can run continuously to implement business rules.
9 Differences from 'whenjobs':
10 - Goals instead of variables.
11 - Persistent (across session) variables exist, but are not central.
12 - Doesn't use <<..>> for shell scripts (has a function 'sh' instead).
14 Similarities to 'whenjobs':
15 - Each shell script runs in its own temporary directory.
17 Example Makefile rule and translation to goaljobs language:
22 let goal compile c_file =
23 require (file_exists c_file);
24 let o_file = replace_substring ".c" ".o" c_file in
25 target (file_exists o_file && file_newer o_file c_file);
26 sh "cc -c %s -o %s" c_file o_file
32 let rec goal website_updated version =
33 let tarfile = sprintf "%s-%s.tar.gz" package version in
34 let tarpath = getenv "HOME" // "html" // tarfile in
35 let url = sprintf "http://example.com/%s" tarfile in
37 target (url_exists url);
39 require (tarball_exists version);
40 require (tarball_tested version);
42 sh "rsync %s example.com:/html/" tarpath
44 and goal tarball_tested version =
45 let tarfile = sprintf "%s-%s.tar.gz" package version in
46 let tarpath = getenv "HOME" // "html" // tarfile in
47 let memkey = package ^ "_tested_" ^ version in
49 target (memory_exists memkey);
51 require (tarball_exists version);
59 " tarpath package version;
63 and goal tarball_exists version =
64 let tarpath = getenv "HOME" // "html" // tarfile in
65 target (file_exists tarpath);
69 git archive --prefix %s-%s/ v%s | gzip > %s-t
71 " package package version version tarpath tarpath tarpath
77 git describe --tags --abbrev=0 --match='v*'
79 require (website_updated version)