probcomp / Venturecxx

Primary implementation of the Venture probabilistic programming system
http://probcomp.csail.mit.edu/venture/
GNU General Public License v3.0
28 stars 6 forks source link

Unscrew list literal syntax in VentureScript #250

Open axch opened 8 years ago

axch commented 8 years ago

From a venstan example:

quote("y_out"("y", "UArray(Number)", "N")())

is how one spells what in the abstract syntax looks like

'(("y_out" "y" "UArray(Number)" "N"))

This is because the VentureScript syntax for lists of all kinds is <first_elt>(<second-elt>, <third-elt>, ...) regardless of whether they are meant as function application syntax or as list literals.

The same problem screws attempts to use the cond and letrec macros.

axch commented 8 years ago

The Scheme community has put some (not very broadly adopted) thought into surface syntaxes that would be both "more traditional" yet still homoiconic. See

for examples in Scheme proper. I also wouldn't be surprised if the Racketeers have something in this space.

lenaqr commented 8 years ago

Clojure suggests another option, which is that vectors with square brackets [a b c] evaluate as literal vectors, and many special forms use vectors instead of lists for internal grouping syntax (e.g. (let [var exp] body), (fn [arg] body)). Clojure's list/vector distinction is a little weird in that it conflates different data representations with different interpretations, and it would be a departure from Scheme style (as Venture is implemented so far), although a self-evaluating vector literal would be useful in its own right. (Maybe that should be a separate issue.)

axch commented 8 years ago

Workaround: One can always write

list(list("y_out", "y", "UArray(Number)", "N"))

That way there's extra verbiage, but at least the parens are all in reasonable places.

axch commented 8 years ago

We recently added syntactic sugar for array literals (with square brackets) (#511). That might be considered enough for this use case. The other reasonable thing to do would be to suppress leading subform motion under quote or quasiquote.