[pypy-dev] Returning a "default value" for a Rtyped function

Timothy Baldridge tbaldridge at gmail.com
Thu Apr 19 19:01:38 EDT 2018


I have a function in RPython that returns a tuple, and based on different
situations, one value or the other may "null":

def decide(x):
  if x:
    return 42, None
  else:
    return 0, Object("some value")


Here's the issue, this function is part of some meta-programming and is
auto generated. So the issue is, when I return `0, Object("some value")` I
really don't know what the first member of the tuple is, I want it to be
some value, and it can be anything since the calling function is
dispatching on the second value of the tuple being None (or not).

Is there some sort of way in rpython to say "return any value that fits the
type expected here?"

Or perhaps there's some better way to do a tagged union of sorts in
rpython.

Thanks,

Timothy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20180419/ddea5008/attachment.html>


More information about the pypy-dev mailing list