Skip to content

Conversation

@belmarca
Copy link
Collaborator

This draft proposes an implementation of sep and end keyword args in print statements.

Works on the online REPL, need to figure out how to test this functionality.

sep = rte_lookup_locals(rte, 'sep')
end = rte_lookup_locals(rte, 'end')

if not (om_isinstance(sep, class_str) or om_isinstance(sep, class_NoneType)):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's faster to do om_is(sep, om_None) since None is a singleton.

return sem_raise_with_message(ctx, class_TypeError, "end must be None or a string")

sep = OM_get_boxed_value(sep)
end = OM_get_boxed_value(end)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful, at this point, sep and end could be om_None in your code.

return loop(rte, 0)
else:
runtime_print('', rte)
runtime_print('' + end, rte)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runtime_print(end, rte) should do the trick

@omelancon
Copy link
Collaborator

I think we should also add tests

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

Successfully merging this pull request may close these issues.

2 participants