-
Notifications
You must be signed in to change notification settings - Fork 160
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
New function for maps/regexps #437
Conversation
For Makefile: it's actually intended the way it is atm, I don't think you should add paths outside of the current directory for security reasons, as it might load untrusted binaries with privileges without notice. For Maps : I understand the need to have the size but I don't think we will add it to Haxe, because some platforms will have a very costly size() implementation, and knowing a Map size is in general not very useful. |
Not only is knowing the size of a map helpful sometimes, but I cannot think of any platform where the implementation would be costly whatsoever outside of AS3, which is irrelevant because it's going to be dead in 2 days anyways. As for the Makefile, there are about half a dozen open issues about Linux users have trouble installing Hashlink, so I don't see how the current setup is working as intended. |
Also for reference, this is how you would get the size of a Map on other targets:
"Very costly"? It's actually the result of the devs not knowing enough about Haxe's various targets (which doesn't make sense because they implemented them?) |
I fail to see in which case... but sure why not.
And you just list afterward that it's costly on JS, which is one of the main platforms, and most likely Lua as well. |
I said the the current JS implementation using As for Lua, it's not a Haxe issue, but actually a Lua issue. Iterating through all the table's entries using the
Quite the opposite actually. According to the MDN docs:
|
And that's exactly why we don't want to have count() on Map because of the discrependencies between platforms, some have 0 cost for the count and some requiring expensive operations. Regarding JS: we used benchmarks across several browsers for that choice |
Maybe those benchmarks are out of date? Not sure if it's representative at all due to the large map size, but here a |
Any updates on this? |
Please remove the Makefile change so I can merge the primitives. |
Done |
So for starters, I fixed the installation issue on Linux that everyone seems to be complaining about.
Secondly, I added 2 (technically 4) functions to the builtin stdlib, which is step 1 of several for a PR that I'm working on for Haxe.
The functions are as follows:
hisize
/hbsize
/hosize
: Return the number of entries in the map.regexp_matched_num
: Return the number of matched groups from the last time a regexp was matched.