-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Allow a Group's children to be null #32
base: main
Are you sure you want to change the base?
Conversation
Wouldn't an empty list make more sense then null? |
public readonly children: readonly Group[] | ||
public readonly start: number, | ||
public readonly end: number, | ||
public readonly children: readonly (Group | null)[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should I read this? A list of nulls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpkorstanje a list whose elements may be either null
or aGroup
object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use null
values in lists. That will be rather unexpected. If you do need something to represent the non capturing groups consider using the https://en.wikipedia.org/wiki/Null_object_pattern
I'm thinking that there may be some counting of groups going on. So replacing a non-capturing group with null doesn't make much sense and is bad programming (lists are usually free from nulls) So rather perhaps use |
What will change from user point of view? What kind of steps would be affected and how? |
That's an option, we can explore that. In that case I'd rename the current A We could make both Would you prefer this @mpkorstanje? |
I'd say that But more importantly, do we need the non capturing groups for anything? If not, could we perhaps leave them out of the list all together? |
That would be nice. I think we need the non capturing groups in order to provide I'll have to play around with it a bit. |
Description
Change the type of
Group#children
fromGroup[]
to(Group | null)[]
Motivation & context
Currently, it is possible for a
Group
object'svalue
,start
andend
fields to benull / nil / undefined
. This happens for optional capture groups.A
Group
object where all fields are absent isn't very useful, and I find it more intuitive that the entire group object is null.If there are no objections to this change I can update the other implementations.
Type of change
work as expected)
Checklist: