title: In vhdl, how to create a to_line function that works for all strings?
body: <p>In vhdl, how to create a generic function that takes a string and returns a line containing that string?   Everytime, I try to do this I get syntax errors...</p>
  <p>Here's my problem:</p>
  <pre class="lang-sh prettyprint-override"><code>
  $ vcom -2002 test1.vhd
  
  ** Error: test1.vhd(44): (vcom-1047) 
  Actual (string literal) for class variable formal 
  &quot;path_in2&quot; is not a variable.
  
  ** Error: test1.vhd(44): Function call returns 
  type (error); expecting type std.TEXTIO.LINE.
  
  ** Note: test1.vhd(50): VHDL Compiler exiting
  End time: 08:38:08 on Mar 23,2022, Elapsed time: 0:00:00
  Errors: 2, Warnings: 0
  
  </code></pre>
  <pre class="lang-vhdl prettyprint-override"><code>use std.textio.all;
  
  entity test1 is
  end entity;
  
  architecture beh of test1 is
  </code></pre>
  <pre class="lang-vhdl prettyprint-override"><code>        procedure join_path(
              variable path_in1 :in  line;
              variable path_in2 :in  line;
              variable path_out :out line         
          ) is
              variable mout :line;
              variable has_slash :boolean := false;
          begin
              path_out := null;
              
              if (path_in1 = null) then
                  path_out := path_in2;
                  return;
              end if;
              
              if (path_in1.all(path_in1'length-1) = '/' or
                  path_in1.all(path_in1'length-1) = '\'
              ) then
                  has_slash := true;
              end if;         
              write(mout, path_in1.all);
              if (not has_slash) then
                  write(mout, '/');
              end if;
              write(mout, path_in2.all);
              path_out := mout;
              return;
          end procedure;
  </code></pre>
  <pre class="lang-vhdl prettyprint-override"><code>    impure function to_line(constant s :string) 
      return line is 
          variable m:line;
      begin
          write(m, s);
          return m;
      end function;
  </code></pre>
  <pre class="lang-vhdl prettyprint-override"><code>begin
  
     process 
         variable projdir :line := null;
         variable mempath :line := null;
     begin
         join_path(
             path_in1 =&gt; projdir,
             path_in2 =&gt; to_line(&quot;mem.txt&quot;), --LINE 44
             path_out =&gt; mempath
         );
  
         report mempath.all;
  
         wait;
     end process;
     
  end architecture;
  </code></pre>