Functionally Equivalent Language Translation →
(class TestClass (defunc func-name ( [ p1 p2 .. pN ] ) body) (function func-name ( [ p1 p2 .. pN ] ) body) (defunc+ func-name ( [ (p1 "Hello") ] )) ; acl: public, p1 defaults to a string value (defunc# func-name ( [ (p1 :ref) ] )) ; acl: protected, p1 is a reference variable (defunc- func-name ( [ (p1 ()) ] )) ; acl: private p1 defaults to 'NULL' );class
See also DEFUN CLASS MVAR CVAR Coding for PHP Coding for javaScript
This instructions is used to define "class" or "static" methods in a class for OO based target languages that support that feature. You should read and understand the DEFUN instruction as these are very very similar except that this instruction should only be used within the lexical scope of a CLASS definition or it will more than likely cause compilation errors. FELT let's you try anything, but your final compiler / interpreter is always the final arbiter of what's acceptable. Please refer to the CLASS page for complete instructions on using classes.
As with DEFUN
is the same as defining a method that has public access. FELT supports the notion of methods that can be "public", "private" or "protected" and in order to express those intentions you can choose from the following:
Instruction | Visibility |
---|---|
DEFUNC |
public |
DEFUNC+ |
public |
DEFUNC- |
private |
DEFUNC# |
protected |
This pattern of characters at the end is also the same for when you want to declare a class method or "static method", for which you should refer to the DEFUNC page for more information.
Exactly the same rules apply as for defun/function
so please refer to the help for DEFUN for complete information on composing a function signature.
Here we show a simple FELT class definition and the (tidied) PHP output that results from it so you can see methods and class methods in practice. This is not a complete example. please refer to the help for CLASS for more complete details.
(class Example => class Example { (defun def-pubfun ()) function def_pubfun() {} (defun+ pub-fun ()) public function pub_fun() {} (defun# prot-fun ()) protected function prot_fun(){} (defun- priv-fun ()) private function priv_fun() {} );class }