nwf / dyna

Dyna2 compiler and REPL
GNU Affero General Public License v3.0
146 stars 20 forks source link

Are there any restrictions on return types? #83

Open JeffreyBenjaminBrown opened 6 years ago

JeffreyBenjaminBrown commented 6 years ago

This language looks amazing!

The tutorial leads me to believe the arguments to a functor must be strings or integers:

"We can also have rules which contain both variables and atoms. (An atom is an argument
to a functor. Types of atoms include strings in quotes, like "Steve", and numbers,
like 903 or 3.14159. Variables don’t count as atoms, because they stand in place of atoms.)"

A very cursory glance at this paper leads me to believe that a Dyna functor's return type can be specified as any type, or left unrestricted.

Is that so?

(I apologize if I'm asking this question in the wrong place; if that's so, please let me know where to move it.)

timvieira commented 6 years ago

An item can take on values of two general types primitive types (e.g., string, int, Boolean) as well as recursive "Terms types" (e.g., x = &f(&g(&h(1))), lists [1,2 ,"a", ["b"] ]).

The unary operator &, known as "quote" is used to create these Term structures. To avoid clutter, functors can declare their default "disposition" via pragma directives. An example of such a functor is cons -- the list constructor` - it does not require explicit quoting because it's default disposition is "quoted".

JeffreyBenjaminBrown commented 6 years ago

So it sounds like anything I could represent in JSON, I could represent in Dyna?

timvieira commented 6 years ago

Yes, JSON is a subset of what's representable in Dyna. At the moment, JSON is close fit for what's implemented in this language prototype since we don't yet support variable-variable unification (as in Prolog). Generally speaking, our types are (going to be) "tree automata with equality constraints".

JeffreyBenjaminBrown commented 6 years ago

Fantastic! I can't wait to use this.

timvieira commented 6 years ago

Great! Let us know how it goes!