-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undesirable behavior in the execution of the Show built-in #250
Comments
It is normal for You can force it to be ready before you start creating any space with |
On Wed, Dec 3, 2014 at 3:28 PM, Sébastien Doeraene <[email protected]
declare Now let us suppose that Show is lazy as you said and that is only "ready" |
It was like that in 1.4.x as well.
That's it. It is just like any |
We have tried the following program and it does behaves as expected: declare The only modification is in the second line: {Wait Show}. The fact that it behaves as expected (i.e. shows failed) is fine. However we still have some questions:
We think that loading the modules when they are required is a wise decision. However, doing it using ByNeedFuture does not sound right to us. Take into account for instance the System module. Every built-in in that module is “defined” and hence “ready”. In consequence, when System.show is used it has to be executed immediately by the VM. Or are we missing something?= |
Probably because A builtin module (boot module) can be constant-folded by the compiler, causing a direct reference to builtin functions to be stored in the code, which makes User modules need to be lazily loaded.
I don't know. But it seems plausible (except for true builtins -
It is the only reasonable thing to do. How would you do it otherwise?
Again, |
I see. Probably at the time that constraint programming was implemented in the original mozart was safe to rely on such artifacts. The problem that we face now is that aspects like stability detection relies on those “artefacts” and is easy to get an undesirable behavior just by running old code on the new system. At least from the constraint programming standpoint. I would like to know your opinion on how to tackle this problem. In my opinion the first thing to do is to warn the user when situations like this occurs. For instance, I would rise an exception with an appropriate message. I think an exception is far better than the current behavior. Is it possible to detect this situation in a consistent way?. I have thought about:
This will be difficult and will lead to ugly code, in my opinion. Moreover, the code would not be a direct consequence of the problem constraint being solved but just to work around an old design decision. I think the first step is to detect the problem and hence my idea of throwing an exception. This will ensure program termination in a consistent way. This is not only Show dependent but the idea is to catch the problem for any other user module (or better: Oz defined procedure that is lazily loaded). Another way is to change the way in which space stability is detected. However this will require more changes at both implementation and design levels. This is why I hesitate to go in this way but still a possibility. |
Before going to all these things, could you check what happens in Mozart 1.x if you use a simulated lazy LazyShow = {ByNeedFuture fun {$} Show end} and use How does Mozart 1 behaves in that case? Does it detect stability as well? |
Do you have any clue on where to start looking for the problem? |
So I suppose Mozart 1 did something funny to not consider a space stable if it waits for something like a |
|
I have digged a bit into the behavior reported in (#100 ). I managed to get deeper and confine the problem. Right now my hypothesis is that the bug is not related to the detection of the space stability but to the execution of the Show built-in. Consider the following piece of code that should show failed but prints succeeded instead.
I added the following print statements inside the VM implementation:
The execution of the program above leads to the following output:
Output explanation:
Conclusions/ Guesses:
Our guesses: at some point Show is not “ready” and hence the VM suspends the thread. The problem now is to know why it was not ready. To continue the hunt we would like to know if any of you share the same guess or have another clue about what can be producing this behavior.
The text was updated successfully, but these errors were encountered: