<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts by dclements</title><link href="https://forge.codesys.com/u/dclements/" rel="alternate"></link><link href="https://forge.codesys.com/u/dclements/profile/feed.atom" rel="self"></link><id>https://forge.codesys.com/u/dclements/</id><updated>2026-09-01T14:15:28Z</updated><subtitle>Recent posts by dclements</subtitle><entry><title>Feature Request: Read-Only References / Pointer-to-Const Support</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/c05dce14ca/?limit=25#e534" rel="alternate"></link><published>2026-09-01T14:15:28Z</published><updated>2026-09-01T14:15:28Z</updated><author><name>dclements</name><uri>https://forge.codesys.com/u/dclements/</uri></author><id>https://forge.codesys.comd0d94c34af192e7c1cd31520c435361e5d4df751</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I would like to suggest adding support for persistent read-only references or pointers in CODESYS, similar to a C++ pointer-to-const (const T*).&lt;/p&gt;
&lt;p&gt;For example, something conceptually similar to:&lt;/p&gt;
&lt;p&gt;POINTER TO CONSTANT ST_MyData&lt;br/&gt;
or&lt;br/&gt;
REFERENCE TO CONSTANT ST_MyData&lt;/p&gt;
&lt;p&gt;The important distinction is that the reference itself may still be passed around or reassigned, but the referenced object cannot be modified through that reference.&lt;/p&gt;
&lt;p&gt;CODESYS currently supports VAR_IN_OUT CONSTANT, which provides read-only reference semantics for parameters, but there does not appear to be an equivalent type that can be stored in a variable or returned from a method.&lt;/p&gt;
&lt;p&gt;A practical use case is a registry that owns long-lived definitions.&lt;/p&gt;
&lt;p&gt;The registry needs to retain ownership of the data while downstream systems maintain persistent references to it.&lt;/p&gt;
&lt;p&gt;Currently, the main options are:&lt;/p&gt;
&lt;p&gt;Return the struct by value, which loses reference semantics and requires a copy.&lt;br/&gt;
Return POINTER TO ST_Definition, which allows consumers to modify registry-owned data.&lt;br/&gt;
Convert the structure into a Function Block and expose a getter-only interface, which provides the desired encapsulation but introduces more complexity and memory overhead.&lt;/p&gt;
&lt;p&gt;A read-only reference/pointer type would allow libraries to expose persistent, zero-copy access to internally owned data while preserving encapsulation.&lt;/p&gt;
&lt;p&gt;This would be particularly useful for library APIs and object-oriented CODESYS architectures where ownership of data should remain with one component while other components are allowed to observe it.&lt;/p&gt;
&lt;p&gt;Similar requests for constant references/pointers have been discussed on CODESYS Forge previously, so this appears to be a recurring use case rather than something specific to one application.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>