Larry wrote:

All other things being equal, I think people will find modal operators
more confusing than if we just make separate operators.
Agreed.


That being said, I'm still wondering whether we can finesse it.
We can get close. But that might actually be counterproductive.


> Damian's default any() semantics in numeric context select a random element.

And I'd like to change that please! If superpositions are fundamental to the
language, we can integrate them properly with the language. So instead of:

	@array[1|2|3]

randomly selecting element 1 or 2 or 3, this expression would return

	any( @array[1,2,3] )

thereby propagating the superpositional nature of the index.

Note that we already do that anyway for certain numeric contexts. That is,
the numeric contexts of the arguments to:

	1|2 * 3|4

don't randomly select, they propagate the superposition.

So I think that superpositions normally just propagate superpositionality
on *all* operations, but also have the following methods:

	$superposition.states()          # return eigenstates
	$superposition.pick()            # select one state at random
	$superposition.serialize()       # convert to a string representation

And since superpositions *do* defer evaluation of boolean expressions, there's
no technical reason why we couldn't have a:

	$superposition.intbits()         # evaluate superposition as integer bit ops
	$superposition.strbits()         # evaluate superposition as string bit ops

Then we make functions like C<sysopen> and C<chmod> call those methods automatically
when passed a superposition where they're expecting a bitset. That would allow:

	my $in  = sysopen $infile,  O_RDONLY;
	my $out = sysopen $outfile, O_WRONLY | O_APPEND | O_CREAT;
	for <$in> {
		my ($x, $y, $z) = split;
		my $res = $x | $y & $z;
		print $out: $res.intbits(), "\n";
	}
	chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, $outfile;

And, apart from remembering to bitify on output, the finesse is complete.

Better still, we could mandate that you *can't* print a raw superposition;
that you *have* to call C<.intbits()> or C<.strbits()> or C<.serialize()> first.
That would catch the mistake of:

	my $in  = sysopen $infile,  O_RDONLY;
	my $out = sysopen $outfile, O_WRONLY | O_APPEND | O_CREAT;
	for <$in> {
		my ($x, $y, $z) = split;
		my $res = $x | $y & $z;
		print $out: $res, "\n";		# OOPS!
	}
	chmod S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH, $outfile;


Damian

Reply via email to