[pypy-svn] r48051 - pypy/dist/pypy/lang/smalltalk

niko at codespeak.net niko at codespeak.net
Fri Oct 26 14:20:09 CEST 2007


Author: niko
Date: Fri Oct 26 14:20:09 2007
New Revision: 48051

Modified:
   pypy/dist/pypy/lang/smalltalk/primitives.py
Log:
add a brief docstring to "subscript", rename to "w_subscript" to reflect
that it returns a wrapped object, and swap the order of the argument
to match smalltalk's defn



Modified: pypy/dist/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/primitives.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/primitives.py	Fri Oct 26 14:20:09 2007
@@ -17,8 +17,12 @@
     elif isinstance(w_v, model.W_SmallInteger): return float(w_v.value)
     raise PrimitiveFailedError()
 
-def subscript(idx, w_obj):
-    # XXX what does this do? explain
+def w_subscript(w_obj, idx):
+    """
+    Rather cryptically named function which retrieves an indexed field
+    from the object, wrapping as necessary depending on the format of
+    the object so that the result can be returned.
+    """
     if isinstance(w_obj, model.W_PointersObject):
         return w_obj.fetch(idx)
     elif isinstance(w_obj, model.W_WordsObject):
@@ -393,7 +397,7 @@
         return w_rcvr.fetch(idx)
     idx -= shadow.instsize()
     if idx < w_rcvr.size():
-        return subscript(idx, w_rcvr)
+        return w_subscript(w_rcvr, idx)
     raise PrimitiveFailedError()
 
 @expose_primitive(INST_VAR_AT_PUT, unwrap_spec=[object])



More information about the Pypy-commit mailing list