[Grace-core] fixing REPL's

Andrew P Black andrew.p.black at gmail.com
Thu May 2 10:34:58 PDT 2013


I'm not impressed by the "nested scopes" idea for a dynamic language like Grace.  And we don't have teletypes any more, so we should be re-thinking "REPL", which implies that we do.  I like to think of a "play space" in which the student can edit and execute code.

It seems much more reasonable to me to treat the contents of the "play" window as a grace program, make it editable and executable, and make the semantics identical to what would be in a file.

In particular, the Grace equivalent of

Prelude> let sqr x = x * x
Prelude> let sqq x = (sqr x) + 1
Prelude> sqq 5
26

would be

	method sqr(x) { x * x }
	method sqq(x) = { sqr(x) + 1 }

and that sqr(x) on the second line means self.sqr(x) — it's supposed to be dynamically bound.   So if the student re-defined sqr(x), she will expect the behaviour of sqq to change.

This can be made clear to the student by letting them EDIT the code in the "play" window, i.e., change the definition of method sqr rather than typing another one.

	Andrew



More information about the Grace-core mailing list