Logo

Programming-Idioms

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

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
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
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");
}