EimaMei / HPL

The HOI4 Programming Language (HPL) is a domain-specific interpreter programming language made for sane HOI4 modding development.
zlib License
13 stars 2 forks source link

Fix missing library include for clang #6

Closed ChineseRansomware closed 1 year ago

ChineseRansomware commented 1 year ago

Clang does not see the cstring library in the helper file - This causes compilation to fail on linux:

clang++ -std=c++17 -O2 -Wall -Wpedantic -I"include" source/helper.cpp -c -o build/helper.o
source/helper.cpp:182:25: error: use of undeclared identifier 'strchr'
        while (NULL != (here = strchr(here, '\\'))) {

Adding cstring as a library to the file solves this.

EimaMei commented 1 year ago

To be fair, that entire function should be less C and more C++ but that's something to think about in the future

ChineseRansomware commented 1 year ago

str::string::find can be a workable replacement for C's strchr. Speaking of "less C, more C++" - what's your consideration on treating entities as objects instead of having them proceduarly processed? For example: Instead of

countrySetPolitics(blr, "neutrality", 25, 25, 25, 25)

have

blr.setPolitics("neutrality", 25, 25, 25, 25)
EimaMei commented 1 year ago

Generally speaking, I don't really want OOP programming as of now due to a few reasons.

  1. Implementation of such a thing is gonna painful as hell and make the language much more complex, which isn't something I want yet. Not to mention it'll take awhile (plural months at least) before I can merge such a feature into main with actual functionality.
  2. I'd like to keep HCL simple, straightforward and take much more influence from basic and understandable C. As such, functional programming is more suited for that than OOP.
  3. To get my bias also out of the way, I prefer functional programming than OOP in a lot of cases, as OOP can sometimes overcomplicate simple things. That isn't to say I don't like OOP, but I generally only use a namespace and maybe some more traditional OOP programming, but that's about it.
  4. Functional programming is more clear than OOP programming in most cases. For an example, what does the br.setPolitics do? What's blr? In the functional programming example, such questions don't exist as it's pretty clear that it sets the politics of a country and blr is clearly something country related.

Now it isn't to say I won't implement OOP in HCL, but I don't expect it to happen anytime soon. What would be an optimal solution is if someone were to fork HCL and create a version with OOP support in it and renamed libpdx.hcl functions (kinda like C and C++ in a way), but I reaaally doubt someone would want to do all of that work, which I can't blame honestly.

ChineseRansomware commented 1 year ago

Functional programming is more clear than OOP programming in most cases. For an example, what does the br.setPolitics do? What's blr? In the functional programming example, such questions don't exist as it's pretty clear that it sets the politics of a country and blr is clearly something country related.

blr was taken from the examples provided in the repository itself. I cannot agree that these questions do not exist in OOP as logically speaking setPolitics would be a function exclusive to country objects. Meanwhile having it as a function that accepts a country makes it confusing and someone can pass a non-country variable to the function and be scratching their head for a reasonably long amount of time.

EimaMei commented 1 year ago

You can't just input a a non-country variable as the 1st argument as the language will output an error if it's attempted to. Also when I meant with "What's blr?" is that at first glance it doesn't tell you much and now you need context to figure out what type blr is.

Also I forgot to mention but what would even be the major benefit of making HCL more OOP-oriented? As far as I am concerned, it doesn't add enough benefits to varant pain and sweat to implement OOP into the language (in fact it might just make the interpreting process much slower but that's just guessing, nothing concrete).