Question: how to access local object variables from a proc() local an object private proc?

I do not understand what I am doing wrong. I have an Object, with private variable call hint. This private variable can be seen only by other proc's inside the object as expected.

Now inside one of those other proc's, I nested a small local proc inside it.

What I want is to access the object private variable from inside this small local proc nested inside.

But not able to. I tried different combinations and nothing is working.  Here is one of many attempts. 

restart;
module my_class()
   option object;
   local hint::string:="X"; #private variable to the object
 
   export foo::static:=proc(o::my_class) #can be seen from outside
      local boo; #local proc inside proc foo

      boo:=proc(o::my_class) #local proc
          print("inside boo()");
          print(o:-hint);
      end proc;

      print("in foo(), calling local proc boo()");
      print("hint is ",o:-hint); #works OK
      o:-foo:-boo(o); #tried also o:-boo(o) and boo(o)
   end proc;
end module;

called it as

o:=Object(my_class);
o:-foo(o)

Error, (in my_class:-foo) module `my_class` does not export `boo`
 

Also tried different combinations but so far nothing worked. For example, I tried making the nested proc static, but that did not help:

restart;
module my_class()
   option object;
   local hint::string:="X"; #private variable to the object
 
   export foo::static:=proc(o::my_class) #can be seen from outside
      local boo; #local proc inside proc foo

      boo::static:=proc(o::my_class) #local proc, static
          print("inside boo()");
          print(o:-hint);
      end proc;

      print("in foo(), calling local proc boo()");
      print("hint is ",o:-hint); #works OK
      boo(o);
   end proc;
end module;

o:=Object(my_class);
o:-foo(o)

Error, (in boo) module `my_class` does not export `hint`
 

But this error do not show up, when I made boo local to the object itself (vs. local to the proc). As follows, where the nested boo() proc is moved one level higher.

restart;
module my_class()
   option object;
   local hint::string:="X"; #private variable to the object
 
   export foo::static:=proc(o::my_class) #can be seen from outside     
      print("in foo(), calling local proc boo()");
      print("hint is ",o:-hint); #works OK
      o:-boo(o);
   end proc;

   local boo:=proc(o::my_class) #local proc to the object
      print("inside boo()");
      print(o:-hint);
   end proc;
end module;

now

o:=Object(my_class);
o:-foo(o)

works. No problem and no error.

How does one call a local proc to an object? Similar to how one does it in normal non-object proc's? 

Are local proc's inside object proc's allowed? Or for an Object, only one level of nesting is allowed?

Maple 2020.1

 

 

 

Please Wait...