Skip to content

Commit

Permalink
Update README.md (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipVinc authored Jun 17, 2024
1 parent b65779e commit d36c737
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,31 @@ Closest candidates are the following:
<function f at 0x7fd3a0235d30> @ /<ipython-input-2-c9f6cdbea9f3>:16
```


> [!IMPORTANT]
> Dispatch, as implemented by Plum, is based on the _positional_ arguments to a function.
> Keyword arguments are not used in the decision making for which method to call.
> In particular, this means that _positional arguments without a default value must
> always be given as positional arguments_!
>
> Example:
> ```python
> from plum import dispatch
>
> @dispatch
> def f(x: int):
> return x
>
> >>> f(1) # OK
> 1
>
> >> try: f(x=1) # Not OK
> ... except Exception as e: print(f"{type(e).__name__}: {e}")
> NotFoundLookupError: `f()` could not be resolved...
> ```
This also works for multiple arguments, enabling some neat design patterns:
```python
Expand Down

0 comments on commit d36c737

Please sign in to comment.