Issue with keyword arguments #20

Open
opened 2021-07-06 11:09:16 +08:00 by pca006132 · 4 comments
Collaborator

Consider the following simple demo:

>>> def foo(x, y):
...     print((x, y))
... 
>>> def bar(y, x):
...     print((x, y))
... 
>>> a = foo
>>> a(1, 2)
(1, 2)
>>> a(x=1, y=2)
(1, 2)
>>> a = bar
>>> a(1, 2)
(2, 1)
>>> a(x=1, y=2)
(1, 2)

Keyword arguments is a bit problematic... Maybe restrict to global functions and non-virtual object methods?

Consider the following simple demo: ``` >>> def foo(x, y): ... print((x, y)) ... >>> def bar(y, x): ... print((x, y)) ... >>> a = foo >>> a(1, 2) (1, 2) >>> a(x=1, y=2) (1, 2) >>> a = bar >>> a(1, 2) (2, 1) >>> a(x=1, y=2) (1, 2) ``` Keyword arguments is a bit problematic... Maybe restrict to global functions and non-virtual object methods?
Owner

What is the problem here exactly?

What is the problem here exactly?
Author
Collaborator

Keyword argument may require runtime resolution if we don't know the function statically, which is the case for function pointers and virtual object methods.

Keyword argument may require runtime resolution if we don't know the function statically, which is the case for function pointers and virtual object methods.
Collaborator

My immediate reaction here is that argument names would need to be part of the function pointer type (which would be a subtype of the same un-named signature).

My immediate reaction here is that argument names would need to be part of the function pointer type (which would be a subtype of the same un-named signature).
Owner

Yes, we are going to do that.

Yes, we are going to do that.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3-spec#20
No description provided.