Comment

Comment by jhg

With regards to the const part of the discussion -

Does anyone knows any research or even a state of affairs of const inference in language design?

The idea is similar to type inference whereby a compiler (or some other tool in a chain) would take care of understanding which arguments/variables/functions are going to be const and generate appropriate warnings based on that. For example,

  void foo(int * a) { (*a)++; }

  void bar(int * b) { foo(b); }

  void baz(const int * c) { bar(c); }
A compiler would generate a warning when baz function, because foo() includes a non-const operation on its argument, bar() is non-const for the same reason, and so it cannot be called for a const pointer.
parent jhg 16 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton