On 09/15/2009 08:01 AM, John Cowan wrote: > Andre van Tonder scripsit: > >> It would be impractical for REPL usage, where the same definition may >> be iteratively modified and executed many times during development. > > The SML/NJ REPL actually does work like this: if you redefine an identifier, > it's a rebinding that doesn't affect any uses that have come before. This > can be both good and bad: sometimes it's easier to throw away the ML world > rather than redefine all the dependents of a bad definition.
The JavaFX REPL (http://per.bothner.com/blog/2009/REPL-for-JavaFX/) does this. It's not ideal, but it's a simple and sane behavior consistent with lexical binding and static typing. It probably would be friendlier to rebind "uses that have come before" to refer to a updated definition, but it's not always clear what should happen. Still, some heuristics can probably achieve what you want most of the time. For example, functions that reference the redefined binding can be re-compiled. If the typing of the function (parameters and result types) don't change, then you can patch the function in place. Ditto for classes and methods. There are some implementation challenges and limitations, since you want "old objects" to be able to be passed to updated function and methods. And that doesn't always make sense, or at least may be too difficult to implement, e.g. if you change the inheritance hierarchy of a class. Another thing to keep in mind: A modern REPL inside a GUI may allow you to edit a previous "command" and re-enter it. Should editing a previous function definition have the same effect and typing in a new function with the same name? What is the user model of "changing history"? While a REPL is a very nice tool, it has its limitations; the classical REPL probably fits best very dynamic languages, with dynamic types, no user-defined classes, and a dynamic top-level environment. It's still useful for more static languages, but there are tradeoffs that make it more limiting. A GUI that allows you to edit and quickly re-execute a program might be a better fit for more lexical languages, as there are fewer anomalies. -- --Per Bothner [email protected] http://per.bothner.com/ _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
