Coder Social home page Coder Social logo

future_cxx's Introduction

Hey there! 🎉

My name is JeanHeyd Meneide. I am a Software Engineer and the Project Editor for ISO/IEC JTC1 SC22 WG14 - Programming Languages, C.

You can find me at:

Recent Posts 📋

What I Do ✍

I make the fastest things go faster, the unsafe things much safer, and the difficult things easy to do!

I specialize in ergonomic library design, performance tuning, foreign function/language interfaces, and a little bit of graphics programming. My favorite work includes programming that enables even the newest programmers to produce high-quality code that pushes them and others towards the pit of success! Occasionally, I get stuck in a Network Programming loop 💫!

I also do Diversity and Inclusivity work in the technical space, working towards making a better and more equitable environment for everyone's contributions.

Need Something Done? ✔

Please reach out to these folks if you need something done as a dedicated project!

Business Inquiries

If you need something more than that, feel free to reach out to Shepherd's Oasis! You can find them in various places, such as:

future_cxx's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

future_cxx's Issues

p1301 - [[nodiscard("should have a reason")]] for Pre-Kona C++20

This was discussed on a reflector mailing list post. But the discussion was not "is this useful", it was "we want this now and here are all the crazy things we can do with it in the standard like demanding implementers put this specific text in it!!!".

We also had people specifically saying they want it, but that mandating the actual text is a step too far. I take that as violent agreement that this is a good thing.

Onward, for C++20.

p1682 - std::to_underlying for C++23

This is a new paper from Template Rex about adding a small utility function std::to_underlying in the Standard. He sent me the motivation so I need to clean up the paper that is already present.

pXXXX - Rewarding C++ Intuition with Function Evaluation Order

This paper is an ambitious fight to take down the last-resolved-in-plenary Gridlock of Argument Evaluation Order for function calls.

Timeline to start is 2 years from today, February 24th, 2019.

May my hands be blessed by the Lord, and my words reach a level of cunning than the spells of the C++ Bruja.

p1132 - std::out_ptr for Pre-Kona C++20

std::out_ptr is ready to go as a paper, but the implementation in Boost is going to stall until post-Kona. We already have a preliminary implementation in https://github.com/ThePhD/phd.

Some things I should do:

  • Add a section discussing temporary lifetime extension for flow control statements (if, while, for, etc.)

Possible typo: undesirable => desirable

Using this initialization syntax, even with different `ftrivial-auto-var-init={whatever}` flags, the behavior is stable: the **entire** union is zero-written. In this case, `foo()` is never called. This proposal's previous iterations replicated this behavior, as it was thought to provide better reliability and security semantics. Note that a user can always fall back to using `= { 0 }` if leaving other non-overlapping values in a union is undesirable. This does mean that one can, technically, tell if something was initialized with either `= { 0 }` or `= { }`, which somewhat contradicts the premise of the paper (that `= { 0 }` and `= { }` are identical).

Hello!

I am a huge fan of your work and, especially, this paper. I was reading through it tonight and think that I spotted a very, very minor typo. In the line reference above you say,

Note that a user can always fall back to using = { 0 } if leaving other non-overlapping values in a union is undesirable.

The way that I understand the point you are making, it would seem that undesirable there should be desirable. Again, the way I read it, you are making the point that a programmer may want to leave the bytes between the end of the first union element and the largest union element uninitialized for some reason. The proposal (ie, using ={}) would negate the programmer's intention and you are saying that they could always use = { 0 } if they wanted the "helpful" behavior.

I hope that this is a helpful comment and that I am not misunderstanding you. Either way, keep up the great work!

Will

cXXX9 - __supports_literal

This paper is meant to help move us beyond some of the intmax_t issues we have with the preprocessor. It is also meant to give C and C-derivative implementations a way to advertise special literal types.

p1664 - reconstructible_range and ranges::reconstruct Extension Point

The same paper as #20, but it needs to be redone to stick it to the fact that string_view is the only string view type it works with, and that it'll exclude Niall Douglass's io_span and similar.

This is because we hard-coded string_view, span, and other types directly into the "reduce template bloat" paper from Hannes Hauswedell. This was a compromise, and absolutely the wrong decision.

p1378: Errors in std::basic_string_literal<CharType, N>::size()

Hello, I read the P1378 paper and I believe I found an error in the [support.stringlit] section where the size method is defined:
N is the template parameter defined as the size of the string including the null terminator, so I believe the size() method in meant to return N-1 instead of N for coherency with other string types and post condition given in the default constructor "Ensures: size() == 0 and *end() == '\0'." where N has to be 1 for arr to be able to hold '\0' but size() is expected to return 0.

ps: I don't know if opening a github issue is the way to report errors as I'm not used to it, let me know if it is not the case.

n3031 - Restartable Functions for Efficient Character Conversions

There are a lot of functions that should be proposed for the C Committee's Unicode support. Specifically, we need:

  • mbs[r]toc[8,16,32]s, 6 functions
  • c[8,16,32]s[r]tombs, 6 functions
  • wcs[r]toc[8,16,32]s, 6 functions
  • c[8,16,32]s[r]towcs, 6 functions

This is too much to propose at first, and does not include the "single code unit" conversion functions for wchar_t. (Notably, because those are fundamentally broken on Windows and IBM machines).

p2513 - char8_t compatibility fixes

unsigned char[] is both a compatibility and an upgrade issue for people who want good UTF-8 in pre-C++20, want to work with C, and want to work with post-C++20 when char8_t becomes generally available.

n3200 - Transparent _Aliases

EDIT - Latest Draft: https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Transparent%20Aliases.html


For C. The goal is to defend against ABI by allowing function renaming. Attributes on the renaming declarations can also provide an easy-out for weak symbols.

#include <assert.h>

int real_call (double d, int i) {
    return (int)(d + i);
}

// a "typedef" for real_call;
using made_up_call = real_call;
// made_up_call never makes it into binary, it's just
// identical function pointer
_Static_assert(&made_up_call == &real_call);

int main (int, char*[]) {
    typedef int(real_call_t)(double, int);
    // decays, like normal, to function pointer to real_call
    real_call_t* made_up_call_ptr_decay = made_up_call;
    // function pointer to real_call
    real_call_t* made_up_call_ptr = &made_up_call;
    // equivalent
    assert(made_up_call_ptr_decay == &real_call);
    assert(made_up_call_ptr == &real_call);
    // invokes real_call directly
    [[maybe_unused]] int is_3 = made_up_call(2.0, 1);
    // invokes real_call through it's function pointer
    [[maybe_unused]] int is_4 = real_call_ptr_decay(3.0, 1);
    // invokes real_call through it's function pointer
    [[maybe_unused]] int is_5 = real_call_ptr(3.0, 2);
    assert(is_3 == 3);
    assert(is_4 == 4);
    assert(is_5 == 5);
    return 0;
}

p1214 - cAll the Things! - motivation, numbers, examples for C++29

So, since P1214 isn't likely to move before we can present actual numbers from an actual implementation in a compiler, I'm opening this issue to gather all the feedback & numbers I can provide. That way when it may have chances to pass EWGI and not to die another sad death before EWG.

No need for the bloated <functional>

One thing that the paper does not mention is that <functional> is often included for std::invoke only [citation needed] and that <functional> is known for being one of the slowest headers to parse:

Modules might change this, but the world probably won't fully move to modules until build systems and IDEs are ready to handle them.

std::invoke is comparatively slow to compile

According to the benchmarks of Eggs.Invoke, std::invoke is 1.5 to 18 times slower to compile than an equivalent plain function call, and the compilation process uses up to 12 times as much memory. It is quite underwhelming for such a small fundamental function.

Better error messages

The feature isn't implemented yet in compilers, but using normal functions as examples should give an example of how error messages can be improved (is there a simple way to make Tony Tables GitHub issues?):

#include <functional>

void func(int) {}

int main()
{
    struct foo_t {} foo;
    std::invoke(func, foo);
}

This snippet gives the following output on the Compiler Explorer with GCC 8.2 :

<source>: In function 'int main()':
<source>:8:26: error: no matching function for call to 'invoke(void (&)(int), main()::foo_t&)'
     std::invoke(func, foo);
                          ^
In file included from <source>:1:
/opt/compiler-explorer/gcc-8.2.0/include/c++/8.2.0/functional:78:5: note: candidate: 'template<class _Callable, class ... _Args> std::invoke_result_t<_Callable, _Args ...> std::invoke(_Callable&&, _Args&& ...)'
     invoke(_Callable&& __fn, _Args&&... __args)
     ^~~~~~
/opt/compiler-explorer/gcc-8.2.0/include/c++/8.2.0/functional:78:5: note:   template argument deduction/substitution failed:

With Clang 7:

<source>:8:5: error: no matching function for call to 'invoke'
    std::invoke(func, foo);
    ^~~~~~~~~~~
/opt/compiler-explorer/gcc-8.2.0/lib/gcc/x86_64-linux-gnu/8.2.0/../../../../include/c++/8.2.0/functional:78:5: note: candidate template ignored: substitution failure [with _Callable = void (&)(int), _Args = <foo_t &>]: no type named 'type' in 'std::invoke_result<void (&)(int), foo_t &>'
    invoke(_Callable&& __fn, _Args&&... __args)
    ^
1 error generated.

And with MSVC 19.16:

<source>(8): error C2672: 'std::invoke': no matching overloaded function found
<source>(8): error C2893: Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Types &&...) noexcept(<expr>)'
<source>(8): note: With the following template arguments:
<source>(8): note: '_Callable=void (__cdecl &)(int)'
<source>(8): note: '_Types={main::foo_t &}'

Now take the same snippet but without std::invoke:

void func(int) {}

int main()
{
    struct foo_t {} foo;
    func(foo);
}

Here is the error message with GCC 8.2:

<source>: In function 'int main()':
<source>:6:10: error: cannot convert 'main()::foo_t' to 'int'
     func(foo);
          ^~~
<source>:1:11: note:   initializing argument 1 of 'void func(int)'
 void func(int) {}
           ^~~

With Clang 7:

<source>:6:5: error: no matching function for call to 'func'
    func(foo);
    ^~~~
<source>:1:6: note: candidate function not viable: no known conversion from 'struct foo_t' to 'int' for 1st argument
void func(int) {}
     ^

And with MSVC 19.16:

<source>(6): error C2664: 'void func(int)': cannot convert argument 1 from 'main::foo_t' to 'int'
<source>(6): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

It should give a good idea of how the proposal should be able to improve error messages. It is worth noting that no compiler actually points to the definition of func on failure when std::invoke is used.

A better debugging experience

Some areas such as the video game industry have a need for interactive debugging and fast debug builds. Release builds tend to collapse calls to std::invoke into the appropriate underlying function call, but debug builds need to retain information about std::invoke and its helper functions.

Having language support for callables removes the aforementioned unneeded extra debug information - and hence can help reducing the size of the debug binary -, but also allows for a smoother navigation through function calls when debugging. In the current state of things, debugger implementers can "ignore" std::invoke as some already ignore std::move and std::forward and jump into std::function::operator() for the sake of a smoother debug navigation, but having language support would give the same experience without requiring implementers to tweak their debuggers.

Once generic libraries start moving away from std::invoke to generic language callables, it might drive their adoption in the areas that require a smoother debugging experience.

Links about issues with the debugging experience:

There might be more special cases in the future

In P0847R2, it is mentioned that the new kinds of member functions proposed don't follow the usual rules of member function pointers and give the following example:

struct Y {
    int f(int, int) const&;
    int g(this Y const&, int, int);
};

Y y;
y.f(1, 2); // ok as usual
y.g(3, 4); // ok, this paper

auto pf = &Y::f;
pf(y, 1, 2);              // error: pointers to member functions are not callable
(y.*pf)(1, 2);            // okay, same as above
std::invoke(pf, y, 1, 2); // ok

auto pg = &Y::g;
pg(y, 3, 4);              // okay, same as above
(y.*pg)(3, 4);            // error: pg is not a pointer to member function
std::invoke(pg, y, 3, 4); // ok

This means that depending on how you declare your member function, you might get different results on how it is possible to invoke a pointer to it. I think that it's yet another case where P1214 makes things better overall. It might be something worth mentioning in P0847 if the authors are fine with it.

It makes library implementers life easier

Once library implementers (including standard library ones) start relying on this feature, it will free there time to implement you favourite features faster! :D

(don't include this one in the paper)

p1039: std::no_init to go for speed

If we specify Flexible Array Members in structs to behave "like arrays", then we lose out on performance due to having to default-construct all of the elements in the array.

We need a tag for the constructor that tells the compiler to not do that and that We Are Going To Initialize It We Promise™. std::no_init of some implementation-defined, compiler-specific tag type might be exactly what we need.

p1039 - Flexible Array Members for C++29

This paper just need to be updated to fix typos and other stuff in it to be resubmitted. I don't expect it to be seriously considered at all until literally 1 year from now.

Fixes include looking at sized deletion operation and adding a callout to allow for that to delete things in a special manner (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0722r1.html). The other is to look at the analogous thing for new, however @griwes has greatly warned me of this and @Morwenn has informed me that operator new's current 18 overloads are very much frowned upon.

I don't know if I have a way forward for this one, so I might can it for Pre-Kona and look to just fix it later in C++23.

pXXXX - Fallible Allocators for Algorithms

std::scratch_space is a type that is meant to be passed to algorithms which currently internally and opaquely allocate to gain their complexity guarantees. Three such algorithms in the standard are known:

  • std::stable_sort
  • std::stable_partition
  • std::inplace_merge

For -ffreestanding and similar, we should provide overloads which take this scratch space bucket and work solely within it, to avoid paying the cost of opaque dynamic allocations inside of the algorithms.

pXXXX - Labeled loops for C++26

Ideal syntax:

while (condition) loop-label-name: { ... }
do { ... } while (condition) loop-label-name:;
for (init; condition; incr) loop-label-name: { ... }
for (type-seq var : expr ) loop-label-name: { ... }

Goal: to enable better control of moving in and out of nested loops, without having to create catch-all lambdas which scale poorly for templated code. It also is easier to implement for constexpr in almost all current constexpr engines. The usage would be like this:

for (int i = 0; i < 4; ++i)  outer_loop: {
     for (int j = 0; j < 4; ++j) inner_loop: {
          if (i > 2 && check_func(i, j)) {
               break outer_loop;
     }
}

pXXXX - Initialize unsigned char arrays from char8_t string literal (Defect Report)

This is mostly a patch job to help ease the portability from C++17 to C++20. In short:

const unsigned char str0[] = u8"foo";
const unsigned char str1[] = { u8"foo" };
const unsigned char str2[4] = u8"foo";
const unsigned char str3[4] = { u8"foo" };
const unsigned char str4[2] = u8"foo"; // truncation: still fine
const unsigned char str5[2] = { u8"foo" }; // truncation: still fine

All of these should compile. This will ease portability, and will also reduce compatibility issues between C and C++ since WG14 is looking like it will accept typedef unsigned char char8_t as a typedef in C.

N2730: Parameter order discrepancy in §3.5 vs other places

In §3.5 (Prior Art, iconv/ICU) the general function signature is given as (address then length, input then output)

stdc_mcerr stdc_XstoYs(const charX** input, size_t* input_bytes, const charY** output, size_t* output_bytes);

whereas §4, all later discussion, and the actual implementation in cuneicode use (length then address, output then input)

stdc_mcerr stdc_XntoYn(size_t* output_size, charY** output, size_t* input_size, const charX** input); /* etc. */

This is probably a bug in the former. Now that I’m looking at this closely, the Xs and Ys are probably also leftovers from earlier versions of the paper (which had functions with mbs[r]towcs-like signatures) and should be changed into Xn and Yn.

I have checked that this is present in the latest Bikeshed source in the repo as well as the published N2730.

(I also think it would be nice to at least comment in §3 why the proposed API puts the length first, disagreeing with ICU, iconv, and almost every other standard C or POSIX API in existence, thereby nearly reaching −4 points on Rusty Russell’s scale for “Follow common convention and you’ll get it wrong”, but that may or may not be a bug and you may or may not wish to listen to me on it.)

p1040 - std::embed for C++32

It is not very likely, but this paper has been seen before. I believe it can make it to C++20, if I try very, very hard.

N2900 - Consistent, Warningless, and Intuitive Initialization with {}

Because I hate myself.

{} deserves to be in C. It's stupid I have to write a paper for something so obvious, but here we are. 12 countries 17 companies and we need a paper full of motivational wank to say "hey maybe do that thing we've been doing for 15 summat years, eh?".

Extremely Functional And Not Way Too Bureaucratic System Of Governance Here, Chief.

N3029 - Improved Normal Enumerations

The status quo for enumerations is actually completely batshit bonkers, and I have no idea how anyone got any work done with exclusively standard C.

What a nightmare.

D1629 - unicode_scalar_value: a type for C++ that represents.

Seems some wording is missing here:

<p><code class="highlight"><c- n>unicode_scalar_value</c-></code>: a type for C++ that represents. Strong typedef that supports all the same operations as <code class="highlight"><c- b>char32_t</c-></code>. It’s constructor may assert / trap on values outside of the allowed 21 Unicode bits and may assert / trap on values that are surrogate characters.</p>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.