-
Notifications
You must be signed in to change notification settings - Fork 46
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
[Bug Fix] Refactoring of Mark
and Span
, and bug fix
#183
Conversation
`firstmark(token)` and `lastmark(token)`.
I've been merging all of the PRs that are small / obviously non-breaking. These big refactoring ones are going to take me a lot longer to get to. @GunnarFarneback if you can take a look, that would be awesome. Otherwise, just keep pinging me every couple of weeks if I don't get to it. @Paalon if you can also add notes about whether things are internal / part of the API, breaking or not, etc, that would be very helpful. As far as I can tell, this one is just cleaning up internal stuff? |
I don't see so much value in splitting The part I don't understand is the iteration protocol for |
I defined them only for |
Mark
and Span
, and bug fixMark
and Span
, and bug fix
Well, |
Is there any reason we can't just define |
We could but it wouldn't match the |
Fair point. And if this is part of internal machinery anyway, I don't think we should extend a base function in that way. Let's just use the properties explicitly. |
Julia Base exports """
first(coll)
Get the first element of an iterable collection. Return the start point of an
[`AbstractRange`](@ref) even if it is empty.
See also: [`only`](@ref), [`firstindex`](@ref), [`last`](@ref).
"""
function first(itr)
x = iterate(itr)
x === nothing && throw(ArgumentError("collection must be non-empty"))
x[1]
end So I think any method which equip x = iterate(itr)
x === nothing && throw(ArgumentError("collection must be non-empty")) is not required for |
I think we should avoid more than 2 dots to access a property (e.g. |
If we don't implement firstmark(span::Span) = span.start_mark
lastmark(span::Span) = span.end_mark
firstmark(token::Token) = firstmark(token.span)
lastmark(token::Token) = lastmark(token.span) will be fine. |
Mark
and Span
, and bug fixMark
and Span
, and bug fix
I think you're overestimating the badness of nested property accesses. I do agree that it's nice not to have
If you absolutely want to avoid a two-level property access you could also do
but to me it doesn't really improve anything. Adding a |
I removed iteration and indexing methods for
|
Mark
andSpan
to each source files.Span
.token.span.start_mark
tofirstmark(token)
.token.span.end_mark
tolastmark(token)
.token.start_mark
→firstmark(token)
token.end_mark
→lastmark(token)