Patrick R. Michaud wrote:

On Wed, Feb 16, 2005 at 06:04:37PM +0000, Nigel Sandever wrote:

If the hyper operator returned one boolean result for each comparison it made, and if a list of boolean values in a boolean context collapsed to a count of the trues/1s it contained, I think those would work.


Part of the problem is that we don't have a "list of boolean values" that is somehow distinguishable from "list of values". (And a list evaluated in boolean context is true if the list is non-empty.)

If we create a "list of boolean values" type, it effectively becomes
a junction.  :-)

What if we instead redefine any/all/one/none to be functions (and/or list methods) that take a list, evaluates each element in boolean context, and returns boolean?

Therefore, Nigels's examples become:

   if any( $x »==« @list) { ... }
   if none($x »==« @list) { ... }
   if all( $x »==« @list) { ... }
   if one( $x »==« @list) { ... }

Then case that I see happening most often will then be:

   if any($x »==« (1,2,10,100,200,1000,2000)) { ... }


I'll also throw in the argue that anything much more complex than this definitely falls into the category of "edge case", and is of dubious utility, and IMHO, a lot of danger.



It occurred to me that junctions felt a lot like typeglobs. Very powerful thing, that little *. But also something that experienced programmers tell inexperienced ones something like "Don't mess with them unless you really understand them." Then throw in that most programmers use a heavy dose of lexicals, which aren't typeglobable. In the end, you are left with only one useful idiom left:
*NewFunc = sub {...};
Which will usually appears inside an AUTOLOAD.
(yes, I'm sure that Damian and some others on this list can create exceptionally cool use of typeglobs, in ways that would warp our minds, but I'm talking overall utility).


How does this relate to junctions? All I think anyone ever *asked* for out of a junction was an easier way to write:

   if ($x==$a or $x==$b or $x==$c or $x==$d) { ... }

The rest of the invention feels like "Magic", and is something the experienced will tell the inexperienced not to mess with until they really understand the consequences of using them. And even then, few of the experienced will make more use of it than the simple case.

-- Rod Adams




Reply via email to