1.1 --- a/docs/syspython.txt Thu Jul 04 22:41:32 2013 +0200
1.2 +++ b/docs/syspython.txt Thu Jul 04 22:53:22 2013 +0200
1.3 @@ -8,6 +8,21 @@
1.4 temporary storage administration and other code generation tasks are to be
1.5 left to the systems programming language compiler.
1.6
1.7 +Special Functions
1.8 +-----------------
1.9 +
1.10 +In syspython, the function invocation notation is reserved to specify
1.11 +primitive operations such as attribute access and actual function invocations,
1.12 +with the latter being expressed as follows:
1.13 +
1.14 + fn(y) # original Python
1.15 + apply(fn, y) # syspython
1.16 +
1.17 +Thus, in syspython, whenever the invocation notation is used, the target of
1.18 +the invocation is always a special function and not a general Python function
1.19 +or method. Note that the apply function resembles the Python function of the
1.20 +same name but is not actually that particular function.
1.21 +
1.22 Program Data and Data Structure Definition
1.23 ------------------------------------------
1.24
1.25 @@ -18,21 +33,21 @@
1.26 Explicit constant declaration shall be done at the start of the main
1.27 module:
1.28
1.29 - __constants__(...)
1.30 + constants(...)
1.31
1.32 Explicit structure declaration is still performed using class statements,
1.33 but base classes are omitted and attributes are declared explicitly as
1.34 follows:
1.35
1.36 class C:
1.37 - __instattrs__(member...)
1.38 - __classattrs__(member...)
1.39 + instattrs(member...)
1.40 + classattrs(member...)
1.41
1.42 Other object table information, such as inherited class attributes and
1.43 class compatibility (to support isinstance) are also declared explicitly:
1.44
1.45 - __inherited__(superclass, member...)
1.46 - __descendants__(class...)
1.47 + inherited(superclass, member...)
1.48 + descendants(class...)
1.49
1.50 Other than function definitions, no other code statements shall appear in
1.51 class definitions; such statements will appear after classes have been
1.52 @@ -69,10 +84,10 @@
1.53 ...
1.54
1.55 def __main__():
1.56 - __globalnames__(...)
1.57 + globalnames(...)
1.58 ...
1.59 if something:
1.60 - __storeattr__(module.C, method, something)
1.61 + storeattr(module.C, method, something)
1.62
1.63 Imports
1.64 -------
1.65 @@ -82,17 +97,17 @@
1.66
1.67 # import package
1.68 package.__main__()
1.69 - package = __static__(package)
1.70 + storelocal(package, static(package))
1.71
1.72 # import package.module
1.73 package.__main__()
1.74 package.module.__main__()
1.75 - package = __static__(package)
1.76 + storelocal(package, static(package))
1.77
1.78 # from package.module import cls
1.79 package.__main__()
1.80 package.module.__main__()
1.81 - cls = __loadattribute__(package.module, cls) # see below
1.82 + storelocal(cls, loadattribute(package.module, cls)) # see below
1.83
1.84 Since import statements can appear in code that may be executed more than
1.85 once, __main__ functions should test and set a flag indicating whether the
1.86 @@ -108,17 +123,15 @@
1.87 Assignments and name usage involve locals and globals but usage is declared
1.88 explicitly:
1.89
1.90 - __localnames__(...)
1.91 + localnames(...)
1.92
1.93 At the function level, locals are genuine local name definitions whereas
1.94 globals refer to module globals:
1.95
1.96 - __globalnames__(...)
1.97 + globalnames(...)
1.98
1.99 -At the module level, locals are effectively equivalent to module globals but
1.100 -are declared as follows:
1.101 -
1.102 - __moduleattrs__(...)
1.103 +At the module level, locals are effectively equivalent to module globals and
1.104 +are declared as such.
1.105
1.106 Each module's __main__ function will declare any referenced module globals as
1.107 globals. Note that the __main__ function is not a genuine attribute of any
1.108 @@ -128,33 +141,33 @@
1.109 For example:
1.110
1.111 def f(a, b):
1.112 - __localnames__(a, b, x, y)
1.113 - __globalnames__(f, g)
1.114 + localnames(a, b, x, y)
1.115 + globalnames(f, g)
1.116
1.117 - __storelocal__(x, 1)
1.118 - __storelocal__(y, x)
1.119 - __storelocal__(a, b)
1.120 - __storeattr__(module, g, f)
1.121 + storelocal(x, 1)
1.122 + storelocal(y, x)
1.123 + storelocal(a, b)
1.124 + storeattr(module, g, f)
1.125
1.126 Names and Attributes
1.127 --------------------
1.128
1.129 -Bare names refer to locals or globals according to the __localnames__ and
1.130 -__globalnames__ declarations, or to constants such as None, True, False and
1.131 +Bare names refer to locals or globals according to the localnames and
1.132 +globalnames declarations, or to constants such as None, True, False and
1.133 NotImplemented. Storage of local or global names is done using explicit
1.134 functions as follows:
1.135
1.136 - __storelocal__(name, value)
1.137 - __storeattr__(module, name, value) # see below
1.138 + storelocal(name, value)
1.139 + storeattr(module, name, value) # see below
1.140
1.141 No operator usage: all operators are converted to invocations, including
1.142 all attribute access except static references to modules or particular class
1.143 or function definitions using the following notation:
1.144
1.145 - __static__(package)
1.146 - __static__(package.module)
1.147 - __static__(package.module.cls)
1.148 - __static__(package.module.cls.function)
1.149 + static(package)
1.150 + static(package.module)
1.151 + static(package.module.cls)
1.152 + static(package.module.cls.function)
1.153
1.154 A shorthand dot notation could be employed:
1.155
1.156 @@ -165,26 +178,27 @@
1.157 Where multiple definitions of static objects occur, the dot notation cannot be
1.158 used, and the full name of such definitions must be quoted. For example:
1.159
1.160 - __static__("package.module.cls#1.function")
1.161 + static("package.module.cls#1.function")
1.162
1.163 In general, attribute access must use an explicit function indicating the
1.164 kind of access operation being performed. For example:
1.165
1.166 - __loadattr__(obj, attrname) # preserve context
1.167 - __loadattrcontext__(obj, attrname) # replace context with obj
1.168 - __loadattrcontextcond__(obj, attrname) # run-time context decision
1.169 - __loadattrindex__(obj, attrname) # preserve context
1.170 - __loadattrindexcontext__(obj, attrname) # replace context with obj
1.171 - __loadattrindexcontextcond__(obj, attrname) # run-time context decision
1.172 + # context effect
1.173 + # --------------
1.174 + loadattr(obj, attrname) # preserve context
1.175 + loadattrcontext(parent, attrname, obj) # replace context with obj
1.176 + loadattrcontextcond(parent, attrname, obj) # run-time context decision
1.177 + loadattrindex(obj, attrname) # preserve context
1.178 + loadattrindexcontextcond(obj, attrname) # run-time context decision
1.179
1.180 - __storeattr__(obj, attrname, value) # preserve context
1.181 - __storeattrcontext__(obj, attrname, value) # replace context
1.182 - __storeattrindex__(obj, attrname, value)
1.183 + storeattr(obj, attrname, value) # preserve context
1.184 + storeattrcontext(parent, attrname, value, obj) # replace context with obj
1.185 + storeattrindex(obj, attrname, value)
1.186
1.187 Temporary variables could employ similar functions:
1.188
1.189 - __loadtemp__(0)
1.190 - __storetemp__(0, value)
1.191 + loadtemp(0)
1.192 + storetemp(0, value)
1.193
1.194 Operators and Invocations
1.195 -------------------------
1.196 @@ -195,6 +209,7 @@
1.197 but might as well be supported directly:
1.198
1.199 __is__(a, b)
1.200 + __is_not__(a, b)
1.201
1.202 Logical operators involving short-circuit evaluation could be represented
1.203 as function calls, but the evaluation semantics would be preserved:
1.204 @@ -218,20 +233,20 @@
1.205
1.206 Special functions for low-level operations:
1.207
1.208 - __check__(obj, type)
1.209 - __jump__(callable)
1.210 + check(obj, type)
1.211 + jump(callable)
1.212
1.213 Function/subroutine definition with entry points for checked and unchecked
1.214 parameters.
1.215
1.216 def fn_checked(self, ...):
1.217 - __check__(self, Type) # raises a TypeError if not isinstance(self, Type)
1.218 - __jump__(fn_unchecked) # preserves the frame and return address
1.219 + check(self, Type) # raises a TypeError if not isinstance(self, Type)
1.220 + jump(fn_unchecked) # preserves the frame and return address
1.221
1.222 def fn_unchecked(self, ...):
1.223 ...
1.224
1.225 -The __jump__ function might also be used for inlining appropriate functions.
1.226 +The jump function might also be used for inlining appropriate functions.
1.227
1.228 Exceptions must also be handled in the language.
1.229
1.230 @@ -241,4 +256,4 @@
1.231 Occasionally, the type of an object (instance of a particular class, class,
1.232 and so on) needs to be determined at run-time:
1.233
1.234 - __isclass__(obj)
1.235 + isclass(obj)