From 82a4aae5321fc8b0eaf7b5e4b9e0bc17a19922c6 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Fri, 5 Sep 2025 16:02:00 +0000 Subject: [PATCH 1/7] [chap-type-method.md] list evalToDict (header for ToC) --- doc/ref/chap-type-method.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/doc/ref/chap-type-method.md b/doc/ref/chap-type-method.md index 98d8ec0e81..717ee5b253 100644 --- a/doc/ref/chap-type-method.md +++ b/doc/ref/chap-type-method.md @@ -735,12 +735,12 @@ TODO ### `__index__` -The `__index__` meta-method controls what happens when `obj[x]` is evaluated. +The `__index__` meta-method controls what happens when `obj[x]` is uated. It's currently used for type objects: var t = Dict[Str, Int] - assert [t is Dict[Str, Int]] # always evaluates to the same instance + assert [t is Dict[Str, Int]] # always uates to the same instance ### `__str__` @@ -982,27 +982,28 @@ creating procs that behave like builtins: --- -When the `eval()` method is passed `to_dict=true`, it returns a `Dict` -corresponding to the stack frame that the `Command` is evaluated in. +To evaluate "purely", use the [`eval()`][func/eval] function. + +[func/eval]: chap-builtin-func.html#func/eval + +### io/evalToDict() + +Returns a `Dict` corresponding to the stack frame that the `Command` is +evaluated in. Example: - var x = 10 # captured + # unevaluated command var cmd = ^(var a = 42; var hidden_ = 'h'; var b = x + 1; ) + var x = 10 # to be captured var d = io->evalToDict(cmd) - pp (d) # => {a: 42, b: 11} + = d # => (Dict) {a: 42, b: 11} Names that end with an underscore `_` are not copied, so `hidden_` is not in the `Dict`. ---- - -To evaluate "purely", use the [`eval()`][func/eval] function. - -[func/eval]: chap-builtin-func.html#func/eval - ### io/evalExpr() Given an `Expr` value, evaluate it and return its value: From 4df89e5bbd862bfa00d4f1510042c09a7c08610a Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Fri, 5 Sep 2025 16:05:56 +0000 Subject: [PATCH 2/7] typo --- doc/ref/chap-type-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ref/chap-type-method.md b/doc/ref/chap-type-method.md index 717ee5b253..34f7a058c1 100644 --- a/doc/ref/chap-type-method.md +++ b/doc/ref/chap-type-method.md @@ -735,7 +735,7 @@ TODO ### `__index__` -The `__index__` meta-method controls what happens when `obj[x]` is uated. +The `__index__` meta-method controls what happens when `obj[x]` is evaluated. It's currently used for type objects: From c9b46ca8e5939bdbae1029b5dde2f0ac5560cdc8 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Fri, 5 Sep 2025 16:06:32 +0000 Subject: [PATCH 3/7] typo --- doc/ref/chap-type-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ref/chap-type-method.md b/doc/ref/chap-type-method.md index 34f7a058c1..5cee2ab8e6 100644 --- a/doc/ref/chap-type-method.md +++ b/doc/ref/chap-type-method.md @@ -740,7 +740,7 @@ The `__index__` meta-method controls what happens when `obj[x]` is evaluated. It's currently used for type objects: var t = Dict[Str, Int] - assert [t is Dict[Str, Int]] # always uates to the same instance + assert [t is Dict[Str, Int]] # always evaluates to the same instance ### `__str__` From 523614789e1c3006703e62073bdbeb6c6df4a5b9 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Fri, 5 Sep 2025 16:08:04 +0000 Subject: [PATCH 4/7] shorten --- doc/ref/chap-type-method.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/ref/chap-type-method.md b/doc/ref/chap-type-method.md index 5cee2ab8e6..3c58d43bc5 100644 --- a/doc/ref/chap-type-method.md +++ b/doc/ref/chap-type-method.md @@ -993,10 +993,9 @@ evaluated in. Example: - # unevaluated command var cmd = ^(var a = 42; var hidden_ = 'h'; var b = x + 1; ) - var x = 10 # to be captured + var x = 10 # captured var d = io->evalToDict(cmd) = d # => (Dict) {a: 42, b: 11} From cf3933a93f1f54e466099a53d5f1148e63bc5177 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Mon, 29 Sep 2025 10:50:39 +0000 Subject: [PATCH 5/7] fix copy/paste error of capture/order --- doc/ref/chap-type-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ref/chap-type-method.md b/doc/ref/chap-type-method.md index 3c58d43bc5..782dff8eb5 100644 --- a/doc/ref/chap-type-method.md +++ b/doc/ref/chap-type-method.md @@ -993,9 +993,9 @@ evaluated in. Example: + var x = 10 # captured var cmd = ^(var a = 42; var hidden_ = 'h'; var b = x + 1; ) - var x = 10 # captured var d = io->evalToDict(cmd) = d # => (Dict) {a: 42, b: 11} From 3e942c894c20b1b9d4f486038490a073e3763389 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Mon, 29 Sep 2025 10:55:41 +0000 Subject: [PATCH 6/7] keep pp (d) --- doc/ref/chap-type-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ref/chap-type-method.md b/doc/ref/chap-type-method.md index 782dff8eb5..be3225503e 100644 --- a/doc/ref/chap-type-method.md +++ b/doc/ref/chap-type-method.md @@ -998,7 +998,7 @@ Example: var d = io->evalToDict(cmd) - = d # => (Dict) {a: 42, b: 11} + pp (d) # => (Dict) {a: 42, b: 11} Names that end with an underscore `_` are not copied, so `hidden_` is not in the `Dict`. From 53945ecf4e8a5a6d1b9901ffb6d84cbbacb89e26 Mon Sep 17 00:00:00 2001 From: bar-g <105970722+bar-g@users.noreply.github.com> Date: Mon, 29 Sep 2025 10:57:28 +0000 Subject: [PATCH 7/7] keep sparse pp output --- doc/ref/chap-type-method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ref/chap-type-method.md b/doc/ref/chap-type-method.md index be3225503e..4cf5ecd205 100644 --- a/doc/ref/chap-type-method.md +++ b/doc/ref/chap-type-method.md @@ -998,7 +998,7 @@ Example: var d = io->evalToDict(cmd) - pp (d) # => (Dict) {a: 42, b: 11} + pp (d) # => {a: 42, b: 11} Names that end with an underscore `_` are not copied, so `hidden_` is not in the `Dict`.