Re: [stack] problems with high-level purely linear languages
John Nowak <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
On Mar 14, 2008, at 3:53 PM, Don Groves wrote: > I have a few suggested rules regarding > the use of linearity in concatenative languages: > > (1) Only temporary objects (on the stack) need be linear. Persistent > (named) objects may have any number of references simply by not > allowing them to be deleted -- once created, they exist for the life > of the program. Aye, I've taken a similar approach. Top-level definitions bind a name to the result of some (pure) expression that operates on an empty stack and returns a function. This can be implemented either by evaluating the expressions at compile time or by evaluating them the first time they're called and caching the result. By putting values on the stack and then quoting them, names can be bound to functions that return the *same* value each time they're called. In order to ensure type system soundness, it is necessary to prevent things like expressions that return a quoted mutable reference with a polymorphic type. This isn't difficult to do. > (2) Named objects are immutable. I don't see this as necessary. References are safe provided that they're not polymorphic (e.g. [Ref Int] is fine but [Ref [List a]] isn't) and provided that you're willing to accept a runtime error if they're empty (as I discussed in the previous email). - John