Logo

Programming-Idioms

  • JS
  • PHP
  • C++

Idiom #127 Source code inclusion

Import the source code for the function foo body from a file "foobody.txt".

void _foo() {
#include "foobody.txt"
}
import { readFile } from 'fs/promises';
const foo = new Function(await readFile('foobody.txt'));
function foo(): void
{
    include 'foobody.txt';
}
void foo()
{
#include "foobody.txt"
}

Same as C++

New implementation...
< >
MLKo