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

Allow callouts written in Nim #12

Open
flaviut opened this issue Apr 22, 2015 · 2 comments
Open

Allow callouts written in Nim #12

flaviut opened this issue Apr 22, 2015 · 2 comments

Comments

@flaviut
Copy link
Owner

flaviut commented Apr 22, 2015

I have no thoughts about this at the moment, but it is something that should be considered.

@oprypin
Copy link
Collaborator

oprypin commented May 11, 2015

Some problems to consider:

  • Is it even possible to set C's global variable?
  • Setting a global variable sucks for thread safety. Mutex could help, within the bounds of NRE.
  • I think PCRE returns a pointer to the same (big) struct every time, just updated. Is the same level of performance possible to achieve?

More remarks:

  • This is a ton of work.
  • I've never seen such a feature in any language's regex wrapper/implementation.

I wanted to see an example, and it is nontrivial, so here is one: http://www.tek-tips.com/viewthread.cfm?qid=745925

@flaviut
Copy link
Owner Author

flaviut commented May 12, 2015

Setting a global variable sucks for thread safety. Mutex could help, within the bounds of NRE.

That variable should only be set once at the beginning of the program. pcre_extra contains a void *callout_data; field, which could contain the pointers to the callout code. pcre_callout_block wouldn't contain the actual callouts, it'd use callout_data.

This is a ton of work.

yep.
I'm going to need to figure out how Nim does closures and how to create closures from strings in macros. I'm also going to have to figure out how to store the closure data in the right place and so on.

Even parsing the code might be a challenge... (?{foo("}")})?
Templating libraries might find that code useful -- perhaps I should extract it into it's own lib?

I think PCRE returns a pointer to the same (big) struct every time, just updated. Is the same level of performance possible to achieve?

The struct isn't that big though, it's 52 bytes on a 64 bit machine (if I didn't screw up counting). I don't understand what you're saying in "Is the same level of performance possible to achieve?"

I've never seen such a feature in any language's regex wrapper/implementation.

s/any language/any non-dynamic language/
It's always nice to be the first.

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

No branches or pull requests

2 participants