Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-08 Thread Jeremy Howard
> > > As for the regexp issue, just to clarify there's only one ambiguous case > > > we need to work out that I can see: > > > > > >/.*^foo/; # ok > > > >But: /.*^foo/m; #ambiguous > > Hold it. What does this mean? Is the whole regex gonna be turned into an > anonymous sub, or what?

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-08 Thread Bart Lateur
On Tue, 8 Aug 2000 13:30:22 +1000 (EST), Damian Conway wrote: > > As for the regexp issue, just to clarify there's only one ambiguous case > > we need to work out that I can see: > > > >/.*^foo/; # ok > >But: /.*^foo/m; #ambiguous Hold it. What does this mean? Is the whole rege

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Nathan Wiger
> I'd agree to the contrapositive: if we have named placeholders, I don't see the > need for positional ones too. But I'm willing to be convinced. The below, with > positional only, is total gibberish, as Ken points out. To most, probably, but I say let the user decide. Like Jeremy points out:

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Glenn Linderman
Jeremy Howard wrote: > Damian Conway wrote: > > Personally, if we have positional placeholders I don't see the need > > for named ones too. But I'm willing to be convinced. I'd agree to the contrapositive: if we have named placeholders, I don't see the need for positional ones too. But I'm will

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Jeremy Howard
Damian Conway wrote: >> And there's no argument about having anonymous, positional, and named >> placeholders in the redraft...? > > There's *always* arguments! ;-) > Although arguments from the RFC author are generally more compelling ;-) > Personally, if we have positional placeholders

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Damian Conway
> And there's no argument about having anonymous, positional, and named > placeholders in the redraft...? There's *always* arguments! ;-) Personally, if we have positional placeholders I don't see the need for named ones too. But I'm willing to be convinced. Damian

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Jeremy Howard
>> We could undo the ambiguity like so: >> >>/^{foo}/; # like ${foo} and @{foo} and %{foo} >> >> In fact, this seems built-in if we follow the same var conventions. We >> can make ^ bind to {} as tightly as we need. > > That would be the right solution. And of course

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Damian Conway
> As for the regexp issue, just to clarify there's only one ambiguous case > we need to work out that I can see: > >/.*^foo/; # ok But:/.*^foo/m; #ambiguous > We could undo the ambiguity like so: > >/^{foo}/; # like ${foo} and @{foo} and %{foo} > >

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Nathan Wiger
> So is this a consensus?: > > It is proposed that Perl introduce a new prefix '^', which indicates a > placeholder. This can be used in any of the following ways: > - ^identifier: named placeholder > - ^_: anonymous placeholder > - ^0, ^1, ...: positional placeholder. I think this sounds go

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Chaim Frenkel
It shouldn't be a problem. *_ would then be a 'special' reserverd identifier. *_name could be a named placeholder. > "JH" == Jeremy Howard <[EMAIL PROTECTED]> writes: JH> John Porter wrote: >> Has anyone suggested '*'? Since its use for typeglobs is (repsumably) >> going away, it's avail

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Peter Scott
At 08:19 AM 8/8/00 +1000, Jeremy Howard wrote: >John Porter wrote: > > Has anyone suggested '*'? Since its use for typeglobs is (repsumably) > > going away, it's available (right?). > > > > It the "wildcard" mnemonic value is consistent with "placeholder". > > >Yes, it's been suggested, but we mi

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Jeremy Howard
John Porter wrote: > Has anyone suggested '*'? Since its use for typeglobs is (repsumably) > going away, it's available (right?). > > It the "wildcard" mnemonic value is consistent with "placeholder". > Yes, it's been suggested, but we might be too late on that one--another RFC suggests reserving

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread John Porter
Has anyone suggested '*'? Since its use for typeglobs is (repsumably) going away, it's available (right?). It the "wildcard" mnemonic value is consistent with "placeholder". -- John Porter

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread John Porter
Nathan Wiger wrote: > > Yeah, I personally can read this much clearer. Peter also mentions that > __ is hard to distinguish from _, unless they're right next to each > other, and I think this is a very valid point. This biggest problem with '__', imho, is that '_' is a valid identifier character

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread John Porter
Jeremy Howard wrote: > Yes, I change my mind . I like the '^' prefix > too. The difficulty of reading __ would be a pain. But what happens here? /^__foo/ Or here? /^{__}foo/ Is the latter sufficiently unambiguous? -- John Porter

Re: RFC 23 (v1) Higher order functions

2000-08-07 Thread John Porter
Ken Fox wrote: > > I think we need a curry context and that all curries must be surrounded > by parens. > . > sub traverse ($_); > my $sum = 0; > $root->traverse(($sum += __)); I think parens may be problematic, since nested lists flatten. Maybe curlies could be overloaded yet again?

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Jonathan Scott Duff
On Mon, Aug 07, 2000 at 02:53:17PM +0200, Bart Lateur wrote: > On Sun, 06 Aug 2000 17:35:17 -0700, Nathan Wiger wrote: > > >I > >think the concept's great, just that the notation is really hard to > >read, and doesn't necessarily scream "function" to me (especially since > >_ is from stat already

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Bart Lateur
On Sun, 06 Aug 2000 21:54:47 -0700, Nathan Wiger wrote: >Seems to me that a leading _ is worse for this than ^ Whatever prefix you choose, it should NEVER EVER be a \w character. And the general rule, until now at least, is that only characters from the ASCII repertoire are acceptable for proga

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-07 Thread Bart Lateur
On Sun, 06 Aug 2000 17:35:17 -0700, Nathan Wiger wrote: >I >think the concept's great, just that the notation is really hard to >read, and doesn't necessarily scream "function" to me (especially since >_ is from stat already). I don't see why you can't simply use _. From the context, you clearly

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Jeremy Howard
Ken Fox wrote: > Jeremy Howard wrote: > > Anyhoo, there's no reason why you can't have ^1, ^2, and so forth, _and_ > > allow named placeholders too. Although I don't see what this buys you. > > Argument ordering. We might be constrained by the caller as to what order > the placeholders are passed

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Mike Pastore
Ken Fox wrote: > > my $f = (^x < ^max) ? ^x * ^scale : ^y * ^scale; > > has to be called > > &$f($x, $max, $scale, $y) Hmm, perhaps we can use those named placeholders when calling the function by a hash. And instead of generating a complete new code reference, we can simply "build up" our

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Ken Fox
Jeremy Howard wrote: > Anyhoo, there's no reason why you can't have ^1, ^2, and so forth, _and_ > allow named placeholders too. Although I don't see what this buys you. Argument ordering. We might be constrained by the caller as to what order the placeholders are passed in. Also, we want to make

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Nathan Wiger
> > There's two potential solutions here: > > 1- Use '_' > > 2- Use '^', but increase the strictness of sub calls > > > The second suggestion specifically relies on us deciding that barewords are > > always evil, so that : > > $a = foo; # Error! Evil bareword! Return to firey depths of hell!

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Nathan Wiger
> There's two potential solutions here: > 1- Use '_' > 2- Use '^', but increase the strictness of sub calls > > I'd be happy with both. I'm with Damian that '__' looks cool, but I > understand that people typing in perl from a magazine (do people still do > that?) might get confused (mmm... comfy

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Jeremy Howard
Ken Fox wrote: > Actually I was wrong about ^ not working. The binary operator ^ is XOR. > The unary "operator" ^ could be for curries. > Right. I though you were just worried about it looking confusing. I don't think the parser will be bothered (at least, I can't think of anything ambiguous so fa

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Jeremy Howard
> Well, what's the different between the placeholder &foo and the sub > &foo? That's the main reason why. Also, '&' already has a perfectly good > meaning: binary AND with the function foo(). :) Not trying to be a > smartass, but I think you understand what I'm trying to say. Yes. '&' is misleadi

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Ken Fox
Mike Pastore wrote: > Ken Fox wrote: > > > Although, I suppose '&' would not work. > > > > Why not? I think it would work great. > > Well, what's the different between the placeholder &foo and the sub > &foo? That's the main reason why. Also, '&' already has a perfectly good > meaning: binary AND

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Nathan Wiger
> $zot **= ^foo# "what's that binary op doing there.. > # ..oh, that's a placeholder" I think this is a valid way of looking at it. If you think about it, * for typeglobs is the same symbol as * for multiplication. But the parser can figure it out based on context. I don't se

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Damian Conway
I concur with Mike. If we *have* to have a prefix (and I *still* prefer a naked __, gumble, grumble, pout), then I'd certainly rather ^ that &. What we *really* need are some more types of brackets: $range = Ç__È < ÇvalÈ && ÇvalÈ < Ç__È; ;-) Damian

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Mike Pastore
Ken Fox wrote: > > > - ^foo is the placeholder 'foo' > > That already has perfectly good meaning: XOR with the function foo(). Good point. Back to the drawing board? > > Although, I suppose '&' would not work. > > Why not? I think it would work great. Well, what's the different between the p

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Jeremy Howard
> > New programmers should easily understand > > New? You're talking about "new" "easy" and "higher order functions" > in the same sentence? ;) > This was intentional. (Err, yes, it was bait, basically...) Higher order functions are harder for old [procedural] programmers than new ones (IMHO). Ha

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Ken Fox
[Sorry, spent too much time thinking in the editor and did not see this before my reply.] Mike Pastore wrote: > - ^foo is the placeholder 'foo' That already has perfectly good meaning: XOR with the function foo(). > Although, I suppose '&' would not work. Why not? I think it would work great.

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Ken Fox
Jeremy Howard wrote: > It is proposed that Perl introduce a new prefix '_', which indicates a > placeholder. This can be used either as '_identifier', which creates a named > placeholder, or '__', which creates an anonymous placeholder. This is a good idea, but it has a good chance of tripping up

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Mike Pastore
Nathan Wiger wrote: > > I think the principle of a "general purpose placeholder" is a good one. > But I think _ is already used so much in Perl that something else is > better. I like ^ since is looks like a carat ("insert your variable > here"), personally. Or even a thumbtack, holding the vari

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Damian Conway
Okay. I'll rework the proposal with the consensus syntax. Damian

Re: RFC 23 (v1) Higher order functions

2000-08-06 Thread Damian Conway
> But the expression > > __ < 2 + __ * sin(__ / 2) or die __ > > curries to > > sub { $_[0] < 2 + $_[1] * sin(sub { $_[0] / 2 }) or die $_[2] } > > That's very odd. No. You got it exactly right. :-) > I really hope I'm missing something, but __ the way yo

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Jeremy Howard
> > Just as simply, > > > > - $foo is the variable 'foo' > > - ^foo is the placeholder 'foo' > > - $_ is the default variable > > - ^_ is the default placeholder > > Yeah, I personally can read this much clearer. Peter also mentions that > __ is hard to distinguish from _, unless they're right nex

Re: RFC 23 (v1) Higher order functions

2000-08-06 Thread Ken Fox
Damian Conway wrote: > That should of course have been: > > __ < 2 + __ * atan2($pi, __) or die __ Oh, yes, of course. Um, wait. Nope, I still don't follow. The expression above curries to: sub { $_[0] < 2 + $_[1] * atan2($pi, $_[2]) or die $_[3] } But the expression __ < 2 + __ * sin(__

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Nathan Wiger
> Just as simply, > > - $foo is the variable 'foo' > - ^foo is the placeholder 'foo' > - $_ is the default variable > - ^_ is the default placeholder Yeah, I personally can read this much clearer. Peter also mentions that __ is hard to distinguish from _, unless they're right next to each other,

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Mike Pastore
Jeremy Howard wrote: > > New programmers should easily understand that: > - $foo is the variable 'foo' > - _foo is the placeholder 'foo' > - $_ is the default variable > - __ is the default placeholder. > Then, when they see the same named placeholder appear twice in the same > higher-ord

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Peter Scott
At 05:35 PM 8/6/00 -0700, Nathan Wiger wrote: >Can I make one observation? Maybe I'm the only one. > >I find the __ *really* hard to follow. I've been trying to keep up with >this discussion, but it's really chewing me up. > >Since this is really something different (not a scalar, hash, etc), has

Re: Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Jeremy Howard
> I find the __ *really* hard to follow. I've been trying to keep up with > this discussion, but it's really chewing me up. > > Since this is really something different (not a scalar, hash, etc), has > any consideration been given to other variable names: > >^_ >&_ # kinda like this

Different higher-order func notation? (was Re: RFC 23 (v1) Higher order functions)

2000-08-06 Thread Nathan Wiger
> The error was not here but in: > >__ < 2 + __ * atan($pi/__) or die __ > > That should of course have been: > >__ < 2 + __ * atan2($pi, __) or die __ Can I make one observation? Maybe I'm the only one. I find the __ *really* hard to follow. I've been trying to keep up with this disc

Re: RFC 23 (v1) Higher order functions

2000-08-06 Thread Damian Conway
> > $root->traverse( $sum += __ ); > > There's a syntactic ambiguity here. I assumed that __ "poisons" an > expression so that an entire parse tree gets transformed into a > closure. If you isolate the parse tree based on expression precedence, > then I'm not sure wh

Re: RFC 23 (v1) Higher order functions

2000-08-05 Thread Glenn Linderman
Jeremy Howard wrote: > New programmers should easily understand that: > - $foo is the variable 'foo' > - _foo is the placeholder 'foo' > - $_ is the default variable > - __ is the default placeholder. > Then, when they see the same named placeholder appear twice in the same > higher-order

Re: RFC 23 (v1) Higher order functions

2000-08-05 Thread Jeremy Howard
> It is proposed that Perl reserve the bareword C<__> (underscore-underscore) > as a "placeholder" for generating higher order functions more cleanly. > But what if I want to say: @n = (0.2, 1, 3.5, 4); @integersInN = grep __=abs(__) @n; # @intsInN is empty! Instead I would need: @integersI

Re: RFC 23 (v1) Higher order functions

2000-08-04 Thread Jeremy Howard
Ken Fox wrote: > And neither did you... ;) The last line should be: > > : $_[0] < 2 + $_[1] * atan($pi/$_[2]) or die $_[3] > > That's why curried functions should automatically re-curry themselves > instead of depending upon lazy programmers. ;) > But of course I only included thi

Re: RFC 23 (v1) Higher order functions

2000-08-04 Thread Damian Conway
> Unless I'm missing something here, you're not filling in the args correctly. > I think you mean: > > $check = sub (;) { > @_==0 ? __ < 2 + __ * atan($pi/__) or die __ > : @_==1 ? $_[0] < 2 + __ * atan($pi/__) or die __ > : @_==2 ? $_[0] < 2

Re: RFC 23 (v1) Higher order functions

2000-08-04 Thread Damian Conway
Thanks for the useful insights and pointers, Ken. Top stuff (as usual :-) I particularly liked the currying context and notions of explicitly marking curries. Obviously I'll need to de-jetlag a little more and run my brain over it again. However, implicit currying is so damn handy that I suspect

Re: RFC 23 (v1) Higher order functions

2000-08-04 Thread Ken Fox
Jeremy Howard wrote: > Unless I'm missing something here, you're not filling in the args correctly. > I think you mean: > > $check = sub (;) { > @_==0 ? __ < 2 + __ * atan($pi/__) or die __ > : @_==1 ? $_[0] < 2 + __ * atan($pi/__) or die __ > : @_==2 ? $_[0] < 2

Re: RFC 23 (v1) Higher order functions

2000-08-04 Thread Jeremy Howard
> $check = sub (;) { > @_==0 ? __ < 2 + __ * atan($pi/__) or die __ > : @_==1 ? $_[0] < 2 + __ * atan($pi/__) or die __ > : @_==2 ? $_[0] < 2 + $_[1] * atan($pi/__) or die __ > : @_==3 ? $_[0] < 2 + $_[1] * atan($pi/$_[1]) or die __ > : $_

Re: RFC 23 (v1) Higher order functions

2000-08-04 Thread Ken Fox
[Could we get the librarian to cc: the RFC owner and hide replies from the announcement list?] Perl6 RFC Librarian wrote: > That is, the expression: > > $check = __ < 2 + __ * atan($pi/__) or die __; > > is equivalent to: > > $check = sub (;) { > $_[0] < 2

RFC 23 (v1) Higher order functions

2000-08-04 Thread Perl6 RFC Librarian
=head1 TITLE Higher order functions =head1 VERSION Maintainer: Damian Conway <[EMAIL PROTECTED]> Date: 4 August 2000 Version: 1.00 Mailing List: [EMAIL PROTECTED] Number: 23 =head1 ABSTRACT This RFC proposes some syntactic sugar to simplify the creation of higher-order functions (a