3 ms·
A snippet from the paper that made me understand what this is about: // $ is the reflection operator and T is a type. constexpr { // execute this at compil
by lultimouomo 9y ago
A snippet from the paper that made me understand what this is about:
// $ is the reflection operator and T is a type.
constexpr { // execute this at compile time
for... (auto m : $T.variables()) // examine each member variable m in T
if (m.name() == “xyzzy”) // if there is one with name “xyzzy”
-> { int plugh; } // then inject also an int named “plugh”
}
This would inject "int plugh;" in the scope surrounding the constexpr block.
- ta834939874 9y agoreminds me of http://terralang.org/ http://terralang.org/
- tomovo 9y agoalso Jai: https://www.youtube.com/watch?v=gWv_vUgbmug https://www.youtube.com/watch?v=gWv_vUgbmug
- _pmf_ 9y agoI have hopes that Jai will be at a very nice local optimum regarding performance and productivity, but I think just like in C++, safety is not a major design goal (you need to be unsafe if working with memory mapped structs).
- Rusky 9y ago> you need to be unsafe if working with memory mapped structs Perhaps when defining their address and layout, or if they are a hardware structure that affects memory like a page table or TLB or a DMA controller, but beyond that, why? Or is that just the main use case you're describing?
- JoshTriplett 9y agoThis kind of compile-time code is a great substitute for things people currently do with template metaprogramming or code generators.