« first day (3493 days earlier)      last day (287 days later) » 

1:17 PM
A misconception I had was that .h files were header files meant for declaring functions ahead of time, so when these functions were used before the actual declaration the definition from the header file could be used as a stub by the compiler/linker.
So I was looking for the .c files that were the true source files for the header files used in the Rebol sourcecode. And it became clear to me that these header files just WERE the sourcecode I was looking for.
 
@iArnold There is nothing mechanically special about .h files. It is just a naming convention for code that you use the preprocessor to paste into multiple files. It is legal to put non-inline function definitions or variables into a .h file... as long as you don't try to include that .h in multiple .c files and link them together. Then you get duplicate definitions, which is illegal.
However: inline functions are an exception. They are treated as a kind of "safe macro" by the compiler.
When you declare functions inline, it gives the compiler more options to optimize together the code. For instance: if you have an inline function like inline void AddOne(int *x) {*x = *x + 1; } and you write something like y = y - 1; AddOne(&y);, the compiler can avoid making a function call altogether if it notices that's a net no-op.
It cannot typically do that with ordinary functions (though there are some exceptions possible via Link-Time Optimization (lto), which are beyond the scope of this conversation. :-P)
But generally, not making the code visible via an inline definition means each function is a black box which cannot be weaved in and optimized into the particulars of each callsite.
 
1:39 PM
>> g: generator [n: 1 while [true] [print [yield "Step" yield mold n] n: n + 1]]
== make action! [[] [...]]

>> loop 3 [print mold reduce [g g]]
["Step" "1"]
Step 1
["Step" "2"]
Step 2
["Step" "3"]
^-- I won't explain why that is harder than it looks to pull off...other than to say "trust me". But I will gloat a bit about Ren-C's foresight in factorization, e.g. building UNSPACED and SPACED on DELIMIT... and PRINT on SPACED, where if you solve one piece (like DELIMIT) then all kinds of things "just work".
 
 
2 hours later…
3:26 PM
@iArnold protip: if you ever want to break up a file just into smaller files and want to put things that can't be multiply defined in it, the convention is to end the filename with ".inc" instead of ".h". The understanding is that you should only #include that file once in your project. But again...this is only a convention. #include does nothing more-or-less than pretend the file you mention was typed where you put that.
 
 
3 hours later…
6:40 PM
@HostileForksaysdonttrustSE :thumbsup:
 

« first day (3493 days earlier)      last day (287 days later) »