Adam Cameron
parallel
parameter description. Should be "Parallelism is supported only when the second parameter is a closure . When the second parameter is a key, paralellism is not supported.". My emphasis. Also, really, it's the argument (value) not the parameter (name). "Parameter value" would work.Scott Bennett
05/23/2023, 7:26 PMAdam Cameron
Mark Takata (Adobe)
05/23/2023, 7:32 PMScott Bennett
05/23/2023, 7:37 PMScott Bennett
05/23/2023, 7:38 PMAdam Cameron
Scott Bennett
05/23/2023, 7:45 PMMark Takata (Adobe)
05/23/2023, 9:04 PMScott Bennett
05/23/2023, 9:14 PMScott Bennett
05/23/2023, 9:15 PMAdam Cameron
Mark Takata (Adobe)
05/23/2023, 9:56 PMMark Takata (Adobe)
05/23/2023, 9:57 PMsaghosh
05/24/2023, 5:40 AMAdam Cameron
structFind(structure, closure, [, parallel][, maxThreadCount] )
You need to also list the key version:
structFind(structure, key)
I note now you have you have a duplicated comma in that first version: , [, parallel]
, and the spacing around the paretheses is uniform and a bit sloppy (ie: (
vs )
.
Also note: the function doesn't take a closure as the that parameter value, it takes a function. Those are two different things: a closure is a subset of function, but structFind
takes any user-defined function, be it defined via statement or expression.
Lastly I note there is some behaviour that is not documented, and probably ought to be:
https://trycf.com/gist/11243a998180b10b46ad2e523e5927d9/acf2021?theme=monokai
normal = {
"tahi" = "one",
"two" = "rua",
"toru" = "toru",
"four" = "four"
}
function keyValueMatcher(k, v) { // not a closure
return k == v
}
result = normal.find(keyValueMatcher)
writeDump(result)
ordered = [
"tahi" = "one",
"two" = "rua",
"toru" = "toru",
"four" = "four"
]
result = ordered.find(keyValueMatcher)
writeDump(result)
four toru
A matcher handler could match more than one element in the struct. What should the behaviour even be here? On an ordered struct, it's clear it's returning the first match. What's the behaviour for an unodered sruct? I presume it needs to be documented as "any one match, and which specific match it is is not guaranteed"? There's no sense of "first" in a data structure that is unordered. I could even see a case for it throwing an exception if there's this sort of ambiguity.
Anyhow, all the docs need to do is clearly state what happens.