Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Activity for celtschk
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #292750 | Initial revision | — | about 1 month ago |
Answer | — |
A: How can I get the same "not all control paths return a value" behaviour across Clang and MSVC? The reason why it is undefined behaviour instead of a hard error is that the problem of determining it is, quite literally, equivalent to the halting problem. So any implementation will either warn about cases where a return cannot actually happen,or miss cases where it can happen, or both. Different... (more) |
— | about 1 month ago |
Comment | Post #292748 |
However when it comes to NULL, C and C++ already differ in that C allows NULL to be defined as ((void)0), which C++ does not allow. So C compatibility is probably not the issue. However compatibility with previous C++ versions surely played a role in the decision. (more) |
— | about 1 month ago |
Comment | Post #292393 |
Thank you. I've used the method in the other file (mostly because I needed to stash some changes, and I'm not sure if that would have worked with your approach), so I can't honestly give you a "worked for me", although I'm sure it would have worked, too. (more) |
— | 3 months ago |
Comment | Post #292394 |
Thanks, that worked great. (more) |
— | 3 months ago |
Edit | Post #292401 | Initial revision | — | 3 months ago |
Answer | — |
A: Why is the new auto keyword from C++11 or C23 dangerous? A pitfall in C++ that I didn't see mentioned in the other answer is that it might give unexpected results with libraries using expression templates. What are expression templates? In a nutshell, expression templates are a technique that allows to write efficient numeric code with intuitive nota... (more) |
— | 3 months ago |
Comment | Post #290502 |
If the password hashing scheme is reasonable (simply storing an SHA256 of the password is *not* reasonable!) then the password hashing rate is in no way comparable to Bitcoin hashing rates (which, indeed, are SHA256 hashes).
A good password hashing implementation is tuned to need at least about ha... (more) |
— | 3 months ago |
Edit | Post #292391 | Initial revision | — | 3 months ago |
Question | — |
Turn all changes after latest origin/main into a branch I have a git history that basically looks like this: ``` commit: XXX (HEAD -> main) | | commit: YYY | | commit: ZZZ (origin/main) | | ... ``` Now I would like to turn everything after the last origin/main into a named branch (that is, the changed repository would look as if I bran... (more) |
— | 3 months ago |
Comment | Post #282232 |
Implementing the algorithm recursively is a bad idea (in languages which don't do tail recursion elimination). However one might implement the stack as string (or even reuse the given string as stack, if it doesn't need to be preserved, with an integer storing the current top of stack; note that the ... (more) |
— | 3 months ago |
Comment | Post #291928 |
If you want to allow not implementing set(self, channel), why would you declare it as required to implement to begin with? (more) |
— | 5 months ago |
Comment | Post #291554 |
> If a dictionary is passed in as argument to the class init, then after constructing the object, you have two, entirely separate references to a mutable dict in your code.
I'm not sure what you mean with "entire separate" here; the class referencing and modifying the original dict is the whole p... (more) |
— | 6 months ago |
Comment | Post #287289 |
First, immediate feedback: `README.md` is missing. (more) |
— | about 2 years ago |
Comment | Post #287122 |
It solves the same problem that any strong typing system solves: Catching errors. (more) |
— | about 2 years ago |
Comment | Post #286940 |
The first vector isn't shown completely in your screenshot. So it cannot show what it is intended to show according to the text.
You should have copy-pasted the output instead of posting a meaningless (and data wasting) screenshot.
Even better, post the actual length of the vectors instead of... (more) |
— | about 2 years ago |
Edit | Post #286865 | Initial revision | — | over 2 years ago |
Answer | — |
A: How to manage user-specific application data on Linux? Just as an additional information: If you are writing Python code, there's the useful package `appdirs` that provides a platform-agnostic interface to user-specific application data directories. For Linux, it implements the XDG specification. (more) |
— | over 2 years ago |
Comment | Post #286685 |
Well, as I had mentioned in the Github thread, starting a new thread is what I had expected to happen, so that would be a point for option 2. Obviously someone who understands the code will have to say what is practical to do. (more) |
— | over 2 years ago |
Comment | Post #286773 |
You're welcome. (more) |
— | over 2 years ago |
Edit | Post #286773 | Initial revision | — | over 2 years ago |
Answer | — |
A: How to use grep to print only specific word from a string While I agree with Dirk Herrmann that `basename` is the right tool for the job, I think it is still worthwhile to know how to do it with `grep`, because you might one day encounter a sufficiently similar situation that is not covered by a specialised tool. The question can be broken into two quest... (more) |
— | over 2 years ago |
Comment | Post #286727 |
It is a slash, followed by an asterisk. From the man page:
> The slash / is used as the directory separator. Separators may occur at the beginning, middle or end of the .gitignore search pattern.
And:
> If there is a separator at the beginning or middle (or both) of the pattern, then the pat... (more) |
— | over 2 years ago |
Comment | Post #286588 |
In principle, there's also the option to write a command line tool accepting sendmail-compatible options which does the signing before passing it on to whatever you use for sending mail, and instruct git to use that as sendmail executable. Maybe there already exists such an executable somewhere. (more) |
— | over 2 years ago |
Comment | Post #286575 |
Sorry, I misread. But then, `r->s` is *not* `const char*`. It is `char* const`. And while it does have a top-level const, that doesn't matter because you are just returning the value anyway.
Indeed, your code compiles just fine. And it does so even if you remove `discard_const` completely, changin... (more) |
— | over 2 years ago |
Comment | Post #286575 |
Note that `const struct t*` is *not* a const type, but a *non-const* pointer to a const type. Therefore there's no top-level `const` to discard. You can easily see the non-constness by adding the statement `r = 0;` to the function. If `r` were of a const type, that wouldn't compile.
(more) |
— | over 2 years ago |
Comment | Post #286552 |
Thank you for your answer; while the other answer gave me the understanding I needed to do it, the information in your answer made actually correcting my mistake far more easy than it would have been otherwise. (more) |
— | over 2 years ago |
Comment | Post #286551 |
Thank you for the very helpful and informative explanation. (more) |
— | over 2 years ago |
Edit | Post #286550 | Initial revision | — | over 2 years ago |
Question | — |
Is it possible to undo a git reset? For some reason, I just wanted to undo a commit on my git repository, which I've done with the following command: git reset --soft HEAD1 So far, so good. However, by mistake I issued the command a second time, thus deleting also an earlier commit. It also turned out that I had forgotten to ... (more) |
— | over 2 years ago |
Comment | Post #286529 |
Thank you for your feedback. You've got a few good points. I didn't actually think of double-registering observers, and I don't think in my actual use the order would matter. I would have expected bound member functions not to be allowed in a set (because, after all, you can change the object afterwa... (more) |
— | over 2 years ago |
Comment | Post #286530 |
Thank you for your feedback. However I don't see how you get from the term "actions" to "imperative commands". "Actions" here are actions *on* the state machine, not actions *of* the state machine. "Event" may be a better name here, but then, in the code I plan to use it, the term is already used for... (more) |
— | over 2 years ago |
Comment | Post #286511 |
The goal is to use it for my game, but not as game AI, but to manage different phases. I started out with just values for the current state, which originally were only used to report a result (was the level won, lost, saved or quit, was the menu quit or terminates, etc.), then moved on to also encode... (more) |
— | over 2 years ago |
Edit | Post #286511 | Initial revision | — | over 2 years ago |
Question | — |
A state machine in Python I've written the following code implementing a state machine in Python, and I'd like some feedback on it. The basic idea is that each state has a set of corresponding actions that trigger a state change. You can register observer functions with states, which are then called whenever the state is e... (more) |
— | over 2 years ago |
Comment | Post #286440 |
As far as I can tell, you fork exactly one child process, and the function you call for the child process only calculates and outputs the area exactly once. After return from that function, you exit the child process. No matter what the parent process does, I see absolutely no way to get more than on... (more) |
— | over 2 years ago |
Comment | Post #286433 |
@#53196 Thank you. (more) |
— | over 2 years ago |
Edit | Post #286433 | Initial revision | — | over 2 years ago |
Question | — |
Reaction comment doesn't appear if previous comment for retracted reaction was deleted On this answer I just reacted with “works for me” with comment, but then retracted it because of what finally turned out to be a mistake on my end, and deleted also the comment (and thus the comment thread). After figuring out my mistake, I gave again the “works for me” reaction with comment, but thi... (more) |
— | over 2 years ago |
Edit | Post #286429 | Initial revision | — | over 2 years ago |
Question | — |
Is it possible to write protocols for enumerations in Python? Having recently learned about protocols in Python, I now wonder if you can write a protocol for enumerations. That is, a protocol that says that you are supposed to pass an enum that has certain items with certain values, but doesn't specify a specific enum. To explain how I mean it, here's some n... (more) |
— | over 2 years ago |
Edit | Post #285813 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Are there references in C? C does have references, but it does not have pass by reference. A reference is simply an expression that references an object (object here is meant in the general sense, not in the OO sense; for example, a variable is an object). In C, references are implemented using pointers. However C does n... (more) |
— | almost 3 years ago |
Comment | Post #285801 |
A workaround could be to start your python script with a custom shell script, e.g.
```
#!/bin/bash
source ~/.env
exec python3 yourprogram.py "$@"
```
(more) |
— | almost 3 years ago |
Comment | Post #285801 |
Note that with `getenv` you need to use parentheses `()` instead of square brackets `[]`. Doing so should solve the TypeError. (more) |
— | almost 3 years ago |
Comment | Post #285580 |
@#53629 A program consists of several translation units. As far as the C standard is concerned, a program consists of nothing but translation units written in C and the standard library supplied by the implementation. It doesn't say there needs to be a separate linking step; a compiler that required ... (more) |
— | almost 3 years ago |
Edit | Post #285580 | Initial revision | — | almost 3 years ago |
Answer | — |
A: C Language Standard Linking Specifications The standard does not talk about object files and/or linking, but it does talk about translation units. In typical compilers, a single translation unit translates into a single object file. Obviously the C standard does not talk about translation units that are not themselves C; that's what a plat... (more) |
— | almost 3 years ago |
Comment | Post #285566 |
Actually given that vim is an editor, I doubt it is possible at all. To allow this, the developers would have to define what it means to edit a file while you're still reading it, and that seems to me something that isn't worth the effort.
However there is a tool called [less.vim](https://github.c... (more) |
— | almost 3 years ago |
Comment | Post #285351 |
@#8176 The alignment requirement just tells you where the allocated memory has to start, the end of the allocation does not need to be aligned. The implementation would be allowed to use the very next byte after the allocation for its own purposes, independent of its alignment. Or if the platform all... (more) |
— | almost 3 years ago |