[e-lang] Why aren't guards allowed on forward declarations?
Mark Miller
erights at gmail.com
Fri Sep 28 00:59:39 EDT 2007
On 9/26/07, David Hopwood <david.hopwood at industrial-designers.co.uk> wrote:
> Kevin Reid wrote:
> > On Sep 26, 2007, at 16:57, David Hopwood wrote:
> >> Kevin Reid wrote:
> >>> On Sep 26, 2007, at 16:20, David Hopwood wrote:
> >>>> def succeeded :boolean
> >>> (Syntactic note: Forward declarations may not have guards.)
> >> Any good reason for this? It seems as though the semantics would be
> >> clear.
I just talked to Kevin and Dean about this and came up with a clearer
reason why this is disallowed.
In general in E, when a guarded declaration appears such as
def succeeded :boolean := expr
any code for which the defined variable is in scope is guaranteed that
it will hold a value of the type the guard guarantees. For example, if
expr produces a non-boolean, an exception will be thrown, preventing
execution of the code for which the succeeded variable would have been
in scope.
The whole purpose of a forward declaration is to bring the variable
into scope before it's initialized. If it is used before it's
initialized, it won't have a value with the guarantees normally
implied by the guard notation.
--
Text by me above is hereby placed in the public domain
Cheers,
--MarkM
More information about the e-lang
mailing list