On Sat, Mar 28, 2009 at 6:39 AM, Daniel Ruoso <dan...@ruoso.com> wrote: > Em Sáb, 2009-03-28 às 13:36 +0300, Richard Hainsworth escreveu: >> Daniel Ruoso wrote: >> > The thing is that junctions are so cool that people like to use it for >> > more things than it's really usefull (overseeing that junctions are too >> > much powerfull for that uses, meaning it will lead to unexpected >> > behaviors at some point). >> What are the general boundaries for junctions? > > Junctions are superposition of values with a given collapsing type. > > The most important aspect of junctions is that they are a singular > value, which means that they are transparent to the code using it. You > always use it as a singular value, and that's what keep its semantics > sane.
Closely related to this is that junctions autothread. If you type in "foo($a | $b)", it will be processed exactly as if you had typed "foo($a) | foo($b)" - that is, it will call foo twice, once for $a and once for $b, and it won't care which order it uses. And this is true whether or not you know that a junction is involved. Given 'foo($j)', foo will be called once if $j isn't a junction, and will be called multiple times if $j is a junction. If you were dealing with a Set instead, you'd need to make use of 'map' and/or hyperoperators to achieve a similar result. -- Jonathan "Dataweaver" Lang