{"id":1801,"date":"2020-08-25T19:59:06","date_gmt":"2020-08-25T19:59:06","guid":{"rendered":"https:\/\/clarionsharp.com\/blog\/?p=1801"},"modified":"2020-08-26T10:12:33","modified_gmt":"2020-08-26T10:12:33","slug":"new-clarion-language-features","status":"publish","type":"post","link":"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/","title":{"rendered":"New Clarion language features"},"content":{"rendered":"\n<p>Some exciting new features in the Clarion language will be introduced in the next build for C11: <strong>Reference variables of Procedure types<\/strong> are supported by the compiler, and corresponding support is added to the linker and RTL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Declaration of a Procedure reference<\/h2>\n\n\n\n<p>A reference variable of a procedural type is declared as follows:<\/p>\n\n\n\n<p><strong>Ref     &amp;&lt;procedure label&gt;<\/strong><\/p>\n\n\n\n<p>where   &lt;procedure label&gt; is the label of a previously declared Procedure, a parameter of procedural type,  or the label of a method in a CLASS or INTERFACE. If there is more than one Procedure or Class\/Interface  method with the  label (for example, a class method is overloaded), or there is a data  declaration with the same label in the current scope\/context, the compiler returns an error.<\/p>\n\n\n\n<p>A previous MAP structure must contain the corresponding Procedure type declaration to allow references to a Class or Interface method:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  MAP \n    MethodNameType  PROCEDURE (*ClassId, &lt;other parameters>),...,TYPE       \n  END\n\nRef   &amp;MethodNameType<\/code><\/pre>\n\n\n\n<p>We&#8217;re also considering a possible extension in the future is to allow the  &lt;procedure label&gt; to include the Class or Interface identifier  as part of the declaration, for example:<br>     <strong>Ref  &amp;ClassId.MethodName<\/strong> <\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Procedure Reference assignments <\/h2>\n\n\n\n<p>The reference assignment to a reference variable of procedural type has the same form as for any other reference assignment:<\/p>\n\n\n\n<p>    RefVar &amp;=  &lt;source&gt;<\/p>\n\n\n\n<p>For reference assignments to reference variables of procedural types the right-hand  side can be any one of the following: <\/p>\n\n\n\n<p>1) NULL <br>\n2) an expression where the value can be converted to a LONG type <br>\n3) the label of a reference variable of procedural type <br>\n4) the label of a parameter of procedural type <br>\n5) the label of a Procedure declared in a MAP structure <br>\n6) the label of a Class method<\/p>\n\n\n\n<p>For (3),(4) and (5) the profile of a Procedure, or a procedural type on the right hand side must be exactly the same as the profile of the procedural type used in the declaration of the reference variable on the left hand side: <\/p>\n\n\n\n<p>meaning it must match the number of, the types of parameters, the return type, and the calling convention.  (or both sides can have no return type)<\/p>\n\n\n\n<p>For (6) if the method label on the right side is overloaded, the compiler tries to find the method with the most <em>suitable<\/em> profile.  In this case &#8220;suitable&#8221; means that the first parameter (class type) on the right side can also be of a type which is a descendant <br> of the class type of the first parameter in the profile of the reference variable&#8217;s type. All other parameters, their order, return type, and the calling convention must be exactly the same.<\/p>\n\n\n\n<p>The identifier on the right side can include:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>the label of an instance of a class type, or the label of an interface<\/li><li>the label of a reference variable assigned to a class type<\/li><li>the label of a reference variable assigned to an interface type<\/li><li>the SELF or PARENT keywords<\/li><li>the label of a Class type<\/li><\/ul>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CType    CLASS,TYPE\nM          PROCEDURE (LONG),LONG,PASCAL,VIRTUAL\n         END\n\n         MAP\nPType     PROCEDURE (*CType, LONG),LONG,PASCAL\n         END\n\nR1       &amp;PType\nR2       &amp;MESSAGE  ! the MESSAGE - built-in function\nRC       &amp;CType\nAClass   CType\n\n  CODE\n\n  RC &amp;= AClass\n  R1 &amp;= NULL\n  R1 &amp;= AClass.M\n  R1 &amp;= RC.M\n  R1 &amp;= CType.M\n  R2 &amp;= 0 + SYSTEM {PROP:MessageHook}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3. Reference equality operator <\/h2>\n\n\n\n<p>The reference equality operator for the reference variable of a procedural type has the same form as for any other reference variables:<\/p>\n\n\n\n<p>Ref &amp;= &lt;right side&gt;<\/p>\n\n\n\n<p>If the left side of the reference equality operator is a reference variable of procedural type, <br> the &lt;right side&gt; can be of any form as the &lt;source&gt; described above in the &#8220;Procedure Reference Assignments&#8221; section. <\/p>\n\n\n\n<p>There is one exception for this: if the &lt;right side&gt; is a label of a Class\/Interface method, and this label is overloaded, the compiler reports an error; &#8220;<strong>Error: Ambiguous reference type<\/strong>&#8220;, rather than trying to choose the intended matching variation of the method.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Usage <\/h2>\n\n\n\n<p>A Reference variable of a procedural type can be used in any context where procedures\/functions with the same profiles are valid: <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>call statements <\/li><li>a parameter of a procedural type <\/li><li>the Sort function parameter in QUEUE statements ADD, GET, PUT and SORT <\/li><li>as a parameter of the ADDRESS function <\/li><li>as a parameter of the BIND statement<\/li><\/ul>\n\n\n\n<p>Probably the most typical variations of usage for procedural type references are: <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Calling DLL functions from addresses returned by the Windows API&#8217;s GetProcAddress function<br><\/li><li>SYSTEM hooks properties are no longer write-only in the upcoming RTL release. The result of getting these properties are RTL  internal functions implementing corresponding statements:<br>   MESSAGE, COLORDIALOG, FONTDIALOG and other standard dialogs,<br>   OPEN for Windows and Reports, CLOSE for Windows and Reports, changing SYSTEM properties, etc.  <br><br>This means your program can retrieve the RTL&#8217;s hook function and replace it with your own function, which calls the original RTL code internally<br><\/li><li>Simulation  of virtual functions in cases where the actual function can be changed at run time.<br><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">5. Some General info <\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Reference variables of procedural type can be declared as a field in GROUP\/QUEUE\/CLASS declarations<br><\/li><li>The DIM attribute is currently invalid for declarations of reference variables, and that same rule applies for reference variables of procedural types.<br><\/li><li>The ADDRESS function supports Class type labels in the identifiers of methods passed as parameters, for example, using the declarations from the example above the following expression: <br><br><strong>ADDRESS (CType.M) <\/strong><br><br>is valid in the upcoming release.<\/li><\/ul>\n\n\n\n<p>The new language enhancements can be likened to a pointer-to-method, and reference-to-method in C++. But in C++ a special syntax is  used to allow the compiler and linker to handle these language constructs properly. No special syntax is required in Clarion.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">TYPEd Class Methods<\/h2>\n\n\n\n<p>Another powerful language enhancement available in the upcoming release is support for TYPEd Class methods. I&#8217;ll be making a separate post  on typed Class methods with an example of usage.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Exciting new features in the Clarion language; Procedure reference variables<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36,5],"tags":[40,21],"class_list":["post-1801","post","type-post","status-publish","format-standard","hentry","category-clarion-11","category-clarionnews","tag-clarion-language","tag-clarion"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>New Clarion language features - Clarion<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"New Clarion language features - Clarion\" \/>\n<meta property=\"og:description\" content=\"Exciting new features in the Clarion language; Procedure reference variables\" \/>\n<meta property=\"og:url\" content=\"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/\" \/>\n<meta property=\"og:site_name\" content=\"Clarion\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/softvelocity\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-25T19:59:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-26T10:12:33+00:00\" \/>\n<meta name=\"author\" content=\"rzaunere\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rzaunere\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/new-clarion-language-features\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/new-clarion-language-features\\\/\"},\"author\":{\"name\":\"rzaunere\",\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/#\\\/schema\\\/person\\\/b90e860529aea05ad064cf2687697ce3\"},\"headline\":\"New Clarion language features\",\"datePublished\":\"2020-08-25T19:59:06+00:00\",\"dateModified\":\"2020-08-26T10:12:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/new-clarion-language-features\\\/\"},\"wordCount\":920,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/#organization\"},\"keywords\":[\"Clarion language\",\"Clarion#\"],\"articleSection\":[\"Clarion 11\",\"Clarion News\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/new-clarion-language-features\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/new-clarion-language-features\\\/\",\"url\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/new-clarion-language-features\\\/\",\"name\":\"New Clarion language features - Clarion\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/#website\"},\"datePublished\":\"2020-08-25T19:59:06+00:00\",\"dateModified\":\"2020-08-26T10:12:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/new-clarion-language-features\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/new-clarion-language-features\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/new-clarion-language-features\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"New Clarion language features\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/\",\"name\":\"Clarion\",\"description\":\"Deliver your software on time, every time\",\"publisher\":{\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/#organization\",\"name\":\"SoftVelocity\",\"url\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/svlogonew57.png\",\"contentUrl\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/svlogonew57.png\",\"width\":221,\"height\":57,\"caption\":\"SoftVelocity\"},\"image\":{\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/softvelocity\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/SoftVelocity\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/#\\\/schema\\\/person\\\/b90e860529aea05ad064cf2687697ce3\",\"name\":\"rzaunere\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/91d95e38759c411d27f646b60da7f4769ce91e87b484669af240e51c729b1e7c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/91d95e38759c411d27f646b60da7f4769ce91e87b484669af240e51c729b1e7c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/91d95e38759c411d27f646b60da7f4769ce91e87b484669af240e51c729b1e7c?s=96&d=mm&r=g\",\"caption\":\"rzaunere\"},\"url\":\"https:\\\/\\\/clarionsharp.com\\\/blog\\\/author\\\/rzaunere\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"New Clarion language features - Clarion","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/","og_locale":"en_US","og_type":"article","og_title":"New Clarion language features - Clarion","og_description":"Exciting new features in the Clarion language; Procedure reference variables","og_url":"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/","og_site_name":"Clarion","article_publisher":"https:\/\/www.facebook.com\/softvelocity\/","article_published_time":"2020-08-25T19:59:06+00:00","article_modified_time":"2020-08-26T10:12:33+00:00","author":"rzaunere","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rzaunere","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/#article","isPartOf":{"@id":"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/"},"author":{"name":"rzaunere","@id":"https:\/\/clarionsharp.com\/blog\/#\/schema\/person\/b90e860529aea05ad064cf2687697ce3"},"headline":"New Clarion language features","datePublished":"2020-08-25T19:59:06+00:00","dateModified":"2020-08-26T10:12:33+00:00","mainEntityOfPage":{"@id":"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/"},"wordCount":920,"commentCount":0,"publisher":{"@id":"https:\/\/clarionsharp.com\/blog\/#organization"},"keywords":["Clarion language","Clarion#"],"articleSection":["Clarion 11","Clarion News"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/","url":"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/","name":"New Clarion language features - Clarion","isPartOf":{"@id":"https:\/\/clarionsharp.com\/blog\/#website"},"datePublished":"2020-08-25T19:59:06+00:00","dateModified":"2020-08-26T10:12:33+00:00","breadcrumb":{"@id":"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/clarionsharp.com\/blog\/new-clarion-language-features\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/clarionsharp.com\/blog\/"},{"@type":"ListItem","position":2,"name":"New Clarion language features"}]},{"@type":"WebSite","@id":"https:\/\/clarionsharp.com\/blog\/#website","url":"https:\/\/clarionsharp.com\/blog\/","name":"Clarion","description":"Deliver your software on time, every time","publisher":{"@id":"https:\/\/clarionsharp.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/clarionsharp.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/clarionsharp.com\/blog\/#organization","name":"SoftVelocity","url":"https:\/\/clarionsharp.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/clarionsharp.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/clarionsharp.com\/blog\/wp-content\/uploads\/2019\/03\/svlogonew57.png","contentUrl":"https:\/\/clarionsharp.com\/blog\/wp-content\/uploads\/2019\/03\/svlogonew57.png","width":221,"height":57,"caption":"SoftVelocity"},"image":{"@id":"https:\/\/clarionsharp.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/softvelocity\/","https:\/\/www.youtube.com\/user\/SoftVelocity"]},{"@type":"Person","@id":"https:\/\/clarionsharp.com\/blog\/#\/schema\/person\/b90e860529aea05ad064cf2687697ce3","name":"rzaunere","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/91d95e38759c411d27f646b60da7f4769ce91e87b484669af240e51c729b1e7c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/91d95e38759c411d27f646b60da7f4769ce91e87b484669af240e51c729b1e7c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/91d95e38759c411d27f646b60da7f4769ce91e87b484669af240e51c729b1e7c?s=96&d=mm&r=g","caption":"rzaunere"},"url":"https:\/\/clarionsharp.com\/blog\/author\/rzaunere\/"}]}},"_links":{"self":[{"href":"https:\/\/clarionsharp.com\/blog\/wp-json\/wp\/v2\/posts\/1801","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/clarionsharp.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/clarionsharp.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/clarionsharp.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/clarionsharp.com\/blog\/wp-json\/wp\/v2\/comments?post=1801"}],"version-history":[{"count":10,"href":"https:\/\/clarionsharp.com\/blog\/wp-json\/wp\/v2\/posts\/1801\/revisions"}],"predecessor-version":[{"id":1823,"href":"https:\/\/clarionsharp.com\/blog\/wp-json\/wp\/v2\/posts\/1801\/revisions\/1823"}],"wp:attachment":[{"href":"https:\/\/clarionsharp.com\/blog\/wp-json\/wp\/v2\/media?parent=1801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/clarionsharp.com\/blog\/wp-json\/wp\/v2\/categories?post=1801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/clarionsharp.com\/blog\/wp-json\/wp\/v2\/tags?post=1801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}