On Sun, May 31, 2015 at 5:25 PM, Matt Oliveri <[email protected]> wrote: > On Sun, May 31, 2015 at 10:51 AM, Jonathan S. Shapiro <[email protected]> > wrote: >> How about this: >> >> Pick a language of your choice. Show me how to declare the type of an AST >> node that satisfies the following properties: >> >> 1. The grammar is the expression grammar for four-function expression >> arithmetic plus negation plus assugnment. Note that negation is unary and >> assignment is NOT an expression. You don't have to worry about the parsing >> or precedence or the like. You only need to create a suitable AST. >> 2. Every AST node has a field of type "Location". This will serve as the >> non-variant part. >> 3. The structural correctness of the tree should be statically checked to >> the degree that this can be expressed. >> 4. It should be possible to write a single procedure taking an argument of >> type ASTNode and performing some form of recursive-descent pass on that node >> type. > > So how's this OCaml?
I think part of the problem comes when you sometimes want something of 'a, and at other times want something of 'a node, you end up declaring the type as 'a and scattering 'a node about, rather than declaring the type as 'a node after the of, this was the case I found annoying because there were very few cases I didn't want 'a nodes (I see one actually)... _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
