-
Yorick Peterse authored
The nocapture attribute was cute but didn't quite work. For example, "self" is not available in blocks used for spawning new processes but "nocapture" didn't make it possible for the compiler to detect this. Using a lambda solves this. A lambda is a block that _doesn't_ capture any variables, including "self". In these blocks "self" instead refers to the module that the lambda was defined in. This allows one to safely use them for spawning processes. To make this easier to use we infer blocks without signatures (e.g. `{ 10 }`) as lambdas if passed directly to a method that takes a lambda. This means that this: process.spawn { 10 } Is the same as thiS: process.spawn lambda { 10 } This however only works if the block is passed as an argument directly. This means that the following is not valid: let block = { 10 } process.spawn(block) This is because we have already defined the type for `block` by the type we evaluate `process.spawn`. There's currently no way around this, other than by using an explicit `lambda` keyword: let block = lambda { 10 } process.spawn(block)