-
-
Notifications
You must be signed in to change notification settings - Fork 549
feat: Add generic length function, closes #3308 #3317
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
Conversation
|
Here are my thoughts: As it is a feature that I think will not need super heaviy testing it should be targeted at main. Feel free to add more useful functions. Please write a little less minimalistic description in the getting started. Especially examples are very useful and the description needs to be suitable for non programmers. If you say a function "lenght" gives the lenght, that is not super useful. You need to explain more basic, like "count of elements". |
|
@peternewman still there? |
That sounds very sensible, I'll pivot to that.
Great, I'll leave this targeted as is then.
I realised pop would need to return both the modified array (or modify it in place) and the item that was popped, I'm not aware of other functions working like that currently. Obviously push would be pretty easy.
Sorry, lazy copy/paste of the strlen thing.
Yeah sorry, just competing open source stuff and other commitments. |
|
@peternewman What's the state of this PR? Currently I see some failing tests and conflicts. v4 is around the corner and I'd be happy to have this PR included. |
I've managed to resolve the conflicts. I'm not sure what to do about the failing test though. As I mentioned in https://github.com/bitfocus/companion/pull/3317/files#r1981604888 it seems like it's a bug in unicode-segmenter or I'm not using it right or something? Do you have any suggestions?
Yes, me too. |
|
I've just had the thought, should this be considering unicode like this? so if you are doing something that combines So I think that short term this should not consider multi character unicode. |
Yes, it should. That is a valid grapheme.
|
|
@peternewman I found the issue with the count of 2 So you just need to adjust the test. |
|
Ah, I forgot there was Then my only request is that the docs should make it really clear which functions consider unicode correctly, and which ones are naive string versions |
Hmm, that feels a bit to me like the current rendering is broken (in the web-browser) and it should have shown it as
This seems to imply that slice isn't fully unicode compatible: There was mention of a unicode substring type tool elsewhere. I'm quite happy to implement slice if it actually works as we want with unicode.
I've attempted to improve on this. Let me know if we've got preferred terms for grapheme and byte that might be more user-friendly? I think I've caught all the other broken functions, but let me know if I've missed any. |
our substr function is using slice internally, so Im pretty sure it isnt. But we could expose a method called slice (or whatever) that uses some other implementation internally. |


Should this be targeted at main or develop?
Happy to hear other name suggestions, I've mirrored strlen for now.
I did wonder should I add push/pop at the same time (and possibly others...)