Skip to content
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

Why does vigil punish a function that throws an unhandled exception? #9

Open
eschkufz opened this issue Jan 3, 2013 · 7 comments
Open

Comments

@eschkufz
Copy link

eschkufz commented Jan 3, 2013

It seems to me that when a function, f, throws an unhandled exception, it isn't f, but whatever functions are above f on the call stack which are WRONG and should be PUNISHED.

For example (forgive the syntax, I don't write python):

def div(x,y):
if y == 0
throw exception
else
return x/y

def bad():
return div(1,0)

def main():
return bad()

Nothing about div() is incorrect.
It is simply the victim of a bad calling context.
Isn't throwing an exception a form (albeit much less righteous) of implore()'ing constraints on input arguments?

I believe the only difference between what I'm proposing and your policy is that vigil would delete div() as well as the calling stack (recursively) as opposed to sparing div().
Couldn't you instead mutilate div() in some fashion or another?
Such as by modifying it to implore() against the input arguments which caused the exception to be thrown?

@munificent
Copy link
Owner

I like the cut of your jib. Perhaps all functions above the throwing function on the stack bear the stain of culpability and should suffer the same fate.

@michaelmior
Copy link

Maybe the entire stack should just be destroyed when an unhandled exception is thrown. Kill them all and let…someone else…sort 'em out.

@taemyr
Copy link

taemyr commented Jan 4, 2013

Nothing about div() is incorrect.
This is wrong. How should the caller know that y should not be 0?

It should be written:

def div(x,y):
implore y != 0
...

@eschkufz
Copy link
Author

eschkufz commented Jan 4, 2013

Presumably by reading the code, just as they would have to if implore() were used.

@rfindler
Copy link

rfindler commented Jan 4, 2013

Believe it or not, my dissertation covered this ground. Here's our conference paper on the subject: http://www.eecs.northwestern.edu/~robby/pubs/papers/ho-contracts-icfp2002.pdf

@munificent
Copy link
Owner

I've actually read that paper! Well, it's probably more accurate to say I have that paper sitting in my folder of papers to read, but I'm at least familiar with. That counts for something, right?

@rfindler
Copy link

rfindler commented Jan 8, 2013

Sweet. But on second thought: just program in a little in Racket. :) Have a look at the contracts section of the Guide instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants