Time Nick Message 00:57 MTDiscord imi couldn't is_digit compare against a table that holds a bunch of strings in which are numeric in value or regex via local number_chars = {"0","1","2","3","4","5","6","7","8","9"} then just do a function is_digit(c) for _,char in ipairs(number_chars) do if c == char then return true end end return false end? 05:37 pgimeno that parse file needs some work to avoid generating too much garbage 05:37 pgimeno it should be using pointers instead of creating new strings 05:38 pgimeno as for is_digit, c >= "0" and c <= "9" is definitely faster than about any other alternative, although it assumes that c is exactly 1 byte long (which is a reasonable assumption in this context) 06:46 MTDiscord just use Lua patterns 07:15 pgimeno Lua patterns are too powerless for many parsing operations 10:07 MTDiscord agreed 10:08 MTDiscord yet they can very well be used to for example detect whether something is a digit, or extract a string of digits 10:08 MTDiscord typically the "workaround" is to use overly permissive patterns, then leave further validation to the Lua code 10:08 MTDiscord for example using an overly permissive float pattern, then using tonumber to check whether it is indeed a valid number 10:10 MTDiscord imi's code can be rewritten to be more readable and more efficient using patterns, while exactly preserving functionality 10:17 imi hi, this would be a pretty useful chatcmd_parse_coords function to make chatcommands handle coordinates in an uniform way: https://onecompiler.com/lua/3zbcseyh7 what do you think? 13:17 pgimeno imi: there's been some discussion while you were away, please look at https://irc.minetest.net/minetest-dev/2023-06-12#i_6090627 until you joined again 13:26 imi https://www.lua.org/pil/20.2.html as far as I can tell this is a slightly extended regexp 14:16 pgimeno patterns are definitely less powerful than regexps 14:17 pgimeno e.g. you can check if a date is valid with a regexp, but not with a pattern 15:01 MTDiscord imi, pgimeno: patterns are both less powerful (no alternation & grouping, only capture groups) and more powerful (bracket matching) than regex 15:36 imi ok, next versin of my code: https://onecompiler.com/lua/3zbde65gd 19:17 pgimeno er, when looking up what the tilde notation does in lua_api, I saw that no one seemed to notice that in markdown, the tilde is used for strikeout 19:17 pgimeno sorry that I can't open an issue 19:18 pgimeno not sure if this link will work: https://github.com/minetest/minetest/blob/master/doc/lua_api.md#user-content-helper-functions 19:19 pgimeno in the explanation of string_to_area