Semantics of define differs between the clojure macros and the metacircular interpreter #52
Labels
bug
Describes a software defect.
medium priority
An issue we should address after the urgent issues have been taken care of.
Here is a bit of technical debt to pay off some time. I don't think this is likely to bite anyone soon, but eventually it will, so I wanted to record the issue.
The issue is that the clojure-metaprob
block
macro (with itsdefine
keyword) only approximates what python-metaprob did, using the primitives available in clojure (let
andletfn
). The python-metaprob equivalent was internal definitions written using=
, which augments the lexical environment by mutation. But the meta-circular interpreter is faithful to python-metaprob. This leads to differences in behavior, for example:The
block
/define
macro is pretty hairy, and creates its illusion of environment modification by segmenting the sequence of definitions intolet
bindings andletfn
bindings - very different from creating an environment up front and mutating it with each succeedingdefine
.I'm not sure what to recommend regarding a fix. Implementing the python-metaprob semantics in clojure would be extremely painful and would create implementation and documentation complexity far in excess of its utility. But implementing the
block
macro's semantics in the metacircular interpreter will also be difficult (albeit much less so). A third alternative would be to abandonblock
/define
in favor of clojure let and letfn, with changes to the meta-circular interpreter to implement the clojure syntax.The text was updated successfully, but these errors were encountered: