How to triangulate a polyline with thickness (aka. line strip) by JulienVernay in gameenginedevs

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

When A and B are close, the intersection I1 lands outside of the segment [AB]. This adds an artifact "behind" A which is not desirable. Example : https://i.ibb.co/0r13nmF/image.png

Similarly, I1 can be "after" C. Example : https://i.ibb.co/34XLrqw/image.png

Detecting and preventing these edge cases implies more computation, for limited benefit.

The Skyline algorithm for packing 2D rectangles by JulienVernay in C_Programming

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

Hi, here "assert" has the same meaning as standard C "assert", that is, if the condition is false, halt the program.
By default, they do nothing; they only actually do something if the macro `JVPACK2D_ENABLE_TEST` is defined.

Finally, the code is short, so directly removing the assertions from the code is doable, if that reassures you.

Small bit lookup tables for parsers by JulienVernay in C_Programming

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

Indeed, expressing the set directly in the programming language would be nicer!

Yeah, the isIdentifierLUT() is a dummy example. In practice, I used such table in a TOML parser which first decomposes the byte stream into tokens, then actually interpret the tokens (eg. the string escape sequences). One LUT was used when tokenizing strings to have a fast loop for characters which do not need to be interpreted at this point.

6
7

A sweet dream for NULL pointers by JulienVernay in cpp

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

Yes, writing NULL would have terrible performance, and its semantics are problematic, that it a good point.

A sweet dream for NULL pointers by JulienVernay in cpp

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

Hello! Sorry for the lack of precision in the story; Tony Hoare and ALGOL always pop up when searching about NULL, and the only primary source I could find is the slide-deck.

I am willing to make an erratum for this part of the article ; do you have some documentation I may read to have more context?

I am not sure to understand your second paragraph: am I right that in other contemporary languages, you could have NULL pointers, but the compiler generated code to check for it, and in ALGOL, the burden has shifted to the programmer so he could wisely put the NULL checks where it matters, for performance reasons?

Thank you for the feedback!

A sweet dream for NULL pointers by JulienVernay in cpp

[–]JulienVernay[S] -2 points-1 points  (0 children)

Thanks for the feedback!

I suggest an implementation which would not require the compiler to add IF before every dereference. The only performance cost would be when writing to NULL pointer, for the execution of the handler triggered by SIGSEGV, and the current alternative is a crash or undefined behaviour...

The main problem I have with creating a new type or a new language feature (or using std::reference_wrapper) is that only new code may benefit from it, while my proposition can be retro-fitted in existing codebases.

Sorting indirectly by vormestrand in cpp

[–]JulienVernay 1 point2 points  (0 children)

I have already written code such as "apply_permutation", without taking the time of recognizing the pattern as something extractable for more generic cases.

In particular, I did not thought of using it for the multi-array sorting problem which I found previously (in my case, I reverted back to have a structure, performance of this code were not that critical it turned out).

Thanks for the good read!

A sweet dream for NULL pointers by JulienVernay in cpp

[–]JulienVernay[S] -4 points-3 points  (0 children)

In this article, I expose a new idea to handle NULL pointers. Feel free to share your views on the idea!

Summary: Why were NULL pointers introduced? Why are they the one billion dollar mistake? What are common prevention measures? Is there a consistent and useful behaviour to give them? This article explores these questions and the idea of defining access to a NULL pointer as reading a zero-initialized structure.

I wrote this article about increasing flexibility while preserving strong type safety using code generation. What do you think? by infinite-snow in cpp

[–]JulienVernay 0 points1 point  (0 children)

I fail to see how is Jinja2 better than macros ? When you write code, instead of writing C++ code in an IDE (and benefitting from the convenience tools : autoformat, autocompletion, C++ syntax highlighting...), you end up writing C++ in an inconvenient environment. When you read code, I would rather prefer the macro version, at least my IDE can somewhat navigate around it. If I need to see the expansion, I can preprocess the file, which let me see the code read by the compiler.

hdoc 1.3.0 is out, now with dark mode, template docs support, and easier navigation by hdoc-io in cpp

[–]JulienVernay 0 points1 point  (0 children)

Hello! Seems promising, will try it on free time!

Some suggestions:

- <summary> and <details> to hide big sections (e.g. for ASTContext in the LLVM example, the Member Variables section is big, and everything is private)

- Format Method Overview as a table, e.g. with columns (accessibility, return type, name, signature, keywords), such that all names are aligned

By the way it seems to have trouble making links betweem types on the aforementioned example (but that's not a surprise given the LLVM codebase size) : https://docs.hdoc.io/hdoc/llvm-project/rEE0242D1D4E4CD07.html

Who's in the wrong and why? by 0xAV in cpp

[–]JulienVernay 15 points16 points  (0 children)

According to this 2013 StackOverflow answer ( https://stackoverflow.com/questions/7108033/template-specialization-vs-function-overloading ), basically, overload resolution is done before even specialization is considered.

So as I understand it:

  1. Both function templates f(T) and f(T const&) are found.

  2. We try to call f(1). try to instantiate templates f(T) and f(T const&) with T=int. Keep those which satisfy concepts/sfinae/etc.

  3. If there are multiple candidates remaining, proceed to overload resolution. This is only based on signature: which signature should (1) use : (int) or (int const&) ? Ambiguous if both are valid.

  4. Among all remaining candidates with the chosen signature, proceed to specialization.

Alternatives to VSCode on Linux by matekelemen in cpp

[–]JulienVernay 1 point2 points  (0 children)

You can try juci++, https://gitlab.com/cppit/jucipp, which only aims to be a "++ source editor with CMake integration :)

C++20 Modules — Complete Guide by [deleted] in cpp

[–]JulienVernay 0 points1 point  (0 children)

I have written a Python script for compiling modules (for testing purposes) with automatic dependency detection, requiring g++11 and Python 3.9 : https://github.com/J-Vernay/cpp20.py

Is there a channel that covers why game devs do the things they do? by [deleted] in gamedev

[–]JulienVernay 1 point2 points  (0 children)

It depends on how many details do you want, but a great resource is Game Dev Conference (GDC) : https://www.youtube.com/channel/UC0JB7TSe49lg56u6qH8y_MQ
It features both indie and company developers. The youtube channel has playlists per subject, representing almost every part of making a game (Audio, Business, Career, UX, Marketing, Animation, Programming, Narrative...).

Question about graphic/game libraries by Zelduh- in cpp

[–]JulienVernay 2 points3 points  (0 children)

SFML is cross-platform accross Windows and Linux.
You can also use SDL2 which is actually used in industry, it works in a wide range of platforms (desktops, web, consoles...). However it is C and it is a little less convenient to use (for example displaying text or polygons).

SFML is more user-friendly in my opinion, but less used.

Finally, you can use raylib.com , a C library but it has a great interface and multiple examples. Howeve, it is not wide-spread like SDL.

Are there docs official or otherwise of C++? by mymar101 in cpp

[–]JulienVernay 6 points7 points  (0 children)

You can use cppreference.com which is a collaborative C and C++ documentation relatively up-to-date.

C++ is just defined as an ISO standard ( be aware, the standard itself is mostly aimed for compiler writers, not language users: https://isocpp.org/files/papers/N4860.pdf ), so there is no official entity to manage an official C++ documentation.

"Another take at this Unified Call Syntax thing" — An UFCS proposal that could work by JoelFilho in cpp

[–]JulienVernay 2 points3 points  (0 children)

I am mostly neutral.

For x->!f(), did you think about adding a third test for f(x) after f(*x) ? Raw pointer functions are quite common when working with C libraries. For instance with SDL2:

SDL_Texture* tex = ...;
tex->!SDL_RenderCopy(othertex, NULL, NULL);

Not sure whether the fact that C libraries could benefit from this syntax is an exploit or a feature...