On Sat, Jun 24, 2023 at 3:16 PM Ondrej Zajicek <santiago@crfreenet.org> wrote:
On Sat, Jun 24, 2023 at 02:20:03AM +0200, Alexander Zubkov wrote:
Yes, the original idea there was to add bytestring as a data type, make hex() a regular (filter) function instead of special function-like syntax, and add equivalent of 'expr' grammar term for other data types.
I see. I think I can look into preparing a patch for that too. But for such variant I would suggest using function names like "from_hex/base64" instead of "hex/base64", or something including bytestring reference: "bs_hex". Because the simple variants could be misleading when used not only in the limited set of scopes. they can be thought of converting to hex/base64 representation too. Or they could collide with "hex" function to convert from string to int, which someone would need to implement in the future.
Yes, that is true.
You can try it if you are brave enough to add new f_val type.
Take a look at the patch, please. Waiting for the critics and improvement suggestions. Some remarks: It was needed to add another function like f_eval_int(), so I decided to do some more generic approach and replaced all occurences of f_eval_int() with it. Bytestrings for password caused conflicts with strings on being presented as symbol names. Insted of adding something like "string_or_bytestring", I decided to allow bytestring term to be derived from strings too. I also used different approach from "expr", where it evaluates only complex expressions. I decided that handling constants and symbols via evalutation would be easier. So I have special case only for literals. There is separate "term_bs" term, so that it is possible to use "from_hex()" without outer brackets. Again, added a new file in lib dir for bytestrings. And I changed some struct bytestring pointers to const struct bytestring.
I think this should be quite good too, the only problem with it is inability to mix "hex" symbol with hex("...") bytestrings.
This is an issue with any keyword, so not a big thing.
Yes. By the way what do you think about the patch that allows using keywords and symbols together? Is it viable?
Answered there.
-- Elen sila lumenn' omentielvo
Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."