treatment of void and None and other special values - best practice?

12 views
Skip to first unread message

cam

unread,
Apr 13, 2013, 2:10:54 AM4/13/13
to utah-compiler...@googlegroups.com
When you desugar a language to an lir representation, I imagine the standard is to represent null and other such values in the host language's terms.

So for something like:

def f():
  pass

if f() is None:
  print("f is none")

python3 treats the return value of f() as None.

In the reference implementation, f() returns (void) and then 'is' does an eq? check with 'None which fails.

So instead of (define None 'None) as in the provided headers, is (define None (void)) a decent approach?

Another issue then is how to print out such values in the host language.  
For instance, should special values like None be translated from (void) to 'None inside py-print or from 'None to (void) in comparisons?

Matt Might

unread,
Apr 13, 2013, 8:16:57 AM4/13/13
to cam, utah-compiler...@googlegroups.com
Good question.

In this case, leave as is.

We'll say it's an error to use the value of a function which is never defined.

-Matt
> --
> 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.
>
>
Reply all
Reply to author
Forward
0 new messages