Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This is to propose using P-Strings (Pascal-Strings) as the standard string format.
- === Benefits of using P-Strings ===
- * Accessing the length of the string is O(1) fast.
- * Buffer overflows are prevented by being able to allocate enough space ahead of time.
- ** This also decreases the risk of code injection into the program.
- * 0 can be used in strings, while a 0 in C-Strings would terminate the string.
- * Concat for P-Strings is O(n). Concat for C-Strings is O(n+m)
- === Disadvantages of using P-Strings ===
- * Indexing would begin at 1, instead of the conventional 0
- * Even on fixed-length fields, the first byte would be needed for the length
- === Other notes ===
- * Having a limit of 255 chars for a string is reasonable for the DCPU. Therefore, P-Strings are no more expensive than C-Strings.
- * Cutting off the beginning of a string is more expensive for P-Strings, but cutting off the end is more expensive for C-Strings. Therefore, those two arguments negate each other.
- The advantages of P-String outweigh the disadvantages. Therefore, I propose to use P-Strings as the String Format Standard.
Add Comment
Please, Sign In to add comment