Konrad Rudolph on Nostr: It’s not a bug; it’s a consequence of `for` loops not creating their own scope; ...
It’s not a bug; it’s a consequence of `for` loops not creating their own scope; it’s the same effect you get when writing
for (i in 1 : 10) {}
message(i)
— after the loop, `i` has a single value. Same for `name` in your case. Try `rm(name)` after the loop, before evaluating the active binding. You’ll get an error because `name` no longer exists.
To fix this, create a local scope inside the loop body, assign a local copy of the variabel inside it, and refer to that in your lambda.
Published at
2024-06-15 16:21:43Event JSON
{
"id": "8e9fed1bbd25b55d9c44550c6254b9f3ac91857d34649cccbd9f374ce0b95cf2",
"pubkey": "8e9a13f52424c355217fb84ee08d9c27dbb719a6f69ee892636b39f1277f8adf",
"created_at": 1718468503,
"kind": 1,
"tags": [
[
"proxy",
"https://mastodon.social/@klmr/112621551858722548",
"web"
],
[
"p",
"702baf454cf13ecd65a6a1f0d67108745c78d20ae7b3a9b6284b35a843798c09"
],
[
"e",
"e22dc10d891ab37c8b44b0ea795bc4e3ec6db9d1f80872cbf9bfbfc7e462039a",
"",
"root"
],
[
"proxy",
"https://mastodon.social/users/klmr/statuses/112621551858722548",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://mastodon.social/users/klmr/statuses/112621551858722548",
"pink.momostr"
]
],
"content": "It’s not a bug; it’s a consequence of `for` loops not creating their own scope; it’s the same effect you get when writing\n\nfor (i in 1 : 10) {}\nmessage(i)\n\n— after the loop, `i` has a single value. Same for `name` in your case. Try `rm(name)` after the loop, before evaluating the active binding. You’ll get an error because `name` no longer exists.\n\nTo fix this, create a local scope inside the loop body, assign a local copy of the variabel inside it, and refer to that in your lambda.",
"sig": "d772e6bd8eb6e0792c07f5401501d9da54ee99add84b18ed998ff57b6858f9604fbc8c0ba497a0303c3616b4a65ce63bf6ba36b0176e32f327d767338574df88"
}