<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Basic templates</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/6f22319433/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/6f22319433/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/6f22319433/</id><updated>2021-05-26T15:23:02.537000Z</updated><subtitle>Recent posts to Basic templates</subtitle><entry><title>Basic templates</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/6f22319433/?limit=25#fddb" rel="alternate"/><published>2021-05-26T15:23:02.537000Z</published><updated>2021-05-26T15:23:02.537000Z</updated><author><name>sgronchi</name><uri>https://forge.codesys.com/u/sgronchi/</uri></author><id>https://forge.codesys.com1bf7fb5b4a6778e464756e79b8630f4d82f93114</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Sorry, they're terms borrowed from C++, that has a very complex template system (in fact, it is a programming language itself embedded in another programming language).&lt;br/&gt;
It can perform any computation (an extremely crude definition of Turing completeness) at compile time (bounded only by compiler limitations), and support recursion (defining something in term of {an usually smaller version of} itself).&lt;/p&gt;
&lt;p&gt;Anyway these are things that a PLC does not need to have in my opinion.&lt;/p&gt;
&lt;p&gt;But being able to write something like&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;FUNCTION Frombulate&amp;lt;'T, 'U&amp;gt; : 'U&lt;/span&gt;
&lt;span class="err"&gt;VAR_INPUT&lt;/span&gt;
&lt;span class="err"&gt;    input : 'T;&lt;/span&gt;
&lt;span class="err"&gt;    a_1 : POINTER TO 'T;&lt;/span&gt;
&lt;span class="err"&gt;    a_2 : POINTER TO 'U;&lt;/span&gt;
&lt;span class="err"&gt;    a_size : USINT;&lt;/span&gt;
&lt;span class="err"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;where 'T and 'U denote types (either explicitly written or inferred at compile time), without resorting to ANY (which (1) is a PITA to use with arrays, (2) it's an endianness nightmare, (3) is a glorified UNION requiring runtime checking {that on a 48 MHz MCU has a more severe impact than on a Core i5}, and (4) does not work for output values anyway).&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Basic templates</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/6f22319433/?limit=250#1289" rel="alternate"/><published>2021-05-26T14:14:15.306000Z</published><updated>2021-05-26T14:14:15.306000Z</updated><author><name>aliazzz</name><uri>https://forge.codesys.com/u/aliazzz/</uri></author><id>https://forge.codesys.comdb305784a2be4ae34ae065f4471629978f995648</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Could you add subtitles for the lesser informed;&lt;br/&gt;
&lt;em&gt; no recursive definitions = ?&lt;br/&gt;
&lt;/em&gt; no compile time Turing completeness =?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Basic templates</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/6f22319433/?limit=25#0080" rel="alternate"/><published>2021-05-26T13:22:23.922000Z</published><updated>2021-05-26T13:22:23.922000Z</updated><author><name>sgronchi</name><uri>https://forge.codesys.com/u/sgronchi/</uri></author><id>https://forge.codesys.com1d0caba7ffe59d9d72fd8ff79f5bdb49292c1bec</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Has anyone ever wanted a basic template support in Codesys? I mean, no recursive definitions, no compile time Turing completeness, just symbolic datatype declarations and POU generation.&lt;/p&gt;
&lt;p&gt;I often find myself copypasting some POUs only to change datatypes, especially with array-based stuff and constrained memory/performances.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>