3 ms·
> “I find that there must be a balance where names are clear and unique enough while not tiring the eyes too much by making them read long boring repetitive pre
by AlbertoGP 4y ago
> “I find that there must be a balance where names are clear and unique enough while not tiring the eyes too much by making them read long boring repetitive prefixes all the time.”
I have that problem, repetitive prefixes getting in the way of reading the code, and I’ve been doing some experiments with what could be described as “local namespacing”, only inside an expression or statement, with the prefix/suffix feature of the backstitch macro in my C preprocessor:
https://sentido-labs.com/en/library/cedro/202106171400/#backstitch-macro https://sentido-labs.com/en/library/cedro/202106171400/#back...
For instance, writing a program with libxml2, I write:
Next(reader) @xmlTextReader...;
which gets translated to
xmlTextReaderNext(reader);
and I find the first easier to read.
Whether that’s the case for others, I don’t know.
A longer example from the link I wrote above, this time for libuv:
@uv_thread_...
t hare_id,
t tortoise_id,
create(&hare_id, hare, &tracklen),
create(&tortoise_id, tortoise, &tracklen),
join(&hare_id),
join(&tortoise_id);
Result:
uv_thread_t hare_id;
uv_thread_t tortoise_id;
uv_thread_create(&hare_id, hare, &tracklen);
uv_thread_create(&tortoise_id, tortoise, &tracklen);
uv_thread_join(&hare_id);
uv_thread_join(&tortoise_id);