c3c icon indicating copy to clipboard operation
c3c copied to clipboard

[STD-LIB] DString has a few confusing method names

Open BWindey opened this issue 1 month ago • 2 comments

The current DString implementation inside the standard library has the following methods:

fn void DString.append_chars(&self, String str);
fn void DString.append_string(&self, DString str);

Based on the name however, one would think that append_chars takes in a char[], and append_string takes in a String. This is not the case currently; furthermore, a char[] cannot implicitly convert to a String.

The current situation is a bit confusing, and I would propose changing the names:

  • append_chars(String str) => append_string(String str)
  • append_string(DString str) => append_dstring(DString str)

Maybe append_chars could stay and take in a char[] instead, but from Discord I gathered that might not be preferred due to String adhering to UTF8 and char[] not really, so mixing them might not be a good idea.

I made a branch myself with the above proposal, but the deprecation path is unclear, as there are overlapping names between the old and new proposed names: https://github.com/c3lang/c3c/compare/master...BWindey:c3c:dstring_append

BWindey avatar Nov 16 '25 13:11 BWindey

For what it's worth, I think this is a good proposal

A clean and intuitive syntax is crucial for feeling joy when using a programming language, and therefore, also for adoption :)

aneiosi avatar Nov 16 '25 13:11 aneiosi

New names: append_string, append_dstring, append_bytes. Using append_string for dstrings will work, but is deprecated. Try it out please

lerno avatar Dec 16 '25 21:12 lerno

Ping

lerno avatar Dec 20 '25 15:12 lerno

Thanks! Is perfect.

BWindey avatar Dec 21 '25 15:12 BWindey