A macdef
in ATS cannot involve types (but it can in ATS2); use macros only in cases where using functions would be inconvenient. Using macros probably does not make your code run more quickly, since gcc -O2
already inlines functions somewhat aggressively.
Making use of the knowledge that separate val declarations within the same scope technically denote different vals on the stack should not preclude one from using a natural style. For instance:
val x = 5 val x = 7
here no extra space is allocated for the second 'x' due to constant propagation. It is in generally unlikely that such a coding style would incur any penalty.
Instead of freeing an instance of a linear type and immediately creating and returning a new one with the same value in a case expression, like this
case+ x of | ~GRgenes (genes) => GRgenes (genes)
do this
case+ x of | GRgenes _ => (fold@ x; x)
because @fold
is compiled into a "noop".
Remove anonymous closure definitions from function calls when possible, to avoid having them created each time the loop is called. For instance, a simple string comparison function can be created like so:
val cmp_str = lam(x:string,y:string):int =<cloref> compare (x, y)
Anonymous