topheader Welcome 3.88.220.93 @ xps.scios.ch on Sun Jun 16 14:57:17 CEST 2019
topheader
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

clips:clip5foj [2010/01/04 20:46] (current)
Line 1: Line 1:
 +
 +<​HTML>​
 +<​HEAD>​
 +<META HTTP-EQUIV="​Content-Type"​ Content="​text/​html;​ charset=Windows-1252">​
 +<​TITLE>​DEFGENERIC / DEFMETHOD</​TITLE>​
 +</​HEAD>​
 +
 +<BODY BGCOLOR="#​FFFFFF"​ TEXT="#​000000">​
 +
 +<OBJECT TYPE="​application/​x-oleobject"​ CLASSID="​clsid:​1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">​
 + <PARAM NAME="​Keyword"​ VALUE="​DEFGENERIC">​
 + <PARAM NAME="​Keyword"​ VALUE="​DEFMETHOD">​
 +</​OBJECT>​
 +
 +<​H1><​A NAME="​defgeneric"></​A>​DEFGENERIC / DEFMETHOD</​H1>​
 +
 +<​P></​P>​
 +
 +<​P>​With the defgeneric/​defmethod constructs, new generic functions may be written </P>
 +
 +<​P>​directly in CLIPS. ​ Generic functions are similar to deffunctions because </P>
 +
 +<​P>​they can be used to define new procedural code directly in CLIPS, and they can </P>
 +
 +<P>be called like any other function. However, generic functions are much more </P>
 +
 +<​P>​powerful because they can do different things depending on the types </P>
 +
 +<​P>​(or classes) and number of their arguments. For example, a '​+'​ operator could </P>
 +
 +<P>be defined which performs concatenation for strings but still performs </P>
 +
 +<​P>​arithmetic addition for numbers. ​ Generic functions are comprised of </P>
 +
 +<​P>​multiple components called methods, where each method handles different </P>
 +
 +<​P>​cases of arguments for the generic function. ​ A generic function which has </P>
 +
 +<​P>​more than one method is said to be overloaded.</​P>​
 +
 +<P>A generic function is comprised of a header (similar to a forward declaration) </P>
 +
 +<​P>​and zero or more methods. ​ A generic function header can either be explicitly </P>
 +
 +<​P>​declared by the user or implicitly declared by the definition of at least one </P>
 +
 +<​P>​method. The defgeneric construct is used to specify the generic function header,</​P>​
 +
 +<​P>​and the defmethod construct is used for each of the generic function'​s methods.</​P>​
 +
 +<​P>​The syntax of the defgeneric/​defmethod constructs is:</​P>​
 +
 +<​PRE><​CODE>​(defgeneric &​lt;​name&​gt;​ [&​lt;​comment&​gt;​])
 +
 +(defmethod &​lt;​name&​gt;​ [&​lt;​index&​gt;​] [&​lt;​comment&​gt;​]
 +    (&​lt;​parameter-restriction&​gt;​* [&​lt;​wildcard-parameter&​gt;​])
 +    &​lt;​action&​gt;​*)
 +
 +&​lt;​parameter-restriction&​gt;​ ::= &​lt;​single-field-variable&​gt;​ |
 +                            (&​lt;​single-field-variable&​gt;​ &​lt;​type&​gt;​* [&​lt;​query&​gt;​])
 +
 +&​lt;​wildcard-parameter&​gt; ​   ::= &​lt;​multifield-variable&​gt;​
 +
 +&​lt;​type&​gt; ​                 ::= &​lt;​class-name&​gt;​
 +
 +&​lt;​query&​gt; ​                ::= &​lt;​global-variable&​gt;​ | &​lt;​function-call&​gt;</​CODE></​PRE>​
 +
 +</​BODY>​
 +</​HTML>​
  
 
 
clips/clip5foj.txt ยท Last modified: 2010/01/04 20:46 (external edit)
topheader
© 1998-2019, SciOS Scientific Operating Systems GmbH

Legal | Credits | Profile | Contact | Customer Login