[e-lang] Content Complete, Ready for Comments
David Hopwood
david.nospam.hopwood at blueyonder.co.uk
Thu Jun 30 21:22:16 EDT 2005
Mark Miller wrote:
> David Hopwood wrote:
>
>> $ cat epimenides.e
>> #!/usr/bin/env rune
>> pragma.disable("explicit-result-guard")
>>
>> var flag := null
>> def epimenides() { return flag <- not() }
>> flag := epimenides <- run()
>>
>> java.lang.NoSuchMethodException: <null>.not/0
>
> Try adding a
>
> pragma.enable("easy-return")
>
> to your program. Without this, the lack of a result guard is equivalent
> to :void rather than :any, which is why you're getting that null.
So in order to be correct in current E, the program in the paper should
use one of 'pragma.enable("easy-return")', ':any', or ':vow[boolean]'
(I'd suggest the last of these, even though it will have to be explained).
Incidentally, the error message you get without any pragma:
# syntax error: The optional e.enable.explicit-result-guard feature (see
# org/erights/e/elang/syntax/syntax-props-default.txt) is currently on
# disallowing this construct.
encourages just disabling explicit-result-guard in order to make the error
go away, which is likely to be the wrong thing in many (most?) cases.
>> Oddly,
>> def epimenides() :vow[boolean] { return flag <- not() }
>> just causes the script to terminate without any output; I didn't look
>> closely at what was going on there.
>
> The addition of an explicit result guard caused the lack of easy-return
> not to matter. Your code now datalocks as expected.
Ah, of course. The line 'flag := epimenides <- run()' sets flag to a
new promise in this turn, before running epimenedes() in the next turn
(so the previous value of flag isn't relevant). The text should explain
this.
--
David Hopwood <david.nospam.hopwood at blueyonder.co.uk>
More information about the e-lang
mailing list