aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Laurent Le Brun <laurentlb@google.com>2016-06-23 20:30:40 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-06-24 08:12:22 +0000
commit2cdc802c6c3d577f10ec42fce83253935378df08 (patch)
tree440bd10a5051a2148937f365d75f04d6c24e2032
parent6e3410c635a2a2a5af6f77e789ac73a3076f3355 (diff)
Clarify documentation of type() - behavior might change in the future.
Also, update difference with Python that was dropped from commit 1c88f9cfafcd7f8856066a0ca4531ca2fc92c5bd -- MOS_MIGRATED_REVID=125711726
-rw-r--r--site/docs/skylark/concepts.md3
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java9
2 files changed, 9 insertions, 3 deletions
diff --git a/site/docs/skylark/concepts.md b/site/docs/skylark/concepts.md
index 7b180123ff..355a15f8c2 100644
--- a/site/docs/skylark/concepts.md
+++ b/site/docs/skylark/concepts.md
@@ -171,6 +171,9 @@ Python:
* Recursion is not allowed.
+* Loops iterate on a shallow copy of the elements. If the list is modified
+ during the iteration, you will only see the old values.
+
The following Python features are not supported:
* `class` (see [`struct`](lib/globals.html#struct) function)
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java b/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java
index 89c223e2fb..37d489f892 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java
@@ -2110,10 +2110,13 @@ public class MethodLibrary {
+ "<pre class=\"language-python\">"
+ "type(2) == \"int\"\n"
+ "type([1]) == \"list\"\n"
- + "type(struct(a = 2)) == \"struct\"\n"
+ + "type(struct(a = 2)) == \"struct\""
+ "</pre>"
- + "To write Python-compatible code, you can compare the return values: "
- + "<code>if type(x) == type([])</code>.",
+ + "This function might change in the future. To write Python-compatible code and "
+ + "be future-proof, use it only to compare return values: "
+ + "<pre class=\"language-python\">"
+ + "if type(x) == type([]): # if x is a list"
+ + "</pre>",
parameters = {@Param(name = "x", doc = "The object to check type of.")}
)
private static final BuiltinFunction type =