On Mon, Mar 15, 2004 at 11:56:26AM -0700, John Williams wrote:
: On Wed, 10 Mar 2004, Larry Wall wrote:
: > You subscript hashes with {...} historically, or these days, «...»,
: > when you want constant subscripts.  So what you're looking for is
: > something like:
: >
: >     if / <?foo> ... <?baz> ... { $?foo{'baz'} ... $?baz } .../
: > or
: >     if / <?foo> ... <?baz> ... { $?foo«baz» ... $?baz } .../
: 
: I'm probably a bit behind on current thinking, but did %hash{bareword}
: lose the ability to assume the bareword is a constant string?

It's thinking hard about doing that.  :-)

: And why «»?  Last I heard that was the unicode version of qw(), which
: returns an array.  Using an array constructor as a hash subscriptor is
: not a "least surprise" to me.

We'd be trading that surprise for the surprise that %hash{shift} doesn't
call C<shift>.  Plus we get literal hash slices out of it for free.
Plus it also works on pair syntax :foo«some literal words».  And probably
trait and property syntax as well.

And basically because I decided :foo('bar') is too ugly for something
that will get used as often as switches are on the unix command line.
The %hash syntax is just a fallout of trying to be consistent with
the pair notation.  Once people start seeing :foo«bar» all over,
they won't find %hash«bar» surprising at all, and will appreciate the
self-documenting literalness of argument.

And unfortunately it's an unavoidable part of my job description to
decide how people should be surprised.  :-)

Larry

Reply via email to