google-code-export / omega

Automatically exported from code.google.com/p/omega
Other
2 stars 0 forks source link

"run" acts strangely on lazy values #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. enter following commands on the prompt>

prompt> run (lazy (lift 5))
Run expression:
  run ((lazy lift 5))
Does not evaluate to code:
   (Lazy ...)

prompt> run undefined
Run expression:
  run (undefined)
Does not evaluate to code:
   (Vbottom)

prompt> (let f = run in f (lazy (lift 5)))
5 : Int

prompt> (let f = run in f undefined)
Error -- Something pulled on undefined

To get these diagnostics I have slightly changed

evalZ env (Run e) =
  do { x <- eval env e
     ; case x of
        Vcode c env2 -> eval env2 c
        v -> fail ("Run expression:\n  "++show (Run e)++
                   "\nDoes not evaluate to code:\n   "++pv v)
     }

to use "pv" instead of "show".

What is the expected output? What do you see instead?
I would expect that "run" correctly pulls a lazy value.

This happens in the case of 
(let f = run in f (lazy (lift 5)))
as seen in the dialogue above.

Obviously "Run" should not be handled like a language construct, but like a
simple function, thus eliminating the "evalZ env (Run e)" in its entirety.

The problem is also present in the Nov. 8 snapshot.

Original issue reported on code.google.com by ggr...@gmail.com on 10 Mar 2008 at 12:58

GoogleCodeExporter commented 9 years ago

Original comment by ggr...@gmail.com on 10 Mar 2008 at 12:59

GoogleCodeExporter commented 9 years ago
r572 fixes these examples.

There is a minor complication though; I do not know how to handle the 
permutation part (for names) in Vlazy. So I'll restrict our evaluation ability 
to empty permutations, and we have to fix the other case as it arises.

Also the evaluation may fail without an error message when the forcing of the 
Vlazy does not give a Code (but e.g. a Vbottom). I'll play around a bit and fix 
if it is easy to do so.

Original comment by ggr...@gmail.com on 11 Jan 2011 at 4:06

GoogleCodeExporter commented 9 years ago
r573 now performs:

prompt> run (let f a = a+42 in lazy undefined)

**undefined** : forall 'a.'a

BUT: I suspect it should actually pull on that undefined, causing a run-time 
error. This comes next.

Original comment by ggr...@gmail.com on 11 Jan 2011 at 4:25

GoogleCodeExporter commented 9 years ago
r574 solves all my concerns voiced in
http://code.google.com/p/omega/issues/detail?id=58#c2
and
http://code.google.com/p/omega/issues/detail?id=58#c3

'run' behaves like a function now :-)

Original comment by ggr...@gmail.com on 11 Jan 2011 at 4:43