changeset 32120:0bce463a9b1a

allow symbol scopes to be created without "ans" symbol * symscope.h (symbol_scope_rep::symbol_scope_rep): New optional argument, ADD_ANS. Only insert "ans" as first symbol if ADD_ANS is true.
author Petter T. <petter.vilhelm@gmail.com>
date Wed, 14 Jun 2023 16:07:47 -0400
parents 6870df38af9c
children ae588860b6fa
files libinterp/corefcn/symscope.h
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/symscope.h	Wed Jun 14 16:07:25 2023 -0400
+++ b/libinterp/corefcn/symscope.h	Wed Jun 14 16:07:47 2023 -0400
@@ -65,16 +65,16 @@
   typedef std::map<std::string, octave_value>::iterator
     subfunctions_iterator;
 
-  symbol_scope_rep (const std::string& name = "")
+  symbol_scope_rep (const std::string& name = "", bool add_ans = true)
     : m_name (name), m_symbols (), m_subfunctions (),
       m_persistent_values (), m_code (nullptr), m_fcn_name (),
       m_fcn_file_name (), m_dir_name (), m_parent (),
       m_primary_parent (), m_children (), m_nesting_depth (0),
       m_is_static (false), m_is_primary_fcn_scope (false)
   {
-    // All scopes have ans as the first symbol, initially undefined.
-
-    insert_local ("ans");
+    // Most scopes have ans as the first symbol, initially undefined.
+    if (add_ans)
+      insert_local ("ans");
   }
 
   OCTAVE_DISABLE_COPY_MOVE (symbol_scope_rep)