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

Functional notation? #2

Open
littledan opened this issue Apr 3, 2017 · 5 comments
Open

Functional notation? #2

littledan opened this issue Apr 3, 2017 · 5 comments

Comments

@littledan
Copy link

Pre-allocating an additional object for each RegExp match, when existing code does not use it, is likely to have some performance cost. Would it be OK to instead have an .offset() method (or start and end methods) on match objects, or is this too unergonomic?

@ljharb
Copy link

ljharb commented Apr 3, 2017

Can the engine not invisibly lazily allocate the array?

@littledan
Copy link
Author

@ljharb Other lazy things that have been specified as such explicitly (e.g., the bound function in Intl methods) ended up not being implemented efficiently enough in some engines, and then libraries like Intl.js cached the result. I'd like to avoid this complexity in the future and do things more directly. Is a method that un-ergonomic here?

@ljharb
Copy link

ljharb commented Apr 3, 2017

Not that bad I think - but it's not an expensive operation, and I'd expect the result to be memoized - this seems like a lazy getter that replaces itself with a data property might be helpful?

@littledan
Copy link
Author

This just sounds really complicated. What's the issue with a method?

@ljharb
Copy link

ljharb commented Apr 3, 2017

I don't think it's a big issue; it just seems weird.

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

No branches or pull requests

2 participants