HP Forums
ids scope - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: ids scope (/thread-7037.html)



ids scope - compsystems - 10-14-2016 07:15 AM

I do not understand why dd identifier, can not be called


PHP Code:
local aa:=9// Local external identifier
export bb:=8// Global visible identifier
cc:=7// Global hidden identifier
dir1_fun1( ); // subfunctions
dir1_fun2();

EXPORT main_dir1() // Global main function
BEGIN
  
print(); 
  print(
"aa= " aa); // 9 calls to external local  aa
  
print("bb= " bb); // 8 calls to visible global bb
  
print("cc= " cc); // 7 calls to hidden global bb
  
local aa:=6;        // new scope of aa
  
print("aa= " aa); // 6
  
print("");

  
dir1_fun1(); // 9 5 4 3 2
  
print("");

  print(
"aa= " aa); // 6
  
print("bb= " bb); // 3
  
print("cc= " cc); // 2
 
  //dd:=1; // out of scope ?
  //print("dd= " + dd); 
  
  
dir1_fun2(); 
  
  print(
"ee= " ee); //
  
ee:=-4;
  print(
"ee= " ee); 
END;

export dd:=5// Global visible identifier
dir1_fun1( ) // Local Subfuntion hidden
BEGIN
 
print("aa= " aa); // 9 calls to external local  aa
 
print("dd= " dd); // 5 calls to visible global dd
 
print("-");
 
aa:=4;              // modifies external local aa 9->4
 
print("aa= " aa); // 4
 
bb:=3;              // modifies visible global bb 8->3
 
print("bb= " bb); // 3
 
cc:=2;              // modifies hidden global cc 7->2
 
print("cc= " cc); // 2
END;

export ee:= 0;
export dir1_fun2( ) // Global Subfuntion
BEGIN
  
//export ff:=0; // not valid
  
print("ee= " ee); //
  
ee:=-1;
END

please correct the English commentary


RE: ids scope - cyrille de brébisson - 10-14-2016 08:08 AM

Hello,

The PPL compiler is a single pass compiler. As a result, it requires that things be defined before being used.
This is why you can not use dd in the source code before you define it.
Here, before is not temporal but is with regard to the source code.

Cyrille