Luke Palmer skribis 2005-05-27 20:59 (+0000): > Opaque references always need to be explicitly dereferenced (except > for binding an array to an array reference, etc.). Transparent > references always automatically dereference. The decision of what > type of dereferencing will go on is left up to the reference taker.
The way I see things, an opaque reference is a value, while a transparent reference is a name. And thus we already have both. The name $foo points to a container, and so does \bar. However, to get at the container using $foo, you use simply $foo. To get at the container using the reference to bar, you have to dereference explicitly with another $. To bind a name (and thus have a transparent reference), we can either declare the name, creating the variable at that point, or use some other means of creating the variable, and use := to bind it later. There are named arrays, @foo, and anonymous arrays, []. There are named hashes, %foo, and anonymous hashes, {}. There are only anonymous pairs. You can't dereference a pair, or bind a name to it. > What I can't decide is which one \ will create, and how you will > create the other kind. Also, I can't decide how to one-level > dereference the transparent references so that you can change them. The only real problem with having only infix := for binding, is that you can't easily use an alias (aka transparent reference) in a list. You can have an array of aliases, but it's harder to have an array or hash in which one element is an alias. Binding can be done explicitly: %hash = { key => undef, foo => 'bar' }; %hash<key> := $variable; %hash<key> = 5; # $variable is now 5 too But there is no way to set the transparent reference (aka alias) initially, because we lack a \-like syntax. So I propose that := becomes a prefix operator as well as an infix one, allowing: %hash = { key => := $variable, foo => 'bar' }; %hash<key> = 5; # $variable is now 5 too (This almost makes \ want to be \=, and $foo \= $bar to be what we now write as $foo = \$bar, and $foo = := $bar to be the same as $foo := $bar, and stacked :=s to be irrelevant... But let's not think about this too much...) Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html