Skip to content

Conversation

yaxu
Copy link

@yaxu yaxu commented Nov 3, 2024

image

Implements bitfields:
https://forum.algorithmicpattern.org/t/bytebeat-tixyland-and-other-functions-of-time/396

Inspired by their visual similarity to some weaving patterns:
https://forum.algorithmicpattern.org/t/weaving/359/2?u=yaxu

Warning, this uses eval(), so shouldn't be merged until the input validation is verified as safe. Otherwise folks might run untrusted javascript in their browser by loading a pattern shared by an evil weaver, who then might sabotage their saved drafts!

@yaxu yaxu marked this pull request as draft November 3, 2024 12:14
@yaxu yaxu marked this pull request as ready for review November 3, 2024 16:25
@yaxu
Copy link
Author

yaxu commented Nov 3, 2024

The regex might be enough to make this secure now.. Could be better though, e.g. with useful parse errors.

@yaxu yaxu changed the title Experimental bitfield feature (warning - has security implications!) Experimental bitfield feature Nov 3, 2024
@yaxu
Copy link
Author

yaxu commented Nov 4, 2024

Now redone with mathjs expressions https://mathjs.org/docs/expressions/parsing.html

I just had to hack ^ to be parsed as ^|, as mathjs uses that for the bitwise 'not' used a lot in bitfields.

(With thanks to zspotter@mastodon.social )

@Devendork
Copy link
Member

Devendork commented Sep 9, 2025

Hey @yaxu
I'm in the process of integrating pull requests (late - sorry!) and would love to include this! If I'm understanding the thread correctly does the current implementation use the parsing regex for safety already or is that something I should look into more deeply when I merge it?

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

Successfully merging this pull request may close these issues.

2 participants