Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #127 Source code inclusion

Import the source code for the function foo body from a file "foobody.txt" . The declaration must not reside in the external file.

void foo()
{
#include "foobody.txt"
}
(def foo (load-file "foobody.txt"))
void _foo() {
#include "foobody.txt"
}
void foo()
{
    mixin(import("foobody.txt"));
}
function foo()
include "foobody.txt"
end function foo
function foo(): void
{
    include 'foobody.txt';
}
procedure foo;
begin
  {$I foobody.txt}
end;
sub foo {
    do './foobody.txt';
}
import imp
foo = imp.load_module('foobody', 'foobody.txt').foo
def foo
  eval File.read "foobody.txt"
end
fn main() {
    include!("foobody.txt");
}

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

MLKo