Skip to content

Conversation

@lewis6991
Copy link
Member

@lewis6991 lewis6991 commented May 1, 2022

Experiment/proof-of-concept for a suggestion in #18286


Allows typval strings to contain NUL bytes in order for them to carry Lua strings.

  • Add v_size to typval_T which when set to >-1 represents the size of the value. Currently only used for VAR_STRING in f_iconv.
  • Prevent the Lua->typval converter from turning Lua string's into typval Blob's. This was previously done because Lua strings can contain NUL bytes whereas typval strings cannot so convertion to Blob instead was needed to properly represent the object.
  • Wherever typval strings are constructed, make sure v_size is set to a sensible value.

Allows typval strings to contain NUL bytes in order for them to carry
Lua strings.
@github-actions github-actions bot added the lua stdlib label May 1, 2022
@lewis6991 lewis6991 changed the title DNM: sized typval strings DNM(experiment): sized typval strings May 1, 2022
@justinmk
Copy link
Member

justinmk commented May 2, 2022

Just for reference, another very interesting option we've discussed long ago, is to use SDS strings (or some similar thin string library) for all strings:

Rather than "all strings", introducing something like SDS only for Vimscript (initially) could be very feasible, because the lifetime of Vimscript strings is fairly simple: they get released when the typval gets destroyed. So we'd have little risk of a naive free() doing the wrong thing.

@lewis6991 lewis6991 closed this May 15, 2022
@lewis6991 lewis6991 deleted the sized_typval branch August 25, 2022 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants