Closed elegios closed 2 years ago
So I have been thinking a little about the OCaml interface towards sequence and symbol intrinsics. The idea so far:
Create a module, named say Intrinsics
, containing the ocaml versions of cons
, snoc
, makeSeq
, etc., as well as gensym
, eqsym
(we could very well interface all intrinsics here instead of calling the corresponding operators in the generated ocaml code (or boot
for that matter) directly e.g. (+)
, (-)
, ..., but maybe that is a bit excessive). I think this gives a nice clean interface to be made available in the generated ocaml code as well as in boot
. However, we cannot directly use this module in boot
since we internally rely on map
, fold_right
, etc
over sequences (finger trees), so we would have to add these by extending Intrinsics
in boot
(using include in the module I guess).
Good point. However, we have to double check so that we do not get an overhead in the compiled code due to an indirection via a module. Especially if (+)
, (-)
etc. are included. I guess the only way to really check this is to inspect the generated assembly code.
Intrinsics we can compile to ocaml and are tested.
addi
subi
muli
divi
modi
negi
lti
leqi
gti
geqi
eqi
neqi
slli
srli
srai
arity
addf
subf
mulf
divf
negf
ltf
leqf
gtf
geqf
eqf
neqf
floorfi
ceilfi
roundfi
int2float
string2float
eqc
char2int
int2char
create
length
concat
get
set
cons
snoc
splitAt
reverse
subsequence
print
dprint
readLine
readBytesAsString
argv
readFile
writeFile
fileExists
deleteFile
error
exit
eqsym
gensym
sym2hash
randIntU
randSetSeed
wallTimeMs
sleepMs
mapEmpty
mapInsert
mapRemove
mapFind
mapAny
mapMem
mapMap
mapMapWithKey
mapBindings
tensorCreate
tensorGetExn
tensorSetExn
tensorRank
tensorShape
tensorReshapeExn
tensorCopyExn
tensorSliceExn
tensorSubExn
tensorIteri
bootParserParseMExprString
bootParserGetId
bootParserGetTerm
bootParserGetString
bootParserGetInt
bootParserGetFloat
bootParserGetListLength
bootParserGetConst
bootParserGetPat
bootParserGetInfo
CNot
is compiled but it doesn't exist in boot
so it should probably be removed.
This issue serves as the master issue for the current task of getting a compiler working for mexpr.
Obj.repr
and arguments to intrinsics inObj.obj
. This task probably includes generating let's before the program binding intrinsics to appropriately Objified types. Possibly also ar
function instead ofObj.repr
, just for brevity.gensym
)?utest
?pprint.mc
for OCaml