when run with cps-header, should pycps catch exceptions not explicitly raised?

15 views
Skip to first unread message

cam

unread,
Apr 11, 2013, 3:01:14 PM4/11/13
to utah-compiler...@googlegroups.com
The following expression causes an exception without our code explicitly raising it:

try:
  y = (lambda x : x) / 1 # EXCEPTION: can't divide a lambda!
except:
  print("caught exception")

Should our lir/cps try handle this kind of an exception in the cps phase, or only raised exceptions?



Petey A

unread,
Apr 11, 2013, 3:03:52 PM4/11/13
to cam, utah-compilers-spring-2013
When I run it in python3, it catches the exception. This makes sense to me, too. I'd say you should catch _any_ exception raised while in a try block.


- Petey





--
You received this message because you are subscribed to the Google Groups "Utah Compilers, Spring 2013" group.
To unsubscribe from this group and stop receiving emails from it, send an email to utah-compilers-spri...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

cam

unread,
Apr 11, 2013, 3:20:38 PM4/11/13
to utah-compiler...@googlegroups.com
I agree that we should handle these kinds of exceptions to match python3, but how relevant is it that the lir and cps reference implementations choke on these non-raised exceptions?  Is this a {lir,cps}-header.rkt issue and not an emitted code issue?

Is the interpreted program responsible to catch exceptions that the interpreter throws?  Because the header tries to divide the lambda by 1, then chokes.  How can our emitted code handle the interpreter's exception?

Please correct me if I am thinking about this wrong.

Petey A

unread,
Apr 11, 2013, 3:25:24 PM4/11/13
to cam, utah-compilers-spring-2013
Have you run it through the reference desugarer? Does it do the same?


- Petey


cam

unread,
Apr 11, 2013, 3:45:44 PM4/11/13
to utah-compiler...@googlegroups.com
Yes, the reference desugarer also crashes.  



- Petey


To unsubscribe from this group and stop receiving emails from it, send an email to utah-compilers-spring-2013+unsub...@googlegroups.com.

Petey A

unread,
Apr 11, 2013, 3:50:36 PM4/11/13
to cam, utah-compilers-spring-2013
At this point, I'd recommend that you make a decision, document it in your README, and move forward. The reference differs from python3, so all bets are off - except that you can be pretty sure that you won't be graded on this disparity.


- Petey


To unsubscribe from this group and stop receiving emails from it, send an email to utah-compilers-spri...@googlegroups.com.

Matt Might

unread,
Apr 11, 2013, 6:27:10 PM4/11/13
to cam, utah-compiler...@googlegroups.com
Only worry about *explicitly* raised exceptions.

-Matt



On Thu, Apr 11, 2013 at 1:01 PM, cam <cams...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages