four months of coastal living: coastML at four months
Today marks four months of coastal living; let’s checkout the running burndown chart:
✓ assignments
✓ functions
✓
case
forms✓ thread assignments into
case
forms (e.g.a = case x …
becomescase x | … { a = … }
)❏
case
forms within other forms, such as function calls
✓
type
forms✓ Python generation
✓ decomposition in
case
forms✓ including pattern matching
❏ array pattern matching
❏ string pattern matching (this could get interesting…)
✓ accessors (both variables and lambdas) for
type
❏
gn
forms❏
fc
formsStill so on the fence about these…
❏
mod
andsig
forms❏ an analog to SML’s
op
, using backticks❏ basis library (stubbed out, need to actually compile)
✓ basic basis stubs: some members of
array-*
,string-*
have been stubbed out✓ array-length
✓ array-get
✓ array-set!
✓ array-make
✓ array-init
✓ array-make-matrix
✓ array-append
✓ array-append!
❏ array-concat
❏ array-concat!
✓ array-sub
✓ array-copy
❏ array-fill!
❏ array-blit!
❏ array→list
❏ list→array
✓ array-iter
✓ array-map
✓ array-iter-index
✓ array-map-index
❏ array-foldl
❏ array-foldr
❏ array-sort
✓ array-sort!
❏ array-stable-sort
❏ array-fast-sort
✓ string-length
✓ string-get
❏ string-make
❏ string-init
✓ string-split
✓ string-append
❏ string-join
❏ string-contains
❏ string-concat
❏ string-copy
❏ string→array
✓ string-iter
✓ string-map
✓ string-iter-index
❏ string-map-index
❏ string-foldl
❏ string-foldr
✓ string-sort
❏ compare
❏ char-code
❏ char-chr
❏ char-escaped
❏ char-lowercase
❏ char-uppercase
❏ char-compare
More of the OS interaction stuff out of the Pervasives API
❏ basis library modules (modular forms, e.g.
array-get
becomesArray::get
)
❏ support for the
is
form❏ code generation
❏ C
❏ C++
❏ Go
✓ Python
❏ type inference
❏ refinement types
❏ a compiler
❏ lambda lifter
❏ closure conversion
❏
pragma
to control certain aspects of compilation❏ checking of accessors prior to compilation
❏ value restriction for
ref
types
bugs fixed
✓ nested arrays
[[[1] [2]] [[3] [4]]]
✓ missing
/
character in identifier/operator character sets✓ floating point numbers with two integral digits (e.g.
0.12
and1.12
worked but not10.12
)this was noticed when attempting to write some software to generate Julian dates
✓
return
logic✓ indentation of blocks
✓ missing
bool
type✓ parsing
type
definitions that have other complex types in them✓ munging idents (ex:
julian-date
becomesjulian_date
)✓ stripping comments prior to output
really need to handle these so that we can output them into the compiled language, but for now this suffices
✓
return
prepended to forms that are rewritten tofor
loops✓ fix spacing between
class
forms in Python output✓ fixed bugs with parsing & displaying characters
Wow have we fixed a lot of bugs this month, and there’s a few new
forms that work nicely. The various pervasives such as
array-iter
now rewrite to nicely-compact Python forms, and
some issues around their usage has been fixed. I’m tracking their usage
in the extra/
folder, as a demo of how they should
work:
% ./carpet.py load extra/basis-examples.coast
main ['./carpet.py', 'load', 'extra/basis-examples.coast']
loading: extra/basis-examples.coast
[CoastAST(a is function[int int int] = fn x y {
x + y
}), CoastAST(adder is function[int int] = fn x {
x + x
}), CoastAST(l is function[int unit] = fn x {
print "x is: " x;
}), CoastAST(ll = fn idx value {
print "x at offset " idx " is " value;
}), CoastAST(s is function[char unit] = fn x {
print "x is: " x;
}), CoastAST(b is int = 10), CoastAST(g = array-make 10 0;), CoastAST(h = array-init 10 adder;), CoastAST(m = array-make-matrix 5 6 0;), CoastAST(f = array-map adder h;), CoastAST(j = array-map-index a h;), CoastAST(array-iter l f;), CoastAST(array-iter-index ll f;), CoastAST(string-iter s "hello, world";), CoastAST(a-i-func = fn l f {
array-iter l f;
}), CoastAST(a-i-func l f;)]
% ./carpet.py python extra/basis-examples.coast
main ['./carpet.py', 'python', 'extra/basis-examples.coast']
pythonizing: extra/basis-examples.coast
def a(x, y):
return (x + y)
def adder(x):
return (x + x)
def l(x):
return print("x is: ", x)
def ll(idx, value):
return print("x at offset ", idx, " is ", value)
def s(x):
return print("x is: ", x)
b = 10
g = [0 for _ in range(0, 10)]
h = [adder(x0) for x0 in range(0, 10)]
m = [[0 for _ in range(0, 5)] for _ in range(0, 6)]
f = [adder(x1) for x1 in h]
j = [a(idx2, h[idx2]) for idx2 in range(0, len(h))]
for x3 in f:
l(x3)
for idx4 in range(0, len(f)):
x5 = f[idx4]
ll(idx4, x5)
for x6 in "hello, world":
s(x6)
def a_i_func(l, f):
for x7 in f:
l(x7)
a_i_func(l, f)