Skip to content

Add 'argument mode adapter' functions to std #1085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brson opened this issue Oct 28, 2011 · 4 comments
Closed

Add 'argument mode adapter' functions to std #1085

brson opened this issue Oct 28, 2011 · 4 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Oct 28, 2011

So we have a bunch of higher order functions, that usually take functions with generic, by ref parameters; then we have a bunch of standard utility functions in std::int etc that take their arguments by value.

Both those are the correct decisions individually, but they can't be composed together:

// no-worky
vec::foldl(int::sub, 0, [1,2,3]);

We could have a function that takes it's arguments by ref and calls another function by value:

fn cp_ref2<T, U, V>(&&a: T, &&b: U, f: block(+a: T, +b: U) -> V) -> V { f(a, b) }

With which you could

vec::foldl(bind cp_ref2(_, _, int_sub), 0, [1,2,3]);

If this is a good idea, then identify a bunch of useful scenarios and write these functions, maybe in std::util.

@brson
Copy link
Contributor Author

brson commented Oct 28, 2011

These little functions like uint::add, sub, eq, lt, etc. really only exist to compose with other functions. Maybe it would make more sense to have them take references.

@ghost ghost assigned brson Apr 12, 2012
@Dretch
Copy link
Contributor

Dretch commented Jun 1, 2012

IMHO:

vec::foldl({|a, b| int::sub(a, b)}, 0, [1,2,3]);

is prettier than:

vec::foldl(bind cp_ref2(_, _, int_sub), 0, [1,2,3]);

@brson
Copy link
Contributor Author

brson commented Jun 1, 2012

And with future syntax changes it will probably even be vec::foldl(|a, b| sub(a, b), 0, [1,2,3]). That's pretty good.

@brson
Copy link
Contributor Author

brson commented Jun 1, 2012

And argument modes are going away, so I think this can close.

@brson brson closed this as completed Jun 1, 2012
coastalwhite pushed a commit to coastalwhite/rust that referenced this issue Aug 5, 2023
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
* Make kani-verifier the root crate

* clean up after cbmc install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

2 participants