ThePhD / future_cxx

Work done today for the glory of tomorrow - or, C and C++ systems programming papers.
https://thephd.dev/portfolio/standard
46 stars 8 forks source link

N3022 - Modern Bit Utilities #39

Closed ThePhD closed 2 years ago

ThePhD commented 2 years ago

New paper. No number yet. https://thephd.dev/_vendor/future_cxx/papers/C%20-%20endian.html

ThePhD commented 2 years ago

Paper number N2827.

Let's do this. https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Modern%20Bit%20Utilities.html

h-vetinari commented 2 years ago

There's a typo in the wording (double s):

int stdc_leading_onessuc(unsigned char value);

Ones may indeed suck, but it got me thinking - why not expend one extra underscore and avoid all these super-awkward final words? I.e. stdc_count_zeros_uc vs. stdc_count_zerosuc stdc_rotate_left_ull vs. stdc_rotate_leftull stdc_bit_floor_us vs. stdc_bit_floorus etc.

ThePhD commented 2 years ago

It's done strictly out of trying not to be as inventive with how suffixes are done in the C standard. I'm already pushing stdc_ so I might as well ask the committee if I can add the underscore there since it looks better.

ThePhD commented 2 years ago

Oh my god why did I close this.

ThePhD commented 2 years ago

Benchmarks, implementation, latest revision:

https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Modern%20Bit%20Utilities.html https://ztdidk.readthedocs.io/en/latest/benchmarks/bit.html

h-vetinari commented 2 years ago

Is the additional underscore before the type still a possibility? I guess it missed the train for the newest publication?

ThePhD commented 2 years ago

We don't have the underscore before the type because it's not how other functions in the C standard do it. I also think we actually may exceed the 31-character limit for a unique function in exactly one case if we do that, but I need to count the characters again to be super sure...

h-vetinari commented 2 years ago

From what I can tell, it wouldn't be longer than 31:

>>> raw = ["_".join([x, y, z]) for x in ["count", "first"] for y in ["leading", "trailing"] for z in ["ones", "zeros"]]
>>> full = [f"stdc_{r}_ull" for r in raw]  # <- using extra underscore before type
>>> from pprint import pprint
>>> pprint({f: len(f) for f in sorted(full)})
{'stdc_count_leading_ones_ull': 27,
 'stdc_count_leading_zeros_ull': 28,
 'stdc_count_trailing_ones_ull': 28,
 'stdc_count_trailing_zeros_ull': 29,
 'stdc_first_leading_ones_ull': 27,
 'stdc_first_leading_zeros_ull': 28,
 'stdc_first_trailing_ones_ull': 28,
 'stdc_first_trailing_zeros_ull': 29}
ThePhD commented 2 years ago

Ah, okay, that was only before I had changed to better names.

Still haven't asked the Committee yet, maybe I'll pop ask in a meeting or just ask during the Meeting, if they accept the paper at all.

ThePhD commented 2 years ago

N2903. https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Modern%20Bit%20Utilities.html

ThePhD commented 2 years ago

Next revision: https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Modern%20Bit%20Utilities.html

h-vetinari commented 2 years ago

Still haven't asked the Committee yet, maybe I'll pop ask in a meeting or just ask during the Meeting, if they accept the paper at all.

I know things are getting tight but just wanted to recall this point here. 🙃

ThePhD commented 2 years ago

Oh crap, you're right. I need to make this a question.

ThePhD commented 2 years ago

Question added: https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Modern%20Bit%20Utilities.html#wording-decisions-q2

ThePhD commented 2 years ago

Partially delayed until C???.