My problem is that I have already tried that, I made a wrapper, but I want the code to be inlined as well, and the compiler refuse to do inlining on 3 generic functions when one is referencing another.
Removing the wrapper, and the inlining works.
Interesting...
Rather than asking for a "replacement feature" wouldn't it be better to ask for the original feature (inlining) to be improved?
Of course, I can make an Include-file, but then the code isn't directly visible.
Hence, I suggested to (try to) include the unit itself (recursively).
- Then the code is visible in the unit, inside an IFDEF.
- When the unit is parsed as unit, the IFDEF is inactive
- When the unit is parsed as include, then the IFDEF is active.
But, my example was not complete. The rest of the unit needs to be in an "{$ifNdef BLOCK1}" => so during an include only the block is visible.
Yes, it will be a bit of fiddling, but probably can be made to work...
You may use macros. For other cases {$I Filename.pas} is reasonable fit. If this feature will be implemented in compiler how such code will be handled during debug?
Such code should be easy enough to handle by the debugger. If there is a bug, then simply show the bug where it is:
With the codeblock directive, the debugger already has the codeblock available and can simply display the sourcecode in brackets at the right place. No big issue there.
1) My comment wasn't on macros (though it does apply to macros too / my comment was on include files)
Which btw, why not macros? They are more or less exactly like what you describe with your block?
2) About the debugging.
Yes, the debugger would know the line in the include file (or the macro).
But that line is in several functions. That is the whole purpose, to avoid the copy and paste.
Example
//line 20 to 30
{the block}
...
{end}
line 100
procedure foo;
//the block
line 150
procedure bar;
//the block
line 300
procedure xyz
//the block
So you are paused in the block.
The debugger shows you are at line 25. (that is the only place where the line is).
But you do not know, if that is in foo,bar or xyz.
Because its not a call, but compiled into the function, then there is no entry in the callstack that says what the caller is.
(Of course there is a caller in the callstack, and if you jump to the source of that caller, then you can find if it called foo, bar, or xyz / unless it called via a variable, and you don't know whats in the var)