F.E.L.T.

Functionally Equivalent Language Translation

#F:FN

(#f:fn "fixed-string")
(#f:fn var-name)
(#f:fn expression)

See also #F:SYM #F:VAR

Generates a function name using the syntax rules of the currently active back-end coder. You can have it rendered within quotes or raw. The starred variant causes the value to be output "naked".


The FELT Pre-Processor Instructions

FELT tries to be as helpful as it can in allowing you to try to produce language neutral source texts but there are times when you just have to do something that is specific to a particular back-end coder language. For these examples we are of course going to be talking about PHP as that was the first language that FELT was made for.

Once you see what the #F:FN instruction actually does then you will hopefully understand what the others do and may be useful for as well!

WARNING! Run-Time Use of FN/SYM/VAR

There is one very important point to make first before we explain how and when using these pre-processor instructions is useful. You will see from the generated code in the coming examples that there is one use of these functions that causes some code to be inserted into the PHP output which executes at run-time and currently only for PHP as FELT is written in PHP. This means that for now at least, using any of these instructions with a variable name as the argument only works for the PHPCoder back-end.

That was quite a mouthful but it is important that this current limitation be pointed out lest you end up head-scratching and wasting your valuable time trying to do something that just isn't possible. Yet!

The technical reason for that is that the following PHP code is emitted to make a run-time call to translate the contents of the variable, here is a simple FELT test case to show what we are talking about:

(defvar varname "foo-bar")
(#f:fn varname)
(#f:var varname)
(#f:sym varname)

and the corresponding PHP output is:

$varname = "foo-bar";
FELTCoder::Me()->asName($varname)
FELTCoder::Me()->asVarName($varname)
FELTCoder::Me()->asSymbolName($varname);

And of course, for that to be viable, the code has to be running in a PHP environment AND within the context of the FELT system; currently that means this mode of operation is available to server-based applications only..

Using with String Literals

This is the main way that you probably will use all of these instructions. In short, they translate the FELT syntax within the string into a name that is syntactically correct for the currently active back-end coder class.