Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,47 @@
# syntax: GAWK -f SCOPE_MODIFIERS.AWK
BEGIN {
# All variables in AWK are considered global
a = 1 # global
b = 2 # global
# c is undefined
#
x(a) # call function in default namespace
printf("a='%s' c='%s'\n\n",a,c)
#
# A recent addition to GAWK is namespace
# The default namespace is "awk"
#
# All variables in the default namespace may be referenced by
# name or awk::name
#
# All variables in another namespace must be referenced as
# namespace::name
#
# For example to reference function x in the default namespace use
# x() or awk::x()
#
# To reference function x in the "test" namespace use test::x()
#
# Let's test the two functions named "x" which are shown below
#
awk::x(22) # call function in default namespace
printf("a='%s' c='%s'\n\n",a,c)
test::x(22) # call function in another namespace
printf("a='%s' c='%s'\n\n",a,c)
exit(0)
}
# Variables are:
# - local to functions when specified as arguments
# - passed by value except arrays which are passed by reference
#
function x(a, c) {
printf("inside awk::x() a='%s'\n",a)
a = c = 9
printf("inside awk::x() a='%s'\n",a)
}
@namespace "test"
function x(a, c) {
printf("inside test::x() a='%s'\n",a)
a = c = 9
printf("inside test::x() a='%s'\n",a)
}

View file

@ -0,0 +1,5 @@
package P is
... -- Declarations placed here are publicly visible
private
... -- These declarations are visible only to the children of P
end P;

View file

@ -0,0 +1,11 @@
package P is
type T is private; -- No components visible
procedure F (X : in out T); -- The only visible operation
N : constant T; -- A constant, which value is hidden
private
type T is record -- The implementation, visible to children only
Component : Integer;
end record;
procedure V (X : in out T); -- Operation used only by children
N : constant T := (Component => 0); -- Constant implementation
end P;

View file

@ -0,0 +1,4 @@
package body P is
-- The implementation of P, invisible to anybody
procedure W (X : in out T); -- Operation used only internally
end P;

View file

@ -0,0 +1,5 @@
private package P.Q is
... -- Visible to the siblings only
private
... -- Visible to the children only
end P.Q;

View file

@ -0,0 +1,16 @@
MODULE D1;
VAR x* : INTEGER (* x is visible (read-only) in other modules *)
y, z : BOOLEAN; (* y and z are not visible to other modules *)
PROCEDURE P1*; (* P1 can be called from other modules *)
VAR lv1, lv2 : INTEGER;
PROCEDURE Sub1;
BEGIN (* Sub1 body *)
(* lv1, lv2 not visible here *)
END Sub1;
BEGIN (* P1 body *)
(* x, y, z, lv1, lv2 and Sub1 visible here *)
END P1;
BEGIN (* D1 body *)
(* x, y, z and P1 visible here *)
END D1.

View file

@ -0,0 +1,6 @@
MODULE U1;
IMPORT D1;
VAR v1, v2 : INTEGER;
BEGIN
(* as well as v1 and v2, D1.x and D1.P1 are visible here *)
END U1.

View file

@ -1,12 +1,10 @@
-->
<span style="color: #008080;">forward</span> <span style="color: #008080;">function</span> <span style="color: #000000;">localf</span><span style="color: #0000FF;">()</span> <span style="color: #000080;font-style:italic;">-- not normally necesssary, but will not harm</span>
<span style="color: #008080;">forward</span> <span style="color: #008080;">global</span> <span style="color: #008080;">function</span> <span style="color: #000000;">globalf</span><span style="color: #0000FF;">()</span> <span style="color: #000080;font-style:italic;">-- ""</span>
forward function localf() -- not normally necesssary, but will not harm
forward global function globalf() -- ""
<span style="color: #008080;">function</span> <span style="color: #000000;">localf</span><span style="color: #0000FF;">()</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
function localf()
return 1
end function
<span style="color: #008080;">global</span> <span style="color: #008080;">function</span> <span style="color: #000000;">globalf</span><span style="color: #0000FF;">()</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">2</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<!--
global function globalf()
return 2
end function

View file

@ -1,7 +1,5 @@
-->
<span style="color: #008080;">include</span> <span style="color: #000000;">somefile</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> <span style="color: #000000;">as</span> <span style="color: #000000;">xxx</span>
<span style="color: #000080;font-style:italic;">-- alternatively, within somefile.e:</span>
<span style="color: #7060A8;">namespace</span> <span style="color: #000000;">xxx</span> <span style="color: #000080;font-style:italic;">-- (only supported in Phix for compatibility with OpenEuphoria)</span>
include somefile.e as xxx
-- alternatively, within somefile.e:
namespace xxx -- (only supported in Phix for compatibility with Euphoria)
<span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">xxx</span><span style="color: #0000FF;">:</span><span style="color: #000000;">globalf</span><span style="color: #0000FF;">()</span> <span style="color: #000080;font-style:italic;">-- call a global function named globalf, specifically the one declared in somefile.e</span>
<!--
res = xxx:globalf() -- call a global function named globalf, specifically the one declared in somefile.e

View file

@ -0,0 +1,6 @@
$a = "foo" # global scope
function test {
$a = "bar" # local scope
Write-Host Local: $a # "bar" - local variable
Write-Host Global: $global:a # "foo" - global variable
}