Kaleidoscope's use of C++ features and idioms

(Michael Richters) #21

Also, I still think it’s better to have it configured so that you don’t need to invoke it via the makefile, and so the actual configuration parameters are more easily found and examined. I don’t really have a dog in this fight, though, because I don’t use Kaleidoscope any longer, so feel free to disregard my opinion.

(Gabriel Morin) #22

I’ll put my vote in for sticking to standard c++ and avoiding any compiler extension (stuff that implements draft standards is ok, in the name of progress).

The language is already huge enough with C++17, no need to trip up newcomers with alien syntax.

(Noseglasses) #23

While I completely agree with you, I’d like to add that standard C++ has (and always had) some nice alien syntax. For an example have a look at the following valid C++ code.

int f() {
    int a[1] = { 42 };
    return 0[a];

(Jesse) #24

I ran across a few articles related to Modern C++ and Arduino today. I figure they might be relevant and interesting to folks here.

(Gabriel Morin) #25

So, you’re declaring an array, i.e. a pointer, and then returning the value that’s in memory at zero + this pointer i.e. the first element of the array. I don’t see anything special here (except that nobody would write it like that). Try reading the source of Boost or the STL if you really want your eyes to water.

Either way, it’s precisely because standard C++ can already be hard to read (gods forbid someone decides to overload the [] operator in your example) that we should’t make it even harder.

(Noseglasses) #26

You are obviously hard to impress. :smile:

Most other programming languages wouldn’t allow such a strange thing as writing 0[a] instead of a[0]. I bet most C/C++ programmers would guess it’s illegal code. That’s why consider it as alien syntax.

Try not reading the source code of STL when you are constantly working with it :wink: The smallest syntactical error makes the compiler spit out guts of SLT. I’ve been working with C++ for more than 15 years now, so I am not shocked anymore. Often a look into boost’s or the STL’s code can help to find out what’s going wrong. But you are right, I can remember my first contact with C++'s STL really made my eyes water :wink:


(Gabriel Morin) #27

That’s true, those templates tend to get shoved into your face at the least transgression. Your eyes must be strong, because mine still water :stuck_out_tongue: .

I feel a bit guilty of derailing the thread at this point, but before getting back on track I just wanted to mention that C++ 20 Concepts will make the template-vomiting on errors and the more recent SFINAE shenanigans (declare invalid types on purpose, seriously?) a thing of the past. I think the language will become way more teachable.

(Noseglasses) #28

Good point. I hope library developers of STL, boost and others will adopt this feature ASAP after its release.

(Gergely Nagy) #29

I hope Arduino will start shipping with something more recent than GCC 4.9.2, which supports C++11 only, with only parts of C++14. C++20? Hah! :frowning: