F.E.L.T.

Functionally Equivalent Language Translation

REQUIRE

(require filename1 filename2 ...filenameN)

This instruction informs the back-end coder that it should insist that the named file(s) being included into the run-time system and that if any one of them fails to do so that some kind of exception should be raised.


Require and Include

You have to bear in mind that FELT originally started life as a Lisp way of coding PHP before it became what it is, a translation system into any language that a back-end coder can be created for.

The difference between requiring a file and including a file really depends upon the final run-time environment.

Require-once and Include-Once

These again are an indication to the back-end that whatever it does, it should only do so once. This speeds up compilation / interpretation and also prevents "duplicate definition" types of errors from occurring.

All four of these instructions allow for multiple filenames to be specified within the instruction, this saves having to re-enter the instruction everytime. The back-end coder takes care of generating the correct code.

To explain what these instructions do it's probably easist to show a really simple snippet of FELT code and then just show the translated output, so here we go:

(require "one-filename")
(require-once "filename-a" "filename-b")
(include "another-file")
(include-once "yet-another-file" "and-his-dog")

PHP Output of Example

require("one-filename");
require_once("filename-a");
require_once("filename-b");
include("another-file");
include_once("yet-another-file");
include_once("and-his-dog");

javaScript Output of Example

<script type="text/javascript" src="one-filename"></script>
<script type="text/javascript" src="filename-a"></script>
<script type="text/javascript" src="filename-b"></script>
<script type="text/javascript" src="another-file"></script>
<script type="text/javascript" src="yet-another-file"></script>
<script type="text/javascript" src="and-his-dog"></script>

It can be seen that the javaScript coder makes the assumption that the 'file inclusion' is operating from within the contact of a web page and thus creates the correct type of tag to cause it to be included.

Node.js Specifics

require("one-filename")
require("filename-a")
require("filename-b")
require("another-file")
require("yet-another-file")
require("and-his-dog")

The Node.js system has the idiom of assigning the returned value from the require() statement into a variable. If you undertand the way that Node.js modules are packaged then you will appreciate this and here then is how in a FELT program that you would capture that value into a variable for subsequent re-use:

(defvar html (require :html))
(defvar amqp (require :amqp))

If you visit the REPL page you will find some Node.js examples that demonstrate this and show how to write a simple Node server in FELT. It's easy!