Re: the currying operator
Graham Barr [EMAIL PROTECTED] writes: On Fri, Aug 11, 2000 at 02:52:32AM -0700, Nathan Wiger wrote: Mike- Jeremy's got a great explanation of this, which I'll paraphrase, but the discussion went through lots of iterations. Think of the ^ as a carat or thumbtack, holding the place for later variables. Then, consider the parallels: Placeholder Variable Anonymous ^_ $_ Numbered^1 ^2 $1 $2 Named ^bob ^jim $bob $jim When you look at the symmetry this way, I think it makes a ton of sense and even makes currying a lot more understandable. In fact, I think the syntax is very Perlish. I agree, however I wonder if ^ is the right character. Consider a currie function that used a regexp /^_/ What is that matching ? We've done this. It's matching a string that begins with '_'. Which is why, if you want to disambiguate you do /^{_}/ just like you do with variables. So I would suggest something like one of : _ Not sure about :, but how you do distinguish between _foo = placeholder and _foo = _foo? -- Piers '063039183598121887134041122600:1917131105:Jaercunrlkso tPh.'=~/^(.{6})* (.{6})[^:]*:(..)*(..).*:(??{'.{'.$2%$4.'}'})(.)(??{print$5})/x;print"\n"
Re: the currying operator
On Fri, Aug 11, 2000 at 01:47:12PM +0100, Piers Cawley wrote: /^_/ What is that matching ? We've done this. It's matching a string that begins with '_'. Which is why, if you want to disambiguate you do /^{_}/ just like you do with variables. No that won't work either. That matches the string {_} It is the fact that ^ is the first char of the re that causes to to be interpreted as a re special char. So I would suggest something like one of : _ Not sure about :, but how you do distinguish between _foo = placeholder and _foo = _foo? Ah yes _ is out Graham.
Re: the currying operator
Graham Barr [EMAIL PROTECTED] writes: On Fri, Aug 11, 2000 at 01:47:12PM +0100, Piers Cawley wrote: /^_/ What is that matching ? We've done this. It's matching a string that begins with '_'. Which is why, if you want to disambiguate you do /^{_}/ just like you do with variables. No that won't work either. That matches the string {_} No, \{_\} matches the string {_}. Damn, it doesn't. How annoying. Well, it *should* be that way, and it shouldn't be too hard to make it that way. He said hopefully... It is the fact that ^ is the first char of the re that causes to to be interpreted as a re special char. So I would suggest something like one of : _ Not sure about :, but how you do distinguish between _foo = placeholder and _foo = _foo? Ah yes _ is out And : is being mooted for all sorts of other stuff elsewhere. My current thinking is that ^_ is the best of a not desperately good load of options. -- Piers
Re: the currying operator
"Graham" == Graham Barr [EMAIL PROTECTED] writes: Graham No that won't work either. That matches the string {_} But that's arguably a DWIMmy thing, since {} is in the category of * + and ?, which always need to be *after* something, and there's no *something* here. I don't know how much stuff this would break, but I know I always backwhack my {'s regardless of where they are located in the regex, not counting on the DWIM to do it right. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Re: the currying operator
On Fri, Aug 11, 2000 at 02:03:47PM +0100, Graham Barr wrote: On Fri, Aug 11, 2000 at 01:47:12PM +0100, Piers Cawley wrote: /^_/ What is that matching ? We've done this. It's matching a string that begins with '_'. Which is why, if you want to disambiguate you do /^{_}/ just like you do with variables. No that won't work either. That matches the string {_} It is the fact that ^ is the first char of the re that causes to to be interpreted as a re special char. Just to confuse things further, if RFC 72 (backwards regexps) is accepted, then ^ may have this special meaning of "beginning of target string" even in the middle of the regexp. Peter
Re: the currying operator
On Fri, Aug 11, 2000 at 02:52:32AM -0700, Nathan Wiger wrote: Mike- Jeremy's got a great explanation of this, which I'll paraphrase, but the discussion went through lots of iterations. Think of the ^ as a carat or I only make this annoying and pedantic point because everyone I have seen discussing this has made the same mistake so far: ^ is not a gemological carat, nor a vegetable carrot, but a "caret". This is a Latin verb that means "it is lacking or missing", which, if you think about it is yet another reason it makes a good symbol for a placeholder. Peter
Re: the currying operator
Piers Cawley wrote: Graham Barr [EMAIL PROTECTED] writes: On Fri, Aug 11, 2000 at 01:47:12PM +0100, Piers Cawley wrote: /^_/ What is that matching ? We've done this. It's matching a string that begins with '_'. Which is why, if you want to disambiguate you do /^{_}/ just like you do with variables. No that won't work either. That matches the string {_} Damian and I put this example into the RFC explicitly. I like what I wrote the first time, so I'll just repeat it: =head2 Resolving ambiguity The following is ambiguous: $check_start = $somestring =~ /^_foobar/; This should be interpreted as an immediate pattern match for '_foobar' at the start of a string. To cause this to be interpreted as a higher order function, the ambiguity must be resolved through using braces: $check_start = $somestring =~ /^{_}foobar/; which creates a higher order function testing for its argument, followed by 'foobar', anywhere in $somestring. That is: $check_start = sub { $somestring =~ /$_[0]foobar/ }; It wouldn't be too hard to get P52P6 to recognise ^{something} in a regex and quote it, would it? (And to make the quoting work properly...) I was hoping that the use of {} would seem reasonably intuitive given the similarity to their use in resolving ambiguity in dereferencing and interpoling variables.
Re: the currying operator
I like the idea of currying, it seems powerful and Perlish in many ways. However, I don't like the currying operator chosen, because of it's ugliness (IMHO), and its potential for ambiguity (human, not necessarily parser). It's not an operator, it's a placeholder. So, here is my proposal to change the operator. from to --- ^_^^ ^2, ^3^^2, ^^3 ^named^^named To me, it stands out better, and is less likely to cause the programmer looking at it to scratch his head and try to figure out if it's an xor or a curry. I did it myself several times, and I consider myself at least a competent programmer. We chose the placeholder notation to be consistent with the scalar notation (but using a ^ rather than a $): scalar placeholder analog $x, $y^x, ^y $1, $2^1, ^2 $_^_ The RFC should probably say that explcitly. Damian Damian
Re: the currying operator
On Fri, Aug 11, 2000 at 02:52:32AM -0700, Nathan Wiger wrote: Jeremy's got a great explanation of this, which I'll paraphrase, but the discussion went through lots of iterations. Think of the ^ as a carat or thumbtack, holding the place for later variables. Yea, I ran across the description, and it was well thought-out and describes the decision rather well. However, I am reminded of my first look at the currying syntax. Had I read Jeremy's justification before seeing the example I may have been able to parse it easier, but as it was I had to get past the ^_ and ambiguities with ^. I suspect this is how most people will get their first taste of currying (was that a pun? :). I suppose I can get over it and live with the operators as they are, and so can anyone else, but I would much rather love it than simply live with it. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com --