Logo

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".

void _foo() {
#include "foobody.txt"
}
void foo()
{
#include "foobody.txt"
}
(def foo (load-file "foobody.txt"))
void foo()
{
    mixin(import("foobody.txt"));
}
function foo()
include "foobody.txt"
end function foo
import _  "embed"
//go:embed foobody.txt
var s string

import { readFile } from 'fs/promises';
const foo = new Function(await readFile('foobody.txt'));
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");
}

New implementation...
< >
MLKo