Re: hash subscriptor
On Monday, March 15, 2004, at 11:05 , Larry Wall wrote: On Mon, Mar 15, 2004 at 07:54:09PM -0700, Luke Palmer wrote: Larry Wall writes: 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. Except the six extra keystrokes involved in typing them. Yeah, I know, I could reduce that, but Perl's already used up the rest of the keyboard! :-) It's really the visual disambiguation that convinces me. It's extra keystrokes for me too, y'know, and my finger joints complain to me every day. I mostly just ignore 'em, but they do make a fearful crackling most of the time... But my eyes are bad too, so I have to cater to them too... But really, it's my brain that's my weakest organ, and I can't fix that, so I figure I'll just have to feature it. I'm just catching up, and really rather late to the party, but I just though perhaps worth pointing out that a very simple solution to the {call()} vs. {bareword} ambiguity, the {string literal}, is indeed fewer keystrokes and less surprise (at least for a Perl 5 programmer) and less context dependence than «»-is-a-subscript-now-too. Ba-a-ah, Gordon Henriksen [EMAIL PROTECTED]
Re: hash subscriptor
I've updated Damian's Perl6::Variables module to treat %foo{bar} as %foo{bar()} and to handle %foobar and %foobar baz. If this syntax is finalized, I'll send Damian a patch. This is at: http://www.cpan.org/modules/by-authors/id/S/SW/SWALTERS/Perl6-Variables-0.02_001.tar.gz http://slowass.net/~scott/Perl6-Variables-0.02_001.tar.gz I'm eager to hear if %foobar becomes permanent. Bug reports welcome. I'm not supporting the utf-8 version of because all of my software handles them incorrectly in different ways but if there is enough demand, I might accept a patch. (Just kidding, I will accept a patch). -scott PS: The other thing I was threatening to write, hyper operators in P5 via overload and hyper keyword, well, I couldn't quite get it to work in a useful way. Couldn't figure out how to get real arrays out of an over loaded op, and from what I know about P5, I don't think it is possible. You can do whatever you like with this excpet time-shift it or view it on Linux. On 0, Larry Wall [EMAIL PROTECTED] wrote: 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 Cshift. 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
Re: hash subscriptor
Whoops, that didn't work at all. Forgot about the %foobarbaz case and it was losing the subscripts entirely. Let's try that again... http://www.cpan.org/modules/by-authors/id/S/SW/SWALTERS/Perl6-Variables-0.02_002.tar.gz http://slowass.net/~scott/Perl6-Variables-0.02_002.tar.gz This version still doesn't handle %foo{'bar'}baz. Thanks, -scott On 0, Scott Walters [EMAIL PROTECTED] wrote: I've updated Damian's Perl6::Variables module to treat %foo{bar} as %foo{bar()} and to handle %foobar and %foobar baz. If this syntax is finalized, I'll send Damian a patch. This is at: http://www.cpan.org/modules/by-authors/id/S/SW/SWALTERS/Perl6-Variables-0.02_001.tar.gz http://slowass.net/~scott/Perl6-Variables-0.02_001.tar.gz I'm eager to hear if %foobar becomes permanent. Bug reports welcome. I'm not supporting the utf-8 version of because all of my software handles them incorrectly in different ways but if there is enough demand, I might accept a patch. (Just kidding, I will accept a patch). -scott PS: The other thing I was threatening to write, hyper operators in P5 via overload and hyper keyword, well, I couldn't quite get it to work in a useful way. Couldn't figure out how to get real arrays out of an over loaded op, and from what I know about P5, I don't think it is possible. You can do whatever you like with this excpet time-shift it or view it on Linux. On 0, Larry Wall [EMAIL PROTECTED] wrote: 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 Cshift. 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
hash subscriptor
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? 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. ~ John Williams
Re: hash subscriptor
Larry Wall writes: 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 ... { $?foobaz ... $?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 Cshift. And how often is that, compared with the frequency of doing %hash{optname}, %hash{root}, etc? %hash{~shift} isn't so bad, and it's one of those quirks that people will just have to learn. Perl has plenty of those, and people don't mind once they know them. I'm grateful for most of them, now that I'm more experienced. It's one of those things you'll have to mention when you talk about hash subscripting, that's all. After all, why isn't a hash subscripted with []? And why isn't the inside of a subscript a closure? These are as inconsistent as quoting a single {word}. Plus we get literal hash slices out of it for free. Plus it also works on pair syntax :foosome 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 :foobar all over, they won't find %hashbar surprising at all, and will appreciate the self-documenting literalness of argument. Except the six extra keystrokes involved in typing them. Yeah, I know, I could reduce that, but Perl's already used up the rest of the keyboard! :-) Luke
Re: hash subscriptor
On Mon, Mar 15, 2004 at 07:54:09PM -0700, Luke Palmer wrote: : Larry Wall writes: : 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 Cshift. : : And how often is that, compared with the frequency of doing : %hash{optname}, %hash{root}, etc? %hash{~shift} isn't so bad, and it's : one of those quirks that people will just have to learn. Perl has : plenty of those, and people don't mind once they know them. I'm : grateful for most of them, now that I'm more experienced. Yeah, and guess who had to trust his gut-level feelings for that? :-) : It's one of those things you'll have to mention when you talk about hash : subscripting, that's all. After all, why isn't a hash subscripted with : []? And why isn't the inside of a subscript a closure? These are as : inconsistent as quoting a single {word}. Well, all context dependencies are created equal, but some are more equal than others... : 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. : : Except the six extra keystrokes involved in typing them. Yeah, I know, : I could reduce that, but Perl's already used up the rest of the : keyboard! :-) It's really the visual disambiguation that convinces me. It's extra keystrokes for me too, y'know, and my finger joints complain to me every day. I mostly just ignore 'em, but they do make a fearful crackling most of the time... But my eyes are bad too, so I have to cater to them too... But really, it's my brain that's my weakest organ, and I can't fix that, so I figure I'll just have to feature it. Larry