summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-08-03 21:58:38 +0200
committerBram Moolenaar <Bram@vim.org>2019-08-03 21:58:38 +0200
commitac92e25a33c37ec5becbfffeccda136c73b761ac (patch)
tree64f77cc6dd9427536fd113451b1878490b5298db /runtime
parentb2129068a55261bea1e293a6a1ce8491a03e7de6 (diff)
downloadvim-git-ac92e25a33c37ec5becbfffeccda136c73b761ac.tar.gz
patch 8.1.1803: all builtin functions are globalv8.1.1803
Problem: All builtin functions are global. Solution: Add the method call operator ->. Implemented for a limited number of functions.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/eval.txt81
1 files changed, 73 insertions, 8 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index fdddc22ed..925446a9c 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1114,6 +1114,8 @@ in any order. E.g., these are all possible:
expr9[expr1].name
expr9.name[expr1]
expr9(expr1, ...)[expr1].name
+ expr9->(expr1, ...)[expr1]
+Evaluation is always from left to right.
expr8[expr1] item of String or |List| *expr-[]* *E111*
@@ -1213,6 +1215,11 @@ expr8(expr1, ...) |Funcref| function call
When expr8 is a |Funcref| type variable, invoke the function it refers to.
+expr8->name([args]) method call *method*
+
+For global methods this is the same as: >
+ name(expr8 [, args])
+There can also be methods specifically for the type of "expr8".
*expr9*
number
@@ -2877,6 +2884,8 @@ add({object}, {expr}) *add()*
item. Use |extend()| to concatenate |Lists|.
When {object} is a |Blob| then {expr} must be a number.
Use |insert()| to add an item at another position.
+ Can also be used as a |method|: >
+ mylist->add(val1)->add(val2)
and({expr}, {expr}) *and()*
@@ -3512,6 +3521,8 @@ copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't
changing an item changes the contents of both |Lists|.
A |Dictionary| is copied in a similar way as a |List|.
Also see |deepcopy()|.
+ Can also be used as a |method|: >
+ mylist->copy()
cos({expr}) *cos()*
Return the cosine of {expr}, measured in radians, as a |Float|.
@@ -3548,6 +3559,8 @@ count({comp}, {expr} [, {ic} [, {start}]]) *count()*
When {comp} is a string then the number of not overlapping
occurrences of {expr} is returned. Zero is returned when
{expr} is an empty string.
+ Can also be used as a |method|: >
+ mylist->count(val)
*cscope_connection()*
cscope_connection([{num} , {dbpath} [, {prepend}]])
@@ -3731,6 +3744,8 @@ empty({expr}) *empty()*
For a long |List| this is much faster than comparing the
length with zero.
+ Can also be used as a |method|: >
+ mylist->empty()
escape({string}, {chars}) *escape()*
Escape the characters in {chars} that occur in {string} with a
@@ -4041,6 +4056,9 @@ extend({expr1}, {expr2} [, {expr3}]) *extend()*
fails.
Returns {expr1}.
+ Can also be used as a |method|: >
+ mylist->extend(otherlist)
+
feedkeys({string} [, {mode}]) *feedkeys()*
Characters in {string} are queued for processing as if they
@@ -4154,6 +4172,8 @@ filter({expr1}, {expr2}) *filter()*
Funcref errors inside a function are ignored, unless it was
defined with the "abort" flag.
+ Can also be used as a |method|: >
+ mylist->filter(expr2)
finddir({name} [, {path} [, {count}]]) *finddir()*
Find directory {name} in {path}. Supports both downwards and
@@ -4416,6 +4436,8 @@ get({list}, {idx} [, {default}]) *get()*
Get item {idx} from |List| {list}. When this item is not
available return {default}. Return zero when {default} is
omitted.
+ Can also be used as a |method|: >
+ mylist->get(idx)
get({blob}, {idx} [, {default}])
Get byte {idx} from |Blob| {blob}. When this byte is not
available return {default}. Return -1 when {default} is
@@ -5689,6 +5711,9 @@ insert({object}, {item} [, {idx}]) *insert()*
Note that when {item} is a |List| it is inserted as a single
item. Use |extend()| to concatenate |Lists|.
+ Can also be used as a |method|: >
+ mylist->insert(item)
+
invert({expr}) *invert()*
Bitwise invert. The argument is converted to a number. A
List, Dict or Float argument causes an error. Example: >
@@ -5740,6 +5765,8 @@ items({dict}) *items()*
echo key . ': ' . value
endfor
+< Can also be used as a |method|: >
+ mydict->items()
job_ functions are documented here: |job-functions-details|
@@ -5755,6 +5782,9 @@ join({list} [, {sep}]) *join()*
converted into a string like with |string()|.
The opposite function is |split()|.
+ Can also be used as a |method|: >
+ mylist->join()
+
js_decode({string}) *js_decode()*
This is similar to |json_decode()| with these differences:
- Object key names do not have to be in quotes.
@@ -5840,7 +5870,10 @@ keys({dict}) *keys()*
Return a |List| with all the keys of {dict}. The |List| is in
arbitrary order. Also see |items()| and |values()|.
- *len()* *E701*
+ Can also be used as a |method|: >
+ mydict->keys()
+
+< *len()* *E701*
len({expr}) The result is a Number, which is the length of the argument.
When {expr} is a String or a Number the length in bytes is
used, as with |strlen()|.
@@ -5851,7 +5884,10 @@ len({expr}) The result is a Number, which is the length of the argument.
|Dictionary| is returned.
Otherwise an error is given.
- *libcall()* *E364* *E368*
+ Can also be used as a |method|: >
+ mylist->len()
+
+< *libcall()* *E364* *E368*
libcall({libname}, {funcname}, {argument})
Call function {funcname} in the run-time library {libname}
with single argument {argument}.
@@ -6136,6 +6172,8 @@ map({expr1}, {expr2}) *map()*
Funcref errors inside a function are ignored, unless it was
defined with the "abort" flag.
+ Can also be used as a |method|: >
+ mylist->map(expr2)
maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
When {dict} is omitted or zero: Return the rhs of mapping
@@ -6462,7 +6500,10 @@ max({expr}) Return the maximum value of all items in {expr}.
items in {expr} cannot be used as a Number this results in
an error. An empty |List| or |Dictionary| results in zero.
- *min()*
+ Can also be used as a |method|: >
+ mylist->max()
+
+< *min()*
min({expr}) Return the minimum value of all items in {expr}.
{expr} can be a list or a dictionary. For a dictionary,
it returns the minimum of all values in the dictionary.
@@ -6470,7 +6511,10 @@ min({expr}) Return the minimum value of all items in {expr}.
items in {expr} cannot be used as a Number this results in
an error. An empty |List| or |Dictionary| results in zero.
- *mkdir()* *E739*
+ Can also be used as a |method|: >
+ mylist->min()
+
+< *mkdir()* *E739*
mkdir({name} [, {path} [, {prot}]])
Create directory {name}.
@@ -7154,6 +7198,9 @@ remove({list}, {idx} [, {end}]) *remove()*
<
Use |delete()| to remove a file.
+ Can also be used as a |method|: >
+ mylist->remove(idx)
+
remove({blob}, {idx} [, {end}])
Without {end}: Remove the byte at {idx} from |Blob| {blob} and
return the byte.
@@ -7189,6 +7236,8 @@ repeat({expr}, {count}) *repeat()*
:let longlist = repeat(['a', 'b'], 3)
< Results in ['a', 'b', 'a', 'b', 'a', 'b'].
+ Can also be used as a |method|: >
+ mylist->repeat(count)
resolve({filename}) *resolve()* *E655*
On MS-Windows, when {filename} is a shortcut (a .lnk file),
@@ -7206,13 +7255,15 @@ resolve({filename}) *resolve()* *E655*
current directory (provided the result is still a relative
path name) and also keeps a trailing path separator.
- *reverse()*
-reverse({object})
+
+reverse({object}) *reverse()*
Reverse the order of items in {object} in-place.
{object} can be a |List| or a |Blob|.
Returns {object}.
If you want an object to remain unmodified make a copy first: >
:let revlist = reverse(copy(mylist))
+< Can also be used as a |method|: >
+ mylist->reverse()
round({expr}) *round()*
Round off {expr} to the nearest integral value and return it
@@ -8070,7 +8121,10 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
on numbers, text strings will sort next to each other, in the
same order as they were originally.
- Also see |uniq()|.
+ Can also be used as a |method|: >
+ mylist->sort()
+
+< Also see |uniq()|.
Example: >
func MyCompare(i1, i2)
@@ -8378,7 +8432,10 @@ string({expr}) Return {expr} converted to a String. If {expr} is a Number,
replaced by "[...]" or "{...}". Using eval() on the result
will then fail.
- Also see |strtrans()|.
+ Can also be used as a |method|: >
+ mylist->string()
+
+< Also see |strtrans()|.
*strlen()*
strlen({expr}) The result is a Number, which is the length of the String
@@ -9000,6 +9057,9 @@ type({expr}) The result is a Number representing the type of {expr}.
< To check if the v:t_ variables exist use this: >
:if exists('v:t_number')
+< Can also be used as a |method|: >
+ mylist->type()
+
undofile({name}) *undofile()*
Return the name of the undo file that would be used for a file
with name {name} when writing. This uses the 'undodir'
@@ -9064,10 +9124,15 @@ uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
< The default compare function uses the string representation of
each item. For the use of {func} and {dict} see |sort()|.
+ Can also be used as a |method|: >
+ mylist->uniq()
+
values({dict}) *values()*
Return a |List| with all the values of {dict}. The |List| is
in arbitrary order. Also see |items()| and |keys()|.
+ Can also be used as a |method|: >
+ mydict->values()
virtcol({expr}) *virtcol()*
The result is a Number, which is the screen column of the file