|
|
Subscribe / Log in / New account

From late-bound arguments to deferred computation, part 2

From late-bound arguments to deferred computation, part 2

Posted Aug 31, 2022 1:58 UTC (Wed) by tialaramex (subscriber, #21167)
In reply to: From late-bound arguments to deferred computation, part 2 by NYKevin
Parent article: From late-bound arguments to deferred computation, part 2

I think you've got muddled about From and Into, your description suggests we can take From<T> but I'm pretty sure we would actually write Into<FinalScore> instead

This is one of those mirror image situations, you should implement From<SoccerMatch> on your FinalScore type, but you don't write From<T> or From<SoccerMatch> in the function signature which eventually might need the score, you write what you wanted, Into<FinalScore> instead. We're going to have a line like:

score: FinalScore = Into::into(some_parameter);

... so you can see some_parameter's type needs to be Into<FinalScore> to match.

This is idiomatic for the iterators, hence IntoIterator but it would be unusual to ask for Into<FinalScore> rather than just FinalScore unless you'd specifically designed all of the API this way. As I understand it, what the deferred computation people want for Python is a type which does not require you to be explicit up front in this way.

And that's why I don't think either C++ or Rust fit the bill. They can explicitly do this, but they aren't really designed to be able to implicitly defer computation, everybody involved needs to agree up front to this arrangement.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds