2 ms·
> it's good that it's a mechanism that is completely orthogonal to the language I don’t know, doing what equals to find and replacing string inside a Programmi
by kaba0 4y ago
> it's good that it's a mechanism that is completely orthogonal to the language
I don’t know, doing what equals to find and replacing string inside a Programming language (with a bit exaggeration on my part) seems like a terrible terrible idea, even just for the very trivial reason of outputting paired number of brackets. It is also terrible from a readability and maintainability point of view with quite a few insane hacks of hacks done to implement basic functionality in other languages (there is an infamous macro in the linux kernel that is so cleverly hacky that it is on another level).
And all that for nothing, as the language is incapable of expressing even such a basic thing as a generic array/vector-like data structure without a huge indirection, let alone more complex things.
Minimalism is a nice goal, but without abstractibility/expressivity it is useless.
- jstimpfle 4y ago> (there is an infamous macro in the linux kernel that is so cleverly hacky that it is on another level) Probably that says more about the particular programmer than it says about macros. Also on a Linux kernel scale some tradeoffs are different. > And all that for nothing, as the language is incapable of expressing even such a basic thing as a generic array/vector-like data structure Something you often do not do when programming in C. You do not want "vector", reallocating by a constant factor without second thoughts, for "serious" systems programming. Same goes for much of the other stuff that is in STL for example. And you can in fact design macros in a few lines that allow you to do something like DECLARE_CHUNKLIST(My_Foo_Type) foo_chunklist; CHUNKLIST_PUSH(&foo_chunklist) = make_foo(); I.e. In fact no terrible noise involved. The hack employed here is #define DECLARE_CHUNKLIST(type) union { type *_type; struct { /* chunklist implementation ... */ } _impl; } which allows the list to carry its own type to support operations like CHUNKLIST_PUSH. For good ergonomics this relies on typeof(). But again, there is a lot of "serious" programming that gets by just fine without any of such hacks. Sometimes you're programming an event handling system where you mostle use fixed-size but dynamically-allocated buffers and push those around. There is very little generic code used here, the functions you write are dealing with concrete flat buffers mostly.