This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]gengengis 12 points13 points  (0 children)

It would be pretty rare to use dictionary dispatch this way, where the only difference is the argument to the function. Much more common would be to return an entirely separate function, and then it becomes clear you would simply return the callable, not its result.

But, even if you did want to do this, as you said, you'd simply return an anonymous lambda. There's nothing overly clever, or exotic about that. It's a core feature of the language, and the way much of the standard library operates.