Skip to content
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

Implement ring map #9

Closed
wants to merge 6 commits into from
Closed

Implement ring map #9

wants to merge 6 commits into from

Conversation

waringa-mercy
Copy link

@rand00 i have made some progress but still experiencing some errors. monday being the deadline for submission and application kindly guide me on how to solve the errors. i have included comments on what each each part is supposed to do

@rand00
Copy link
Owner

rand00 commented Mar 31, 2023

I guess it is issue #2 you are trying to solve?

The code expected would be the definition of Ring.map_rev_shortcircuit, which is not what this PR proposes.

As I wrote on the issue, it would be useful to have a look at the existing Ring.fold_left, which I expect is okay close to what is needed for map_rev_shortcircuit

@waringa-mercy
Copy link
Author

@rand00 i have made a few changes. Due to the limited time i have, kindly bear with the very many follow up questions i will ask

@waringa-mercy
Copy link
Author

@rand00 I took the time to study the pointers you gave and came up with a potential solution. kindly review and advice Asap. to day being the deadline for application, I would kindly request to to fill out as accepted and if there are any changes, i will keep working till acceptable.

Copy link
Owner

@rand00 rand00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your latest changes looks good (: You have come very close to something I expect will work

lib/conntest.ml Outdated
@@ -347,7 +347,34 @@ module Make
.. and ring shouldn't be long
*)
Log.debug (fun m -> m "feed_source: packet_index_diff < 0");
(*latest*)
let map_rev_shortcircuit f ring =
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be inside the Ring module

lib/conntest.ml Outdated
(*latest*)
let map_rev_shortcircuit f ring =
let len = Ring.length ring in
let new_ring = Ring.copy ring in
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no Ring.copy

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to get the code compiling before committing. When you have all this code which doesn't compile, it also seems suspicious concerning the code looking generated by an AI

lib/conntest.ml Outdated
let map_rev_shortcircuit f ring =
let len = Ring.length ring in
let new_ring = Ring.copy ring in
let start = Ring.get_start ring in
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no Ring.get_start

lib/conntest.ml Outdated
match Ring.wrap_reverse_i len (i + 1) with
| None -> ring_acc
| Some i' ->
if i' = start || match Ring.get i' new_ring with
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is bad style to make such a big expression inside an if

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. i.e. the code is not very readable

lib/conntest.ml Outdated
| Some v -> match f v with
| None -> true
| Some v' ->
let new_ring' = Ring.set i' v' new_ring in
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no Ring.set - Ring.t is intended to be an immutable datastructure

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. though it is also used as such. It would not be ordinary naming of a function for an immutable datastructure.

lib/conntest.ml Outdated
then ring_acc
else loop i' ring_acc
in
let start_i = Option.map_default (fun x -> x - 1) (len - 1) (Ring.wrap_reverse_i len start) in
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no Option.map_default - all this code looks AI generated. Please see mirage/mirage#1402 (comment)

match idx_opt with
| None -> i := len
| Some idx ->
let value_opt = Ring.get_previous r !i in
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ring.get_previous also calls wrap_reverse_i, so there is some duplicate logic here.

| Some idx ->
let value_opt = Ring.get_previous r !i in
match value_opt with
| None -> i := len
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function shouldn't shortcircuit if the Ring contains None on the current position

@waringa-mercy
Copy link
Author

@rand00 kindly ignore my previous commit with the message progress with errors. i tried deleting it without much success. my latest commit compiles successfully

@waringa-mercy waringa-mercy deleted the implement_ring_map branch April 3, 2023 09:05
@rand00
Copy link
Owner

rand00 commented Apr 3, 2023

If you intend to continue work on this, then please don't close the PR and start a new one - continue on this PR

@waringa-mercy
Copy link
Author

@rand00 sorry, already did. should i continue on this one or the other one? i felt like my latest changes were being lost in the middle or the erroneous code i commited three days ago when i was stuck and needed some guidance.

@waringa-mercy
Copy link
Author

@rand00 can we please proceed in my latest pull request? i have made a few changes already plus i already deleted locally.

@waringa-mercy
Copy link
Author

@rand00 I have attempted to restore the branch i deleted without success since i deleted both locally and remotely. I do not know how to proceed.

@rand00
Copy link
Owner

rand00 commented Apr 3, 2023

In that case continue with the new PR

@waringa-mercy
Copy link
Author

@rand00 Thank you. Honestly i was feeling really demoralized. On friday i was so worried about the deadline that I was trying anything that was even remotely close to what was expected just to submit.Then the weekend came and i knew you would not be available to help. The moment i calmed down and had a deeper look at the code itself, it all became so clear. I already pushed new changes. Review them and let me know if anything more needs to be added. The deadline up now, so now is a learning phase

@rand00
Copy link
Owner

rand00 commented Apr 3, 2023

Sounds like you had good mental progress on it (:

@waringa-mercy
Copy link
Author

waringa-mercy commented Apr 3, 2023

@rand00 I did. I went back to the first code i posted where you told me i was a good try. Looked at the recommendations and that helped a lot. This is a learning period, even if i dont get picked for the internship, no regrets. In the end, i have to struggle till I get it right. AI might be useful in essays and what not but when it comes to writing code, a complete joke.

@waringa-mercy
Copy link
Author

@rand00 if there are any other good issues, I would love to keep contributing. Without the burden of looming deadline, I will revel in the challenge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants