[e-lang] Why aren't guards allowed on forward declarations?
Kevin Reid
kpreid at mac.com
Fri Sep 28 11:35:39 EDT 2007
On Sep 28, 2007, at 10:47, David Hopwood wrote:
> If using backtracking exceptions [*], then the exception caused by
> trying
> to access a forward-declared variable before it is given a value would
> undo side effects performed in that scope.
There is no such exception. Before it is "given a value" (that is,
resolved), the value is a promise. It is possible to examine a
reference and find out that it is a promise.
It would be possible (using a custom slot) to write a forward-
declaration mechanism that behaves as you describe, but it would be
less useful, as it would allow only use-before-definition within
objects and not within data structures.
That is, this would be disallowed:
def foo
def bar
bind foo := makeFoo(bar)
bind bar := makeBar(foo)
This particular case can be rewritten as
def [foo, bar] := [makeFoo(bar), makeBar(foo)]
but in larger cyclic definitions this notation is clunky.
--
Kevin Reid <http://homepage.mac.com/kpreid/>
More information about the e-lang
mailing list