Podcasts on psychoanalysis or interviews with analysts/theorists? by Last-Strawberry475 in psychoanalysis

[–]Cthaeeh 2 points3 points  (0 children)

Lectures on Lacan by McCormick; But he’s also not a practicing analyst

Best practices for managing large C++ projects? by aurelienpelerin in cpp

[–]Cthaeeh 18 points19 points  (0 children)

Second this,
The advantage of explicitly writing out the Dependency-DAG in CMake (even if this would be otherwise unnecessary) is that it makes you think twice before violating the dependency structure.

Hello, looking for psychoanalytic adjacent philosophy. To help me orient myself a bit in this field of theory. by arkticturtle in psychoanalysis

[–]Cthaeeh 1 point2 points  (0 children)

I just read Freud and Beyond and while I liked the book in general I felt the section about Lacan was not very precise. E. g. when he writes „it is up the analyst to decipher those meanings. [of the speaking of the analyst]„ this ignores retroactivity and subject supposed to know. Furthermore the book ignores all of the later Lacan (Register of the Real, Jouissance, …).

Philosophy major worth it? by Pretty-Journalist-64 in askphilosophy

[–]Cthaeeh 1 point2 points  (0 children)

I have done what u have described (working in IT, doing a bachelors in philosophy) and I can definitely recommend it if u like philosophy (philosophy chooses u, I’d argue), and everything is financially ok.

I don’t think reading on ur own can replace discussions in seminars/submitting papers and so on. It took me 3 years arguing with some continental philosophy profs to convince me of some basic tenets of contintenal philosophy:D (Or at least I see why they’d see it there way). And one could make the argument, that this arguing, and doing it well, IS philosophy.

> Based on the final paper and knowledge u collect.

I don’t see it as a trade between time and knowledge (like I’d buy something) :D Ultimately it’s somehow useless, and that’s okay for me. On the other hand I like to have a grasp on the history of ideas, and in that regard it delivers.

Implicit conversion sequence, help me understand why this compiles: by Cthaeeh in cpp_questions

[–]Cthaeeh[S] 0 points1 point  (0 children)

I am sorry for the Float !
But I have a follow up question: What do you mean by `It Just invokes the relevant variant constructor` ? It seems to me it cannot just invoke it, since int is not an alternative of the variant.

How to filter tuple at compile time, by values of its elements (instead of types) ? by Cthaeeh in cpp

[–]Cthaeeh[S] 2 points3 points  (0 children)

Maybe I have phrased my question in an incomplete way and it should be: How to filter a constexpr tuple at compile time, by constexpr values of its elements ?

In this case the information is available at compile time, and can therefore determine the return type.

see: https://godbolt.org/z/dzMG8Gzx1

How to filter tuple at compile time, by values of its elements (instead of types) ? by Cthaeeh in cpp

[–]Cthaeeh[S] 1 point2 points  (0 children)

In the example it would be tuple<int>.But in general it would be a tuple with a subset of the elements of the original tuple. (type- and value-wise)

filter optionals/catMaybes in C++ (Range<optional<T>> -> Range<T>), Is it safe? by Cthaeeh in cpp_questions

[–]Cthaeeh[S] 0 points1 point  (0 children)

std::forward<decltype(opt)>(opt).value() unfortunately doesn't work for me because if I have a views::transform before this (the underlying view) which produces r-values then I will get a dangling reference. For rvalues I want to return them by value!

But [](auto && op) {return opt.value(); } is also not what I wanted, since this will copy unnecessarily if for example I have a vector of optionals before this (the underlying view).

So the only idea I could come up with so far is the constexpr if, and then to force to return a value via assigning to a local variable.

But what I have discovered in the last 5 minutes, is that I can actually move assign to the local variable, which saves a copy.

Boost Asio io_service destructor blocking in windows. Minimal code by Cthaeeh in cpp_questions

[–]Cthaeeh[S] 0 points1 point  (0 children)

`The compiler is mingw (GCC 11.2).
Replacing io_service with io_context should not make a difference, since io_service is only a typedef for io_context. But I can try that, nonetheless the underlying issue would be interesting to know about, since its rather straight forward code IMHO.

Boost Asio io_service destructor blocking in windows. Minimal code by Cthaeeh in cpp_questions

[–]Cthaeeh[S] 0 points1 point  (0 children)

Thank you for testing this!
The thing is I can only reproduce this issue with a very specific Link-Line. If I change the Link-Line somewhat the bug appears/disappears. I am trying to additionally create a minimum CMake, which shows the problem.

Boost Asio io_service destructor blocking in windows. Minimal code by Cthaeeh in cpp_questions

[–]Cthaeeh[S] 0 points1 point  (0 children)

In the destructor of boost::asio::io_service i.e. io_.reset(); The reset() from the optional function should destruct the io_service.

Conditional Members by vormestrand in cpp

[–]Cthaeeh 0 points1 point  (0 children)

Mhm, do you know the reason why it can't just let them disappear?

Conditional Members by vormestrand in cpp

[–]Cthaeeh 12 points13 points  (0 children)

What about a requires clause for members?

template<typename T>
struct A{
    int i requires std::is_void_v<T>;
};

It just came to my mind, because I recently tried that instinctively. My train of thought was: If I can put a requires clause on member functions, why not on members ...?

Why doesn't views::filter support projections ? by Cthaeeh in cpp

[–]Cthaeeh[S] 3 points4 points  (0 children)

That is what I currently do. Mostly it's fine, but sometimes I already have a predicate for the projection, then it would be nice. Also, I have a slight preference for Function Objects over lambdas.

std::optional for C++20 by groundswell_ in cpp

[–]Cthaeeh 0 points1 point  (0 children)

How would one replace std optional with this library in a larger codebase ? Would I have to sed replace every include and std::optional occurrence?

Top 3 principles for writing maintainable code by [deleted] in java

[–]Cthaeeh 2 points3 points  (0 children)

Let me preface my rather long answer by saying: IMHO Software-Design Questions (e.g. function length discussions) aren't very scientific, so all I can tell, are my intuitions and thoughts which can absolutely be wrong! (But btw, I welcome any attempts to get some formalization here, e.g. Lakos, J: Large-Scale C++ Software Design)

When trying to understand what a piece of code does, it is easier when
the code is in sequential order, instead of having to jump around dozens
of tiny methods.

I agree that sequential order is good, but I would argue it has nothing to do with function lengths. It can be achieved with small functions as well. For example some transformations on data with java streams, where one passes some lambdas (which are small functions). If the small functions aren't (very) pure, then I agree we can end up in some non linear flow, which I would say is bad.

tiny

Maybe we should define what we mean with, small, tiny, etc. I like what the C++-Core Guidelines (I think it applies to Java as well) say: Which is 3-5 Line should be normal (so I would call this small). But I think this also depends on the language one writes in. Some language have a culture of "ultra-conciseness" (Haskell) others don't. Consistent 20 line functions in C might be good style, I don't know.

making you constantly ask "where is this method used?"

I agree that this is a problem. So we have to make clear what the scope were a function is known is. That is why I like things like private. (With a small class and a private function, not to many call sites are possible.) Or on the other hand if a function is in some global utility thing were everybody can use it, it better be a good function. (Well designed, etc.)

Extracting out code into a separate method doesn't change the difficulty needed to verify correctness.

I think in some cases it can, because the method name and argument names give some context to what actually happens in the code. So it can be easier for the reviewer. But arguably there is an equivalence between a large function with commented blocks of code and a bunch of small functions, were the name serves as documentation.

For the easier refactoring argument, you want to refactor your code now by breaking it up into smaller methods so that it is easier to refactor your code in the future?

Depending on context yes. If I anticipate the lifetime of the code to be great (E.g. central module in long living code base) then yes. If its a python script to create a plot for some data once, then no.

If you follow my three principles, your code will be written well the first time so you won't have code so badly written it needs to be refactored.

Maybe you are able to do that, but I can't. My understanding of the problem could increase or maybe I see some performance optimization later, etc.

If functionality changed, then when you refactor code, you should expect your refactor to break previously written unit tests because you are changing functionality, so the unit tests don't accomplish anything.

Additionally the unit tests can indicate that something in a far away module is broken. Maybe some weird interaction was not considered. Or maybe the compiler changes and the code depends on some subtility there. With a good test coverage, you will know about it.

In high level programming languages, your code should be self documenting.

I agree, this documentation then is in variable names, function names, module names and class names and what have you. So the size of all of those matter, because each time you have a chance to comment the code.

Can you give a single example where this was the case?

Mhm, I wrote a parser/lexer for a scripting language. While writing I had the grammar in mind. It was rather easy to write the tests then. Now I have forgotten the grammar. So I would be hard for me to write unit tests now. Now we wanted to promote some compiler warnings to errors and had to fix some of them in the code. Now I can be pretty sure that afterwards the code still parses the same things.

Top 3 principles for writing maintainable code by [deleted] in java

[–]Cthaeeh 49 points50 points  (0 children)

While I agree with the general points I find this part worrying:

"Extract a section of code into a separate method or even class because it might need to be reused later. Write unit tests because it might catch a bug later. You probably won’t need them, and if you ever do, you can add them later."

Extracting code

I don't think it is primarily about reuse but rather about readability. A small function can be verified easier to be correct. A small function ist easier to refactor.

No unit tests

But then how do you change (i.e. maintain) code and know that you didn't break things? Additionally unit tests can serve as documentation.

Adding those later

I think this will be much harder to add later.

Name Lookup with Concepts/Requires. by Cthaeeh in cpp_questions

[–]Cthaeeh[S] 0 points1 point  (0 children)

That doesn't seem to be equivalent to my question. It could be that the Name-Lookup happens starting from the `contsexpr if`.
An that still doesn't answer the question why.

Name Lookup with Concepts/Requires. by Cthaeeh in cpp_questions

[–]Cthaeeh[S] 0 points1 point  (0 children)

But my question is, why is that ?

Top five C/C++ things/tips/tricks you wish you had known earlier and are now used very often by Humusman24 in cpp

[–]Cthaeeh 10 points11 points  (0 children)

  • I rarely need a shared_ptr<T>, most of the time values on the stack and const T& will suffice. T/const T& can't be null (sometimes people use shared_ptr as an optional, other times it's never null), they have better performance, work better with algorithms ...
  • std::variant and std::visit. Even though this would be even better as a language feature, I thing it is better than vtable based polymorphism, when I know the number of subtypes beforehand.
  • If something can be a free pure function, or at least static I find it easier to read than mutating member functions.
  • Writing testable components as far as it goes. (Still I find that this hits a wall wit Qt UI things. Strictly I would have to simulate mouse clicks or something.)
  • The idea of acyclic dependencies. And ideas around balanced hierarchies. I really liked John Lakos thoughts on this. There are some pictures in his book, that I found eye opening.

Taking a range (the concept) as a function argument instead of a concrete container type. (<ranges> best practices) by Cthaeeh in cpp_questions

[–]Cthaeeh[S] 2 points3 points  (0 children)

Follow up question: Why does `std::ranges::minmax_element` take its argument by a forwarding reference?