Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pop, drop & get with basic range feature for stringlist#514

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
aman-godara wants to merge22 commits intofortran-lang:master
base:master
Choose a base branch
Loading
fromaman-godara:delete-stringlist

Conversation

aman-godara
Copy link
Member

@aman-godaraaman-godara commentedSep 6, 2021
edited
Loading

Delete function tostdlib_stringlist

Tasks:

@aman-godara
Copy link
MemberAuthor

delete function vsremove function?

delete functions returns the deleted element.
remove function does same job as todelete function but doesn't return the deleted element.

Any suggestions on better naming convention? Should I rather calldelete aspop and think of a better name forremove?

@epagone
Copy link

This is highly subjective but FWIW, I would preferpop for the functions that return the deleted element, simply because I imagine that if I "pop" something out I still have it with me.

For the function that doesnot return the deleted element I am fine with bothremove ordelete, with a slight preference fordelete.

Did you have any time to see what are the choices of other languages for similar functions?

@aman-godara
Copy link
MemberAuthor

Python usespop (returns deleted item) andremove (no return)
Java doesn't have any function equivalent ofpop (or atleast I couldn't find one), it hasremove function (no return).

pop function is used whenever deleted item is returned, otherwiseremove anddelete functions both are used by programming languages. Though, I could find only one occurrence wheredelete was used to remove elements.
Also, some languages usespop() (with no arguments) as a way to allow a user to make alist behave like astack or aqueue.

epagone reacted with thumbs up emoji

@arjenmarkus
Copy link
Member

arjenmarkus commentedSep 7, 2021 via email

How about get_and_remove or get_remove? That makes the function completelyclear, albeit via a more verbose name.Op di 7 sep. 2021 om 15:29 schreef Aman Godara ***@***.***>:
Python uses pop (returns deleted item) and remove (no return) Java doesn't have any function equivalent of pop (or atleast I couldn't find one), it has remove function (no return). pop function is used whenever deleted item is returned, otherwise remove and delete functions both are used by programming languages. Though, I could find only one occurrence where delete was used to remove elements. Also, some languages uses pop() (with no arguments) as a way to allow a user to make a list behave like a stack or a queue. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#514 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAN6YR7NQ6N7APHXMGEGK4LUAYHTBANCNFSM5DQYEJAQ> . Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.

@awvwgk
Copy link
Member

I thinkpop is a reasonable name to a procedure to remove and return the removed element. For only deleting elements,delete,remove ordrop might be suitable. The namesdelete anddestroy could be associated with a deconstructor of the entire list.

epagone reacted with thumbs up emoji

@epagone
Copy link

Based on my experience with past discussions, we are trying to provide a familiar interface to the user ofstdlib following well-established conventions from other languages (like python, for example).@arjenmarkus suggests more "Fortranic" names (that I like too) but they might be inconsistent with other parts ofstdlib.

Based on the other suggestions, my preference is

  • pop: removes and returns the removed element
  • drop: removes an element without returning it
  • destroy: de-constructs the list and frees the memory

I do not have strong opinions on this, though.

awvwgk reacted with thumbs up emoji

@aman-godara
Copy link
MemberAuthor

I agree withdestroy (please note that we have a function namedclear instdlib_stringlist which resets the list and NOT destroys it). Checkout this example frompython to understand the difference:

image

epagone reacted with thumbs up emoji

@aman-godara
Copy link
MemberAuthor

aman-godara commentedSep 12, 2021
edited
Loading

I added a basic range feature topop anddrop which will remove all strings at indexes in the interval [first,last].
Out of bounds indexes in this interval will be ignored. There is no concept ofstride currently in this range feature.

We can discuss the behaviour of non-basic range feature forpop anddrop.

I think atleast a basic range feature should be added toget function as well, it will also improve the waypop_engine function is written.

@epagone
Copy link

epagone commentedSep 13, 2021
edited
Loading

Thank you.

I personally don't like that out of bounds indexes are ignored: I'd like to be notified (at least with a warning, if not by an error) in these cases. Based on my experience, out of bounds indexes are the consequence of upstream bugs that would be difficult to identify, if ignored. However, I believe that a choice in this sense might have been already made during the initial implementation ofstringlist for other methods.

I think atleast a basic range feature should be added toget function as well, it will also improve the waypop_engine function is written.

Good point, I agree.

@epagone
Copy link

I am under the impression that adding theget function (although, as I said, it's a good idea) is out of scope for this PR. Am I right?

@aman-godara
Copy link
MemberAuthor

I am under the impression that adding theget function (although, as I said, it's a good idea) is out of scope for this PR. Am I right?

Yeah, that's right. Let me rename PR.

@aman-godaraaman-godara changed the titleDelete stringlist & move subroutinepop, drop & get with basic range feature for stringlistSep 17, 2021
@awvwgkawvwgk added reviewers neededThis patch requires extra eyes topic: stringsString processing labelsSep 18, 2021
@aman-godara
Copy link
MemberAuthor

This PR is blocked by:#552

get_engine func takes an integer stride_vector which decides the numberof strides to take between indexes.get_range_idx func takes stride of type stringlist_index_type:   fidx(+3) means takes +3 as stride (jump 3 indexes to right)   fidx(-3) means takes -3 as stride (jump 3 indexes to left)   bidx(+3) means takes -3 as stride (jump 3 indexes to left)   bidx(-3) means takes +3 as stride (jump 3 indexes to right)
get_impl comes in the middle of get_engine and get_idx routinesThis allows to get i-th element inside the module using integer indexes
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@epagoneepagoneepagone left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
reviewers neededThis patch requires extra eyestopic: stringsString processing
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@aman-godara@epagone@arjenmarkus@awvwgk

[8]ページ先頭

©2009-2025 Movatter.jp