Re: Unifying invocant and topic naming syntax

2002-11-21 Thread Me
[perhaps] : bare blocks (even those passed as args) just : pick up from the surrounding lexical context. This is definitely a significant simplification. Is it a problem? Yes, that's the problem. A bare block would have to notice at run time that it was called with unexpected arguments and

Re: Unifying invocant and topic naming syntax

2002-11-21 Thread Larry Wall
On Thu, Nov 21, 2002 at 11:27:07AM -0600, Me wrote: : And documenting this by the '-' distinction : described above (ie - means private $_ set : by mumble, no - means $_ is just the outer : lexical) would look natural as well being : logical and strikingly simple. It would, however, force people

RE: Unifying invocant and topic naming syntax

2002-11-21 Thread Martin D Kealey
On Thu, 2002-11-21 at 20:11, Brent Dax wrote: Are you suggesting this? if($error) { use visible 'croak'; require Carp; import Carp: 'croak'; croak($error); } No - that would be pointless as well as error-prone. My idea

Re: Unifying invocant and topic naming syntax

2002-11-21 Thread Me
Are you suggesting this? if($error) { use visible 'croak'; require Carp; import Carp: 'croak'; croak($error); } No - that would be pointless as well as error-prone. My idea of visible is that it would make a lexically scoped thing accessible to an inner dynamic scope at

Re: Unifying invocant and topic naming syntax

2002-11-20 Thread Andy Wardley
Me wrote: Well, I could argue that c) already exists in the form of passing parameters in parens. This reminds me of the Law of Demeter. It specifies what your methods should and shouldn't be able to do if you want to build a bright, shiny system that never has bugs, maintains itself, turns

Re: Unifying invocant and topic naming syntax

2002-11-20 Thread Larry Wall
On Tue, Nov 19, 2002 at 03:09:40PM -0600, Allison Randal wrote: : Larry wrote: : I'm trying to remember why it was that we didn't always make the first : argument of any sub the topic by default. I think it had to do with : the assumption that a bare block should not work with a copy of $_

RE: Unifying invocant and topic naming syntax

2002-11-20 Thread Martin D Kealey
On Wed, 2002-11-20 at 15:01, Brent Dax wrote: We need that capability if we're going to have lexically-scoped exports: Whilst it would be useful for pragmatic modules to access anything and everything in the current compilation scope, I submit that access to dynamic scope should (in general) be

Re: Unifying invocant and topic naming syntax

2002-11-20 Thread Austin Hastings
--- Larry Wall [EMAIL PROTECTED] wrote: ... This might work now, presuming sub foo (;$_ = $=) (or whatever) is really a binding, and not an assignment. (That's another reason why //= is *wrong*--it implies assignment.) Umm, that's what it was supposed to do. IOW: sub($param //=

Re: Unifying invocant and topic naming syntax

2002-11-20 Thread Luke Palmer
Date: Wed, 20 Nov 2002 12:11:52 -0800 (PST) From: Austin Hastings [EMAIL PROTECTED] --- Larry Wall [EMAIL PROTECTED] wrote: ... This might work now, presuming sub foo (;$_ = $=) (or whatever) is really a binding, and not an assignment. (That's another reason why //=

Re: Unifying invocant and topic naming syntax

2002-11-20 Thread Me
$_ = 1; mumble { $_ = 2 }; print; will print 1 or 2? Least surprise, visually, is obviously 2. This would be true if bare blocks (even those passed as args) just pick up from the surrounding lexical context. And if that were true, mumble presumably could not do anything about this

Re: Unifying invocant and topic naming syntax

2002-11-20 Thread Larry Wall
On Wed, Nov 20, 2002 at 04:20:07PM -0600, Me wrote: : $_ = 1; mumble { $_ = 2 }; print; : : will print 1 or 2? : : Least surprise, visually, is obviously 2. : : This would be true if bare blocks (even : those passed as args) just pick up from : the surrounding lexical context. And if :

RE: Unifying invocant and topic naming syntax

2002-11-20 Thread Brent Dax
Martin D Kealey: # On Wed, 2002-11-20 at 15:01, Brent Dax wrote: # We need that capability if we're going to have lexically-scoped # exports: # # Whilst it would be useful for pragmatic modules to access # anything and everything in the current compilation scope, I # submit that access to

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Me
don't understand when one could do the 'is given($_)' and not do the ($_ = $_). Any time that the caller's topic isn't supposed to be explicitly passed as an argument, but is still used within the subroutine. [example] And, yes, I could make it an optional argument, but them I have

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Andy Wardley
Larry Wall wrote: So I was thinking it'd be better to use something different to represent the outer topic... How about this: $_ # current topic $__ # outer topic $___ # outer outer topic ...etc... I also wondered if $= might be a suitable alias to the current

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Tanton Gibbs
How about this: $_ # current topic $__ # outer topic $___ # outer outer topic Unfortunately, or maybe fortunately, that is impossible to read correctly without having to move the cursor and count how many underscores exist. It seems to me, that in English, it is

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Dan Sugalski
At 6:56 AM -0500 11/19/02, Tanton Gibbs wrote: How about this: $_ # current topic $__ # outer topic $___ # outer outer topic Unfortunately, or maybe fortunately, that is impossible to read correctly without having to move the cursor and count how many underscores

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Me
$_ # current topic $__ # outer topic $___ # outer outer topic [not sufficiently visibly distinct] [too much anyway] Agreed. Returning to the topic of binding/copying from a caller to a callee, what about using square brackets to mark implicit args thus:

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Allison Randal
To summarize, we're discussing 3 features: a) the ability to set the topic with a block (sub, method, etc) b) the ability to set a default value for a parameter c) the ability to break lexical scope 1) for $_ only 2) for any variable Each of these features already have syntax that allows

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Allison Randal
Larry wrote: I'm trying to remember why it was that we didn't always make the first argument of any sub the topic by default. I think it had to do with the assumption that a bare block should not work with a copy of $_ from the outside. I dug through the archives. We were considering

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Austin Hastings
So what's wrong with: sub foo($param is topic //= $= // 5)# Shorter form with $= sub foo($param is topic //= $CALLER::_ // 5) It doesn't really seem like we can make it much shorter. Yes, we could convert //= into a single character, but why? People will understand //=. The idea of $= as

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Austin Hastings
--- Allison Randal [EMAIL PROTECTED] wrote: Larry wrote: I'm trying to remember why it was that we didn't always make the first argument of any sub the topic by default. I think it had to do with the assumption that a bare block should not work with a copy of $_ from the outside.

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Allison Randal
Austin wrote: For methods, will that be the invocant or the first other parameter? $string.toLanguage(french) Topic is $string, or french ? It is the invocant. Allison

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Allison Randal
On Tue, Nov 19, 2002 at 01:24:30PM -0800, Austin Hastings wrote: So what's wrong with: sub foo($param is topic //= $= // 5)# Shorter form with $= sub foo($param is topic //= $CALLER::_ // 5) It doesn't really seem like we can make it much shorter. Yes, we could convert //= into a

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Deborah Ariel Pickett
Ah . . . one message with two things I wanted to talk about. Good. Allison wrote: On Tue, Nov 19, 2002 at 01:24:30PM -0800, Austin Hastings wrote: So what's wrong with: sub foo($param is topic //= $= // 5)# Shorter form with $= sub foo($param is topic //= $CALLER::_ // 5)

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Austin Hastings
--- Allison Randal [EMAIL PROTECTED] wrote: On Tue, Nov 19, 2002 at 01:24:30PM -0800, Austin Hastings wrote: So what's wrong with: sub foo($param is topic //= $= // 5)# Shorter form with $= sub foo($param is topic //= $CALLER::_ // 5) It doesn't really seem like we can make it

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Allison Randal
Austin wrote: The idea of $= as CALLER::_ is good, though. Though C//= $= // is a nasty sequence. Final // only required for another default: //= $= // 5 # Default to $CALLER::_, or 5 Aye, it's just a worst case scenario. C//= $= and C= $= are still line-noisy. It's a trade-off

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Austin Hastings
--- Deborah Ariel Pickett [EMAIL PROTECTED] wrote: Ah . . . one message with two things I wanted to talk about. Good. Allison wrote: On Tue, Nov 19, 2002 at 01:24:30PM -0800, Austin Hastings wrote: So what's wrong with: sub foo($param is topic //= $= // 5)# Shorter form with

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Me
c) the ability to break lexical scope Well, I could argue that c) already exists in the form of passing parameters in parens. Of course, that doesn't feel like breaking anything. So instead I'll argue that the word break is perhaps prejudicially perjorative. I'd say, to steer away from being

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Me
inheriting a caller's topic isn't going to be that common a thing that it needs such a short name, is it? 15% of the perl 5 builtins do so. I have suggested that, in some extreme scenarios such as short scripts, perhaps as many as 50% of subs might do so. But then again I probably ate a lot

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Mark J. Reed
On 2002-11-19 at 16:44:49, Me wrote: Elements of this shared vocabulary might be called 'locals' or 'yours'. I like the 'yours' idea from the point of view of the callee: my $inherited = your $_; However, I also like the idea of having to mark shareable lexicals explicitly in the

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Me
Elements of this shared vocabulary might be called 'locals' or 'yours'. I like the 'yours' idea from the point of view of the callee: my $inherited = your $_; I like that syntax, but I'm uncomfortable with an underlying principle, which is that one can reach in to the caller's

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Allison Randal
Me wrote: c) the ability to break lexical scope Well, I could argue that c) already exists in the form of passing parameters in parens. Of course, that doesn't feel like breaking anything. Formal parameters are lexically scoped. Lexical scope: references to the established entity can

RE: Unifying invocant and topic naming syntax

2002-11-19 Thread Brent Dax
Me: # Elements of this shared vocabulary might be # called 'locals' or 'yours'. # # I like the 'yours' idea from the point of # view of the callee: # # my $inherited = your $_; # # I like that syntax, but I'm uncomfortable # with an underlying principle, which is that # one can

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Me
# I'm uncomfortable [that] # one can reach in to the caller's lexical # context from any place in a callee's body. We need that capability if we're going to have lexically-scoped exports: I think I was a bit careless in how I worded that. My problem is not that one reaches in to the

RE: Unifying invocant and topic naming syntax

2002-11-19 Thread Brent Dax
Me: # I am thinking one should have to predeclare # in a sub's preamble that such a trick will # be going on. # # Thus something like: # # sub foo [bar] { ... } # # is (part of what is) required to be allowed # to create a bar sub in the context of the # caller of foo. So how does Exporter

Re: Unifying invocant and topic naming syntax

2002-11-19 Thread Me
# I am thinking one should have to predeclare # in a sub's preamble that such a trick will # be going on. # # Thus something like: # # sub foo [bar] { ... } # # is (part of what is) required to be allowed # to create a bar sub in the context of the # caller of foo. So how does

Re: Unifying invocant and topic naming syntax

2002-11-18 Thread Larry Wall
On Mon, Nov 18, 2002 at 08:05:47AM +1100, Damian Conway wrote: : I still think my original: : : sub bar(; $foo = $topic) is given($topic) {...} : : is the appropriate compromise. Won't fly. Referring to something lexical before it's declared is a no-no. I think we need some other way of

Re: Unifying invocant and topic naming syntax

2002-11-18 Thread Damian Conway
Larry Wall wrote: On Mon, Nov 18, 2002 at 08:05:47AM +1100, Damian Conway wrote: : I still think my original: : : sub bar(; $foo = $topic) is given($topic) {...} : : is the appropriate compromise. Won't fly. Referring to something lexical before it's declared is a no-no. I would maintain

RE: Unifying invocant and topic naming syntax

2002-11-18 Thread Brent Dax
Damian Conway: # Larry Wall wrote: # On Mon, Nov 18, 2002 at 08:05:47AM +1100, Damian Conway wrote: # : I still think my original: # : # : sub bar(; $foo = $topic) is given($topic) {...} # : # : is the appropriate compromise. # # Won't fly. Referring to something lexical before it's

Re: Unifying invocant and topic naming syntax

2002-11-18 Thread Me
Larry: sub bar(; $foo = topicmumble) {...} Damian: topic [would be] Cundef. I assumed topicmumble implied an 'is given'. I don't see why it couldn't. Damian: Hm. Given that the topic is in some sense a property of the lexical scope of the subroutine body, this might be a

Re: Unifying invocant and topic naming syntax

2002-11-18 Thread Larry Wall
On Tue, Nov 19, 2002 at 07:45:25AM +1100, Damian Conway wrote: : What mumble might be is an interesting, er, topic. : : I would argue it ought to be just $_, which is, after all, : the One True Topic. And conveniently lexically predeclared in all scopes. : : I would also argue that it ought not

Re: Unifying invocant and topic naming syntax

2002-11-18 Thread Damian Conway
Larry wrote: The long and the short of it was that my sub foo ($_ := $arg = $_) is how you might set $arg to be both the topic and the given. Wow. I'm surprised by how much I don't like that syntax! ;-) I mean, two entirely different meanings for $_ in the space of one parameter

Re: Unifying invocant and topic naming syntax

2002-11-18 Thread Me
my sub foo ($_ = $_) to just propagate the outer $_ inward. That only works when $_ can somehow be shoe-horned into the parameter list. Whereas: my sub foo is given($_) works for *any* parameter list. Other than the placeholder situation, I don't understand when one

Re: Unifying invocant and topic naming syntax

2002-11-18 Thread Damian Conway
ralph wrote: Other than the placeholder situation, I don't understand when one could do the 'is given($_)' and not do the ($_ = $_). Any time that the caller's topic isn't supposed to be explicitly passed as an argument, but is still used within the subroutine. For example, the

Re: Unifying invocant and topic naming syntax

2002-11-17 Thread Damian Conway
Adam D. Lopresto wrote: It seems like that would be useful and common enough to write as sub bar(;$foo is given) { ... } Where $foo would then take on the caller's topic unless it was explicitly passed an argument. While I can certainly see the utility of that, I believe it is too

Re: Unifying invocant and topic naming syntax

2002-11-17 Thread Adam D. Lopresto
My favorite was from ages ago: sub bar(;$foo //= $_) {...} I think that today that would be written more like this: sub bar(;$foo) is given($def_foo) { $foo = $def_foo unless exists $foo; ... } Though we might get away with:

Re: Unifying invocant and topic naming syntax

2002-11-16 Thread Damian Conway
Luke Palmer wrote: My favorite was from ages ago: sub bar(;$foo //= $_) {...} I think that today that would be written more like this: sub bar(;$foo) is given($def_foo) { $foo = $def_foo unless exists $foo; ... } Though we might get away with: sub bar(;$foo = $def_foo) is

Re: Unifying invocant and topic naming syntax

2002-11-16 Thread Damian Conway
Andrew Wilson wrote: It's the difference between this: print; and this: print $_; It is as far as I'm concerned exactly what topic is all about. Exactly. It let's you write subroutines that behave like builtins with respect to $_. I think it's generally intended to be used like so:

Re: Unifying invocant and topic naming syntax

2002-11-16 Thread Damian Conway
Acadi asked: Just ( my ) terminology clean-up : in this example sub{ } is implicit topicalizer No. It isn't a topicalizer at all. ( it does not set $_ explicitly ) Or implicitly. and you are setting $_ for perl . Yes. that's why you can use when . Yes. is this valid ? (morning()

Re: Unifying invocant and topic naming syntax

2002-11-15 Thread fearcadi
Damian Conway writes: Micholas Clarke asked: If a subroutine explicitly needs access to its invocant's topic, what is so wrong with having an explicit read-write parameter in the argument list that the caller of the subroutine is expected to put $_ in? Absolutely nothing. And

Re: Unifying invocant and topic naming syntax

2002-11-14 Thread Damian Conway
Micholas Clarke asked: If a subroutine explicitly needs access to its invocant's topic, what is so wrong with having an explicit read-write parameter in the argument list that the caller of the subroutine is expected to put $_ in? Absolutely nothing. And perfectly legal. You can even call that

Re: Unifying invocant and topic naming syntax

2002-11-13 Thread Larry Wall
On Mon, Nov 11, 2002 at 11:48:06PM -0600, Me wrote: : Are placeholders only usable with anonymous : subs, or named subs too? Placeholders are not intended for use with named subs, since named subs have a way of naming their parameters in a more readable fashion. However, it may well fall out that

Re: Unifying invocant and topic naming syntax

2002-11-13 Thread Nicholas Clark
Apologies for raising the dead (horse) On Thu, Nov 07, 2002 at 03:27:51PM -0600, Me wrote: Damian: [it will be passed to about 5% of subs, regardless of whether the context is your 10 line scripts or my large modules] If the syntax for passing it to a sub remains as verbose as it

Re: Unifying invocant and topic naming syntax

2002-11-13 Thread Luke Palmer
Date: Wed, 13 Nov 2002 20:34:49 + From: Nicholas Clark [EMAIL PROTECTED] If a subroutine explicitly needs access to its invocant's topic, what is so wrong with having an explicit read-write parameter in the argument list that the caller of the subroutine is expected to put $_ in?

Access to caller's topic (was Re: Unifying invocant and topic naming syntax)

2002-11-13 Thread Me
access caller's topic is an unrestricted licence to commit action at a distance. Right. Perhaps: o There's a property that controls what subs can do with a lexical variable. I'll call it Yours. o By default, in the main package, topics are set to Yours(rw); other lexicals are set

Re: Unifying invocant and topic naming syntax

2002-11-13 Thread Andrew Wilson
On Wed, Nov 13, 2002 at 08:34:49PM +, Nicholas Clark wrote: If a subroutine explicitly needs access to its invocant's topic, what is so wrong with having an explicit read-write parameter in the argument list that the caller of the subroutine is expected to put $_ in? It's the difference

Re: Unifying invocant and topic naming syntax

2002-11-11 Thread Damian Conway
ralph wrote: If the syntax for passing it to a sub remains as verbose as it currently is, you are probably right that it won't be used to achieve brevity! You're confusing brevity of declaration with brevity of use. Declarations should always be relatively verbose. Why do you think your

Re: Unifying invocant and topic naming syntax

2002-11-11 Thread Me
You're confusing brevity of declaration with brevity of use. One needs sufficient brevity of both call and declaration syntax if the mechanism's brevity is to be of use in short scripts. Making (limited) circumvention of [$_'s lexicality] depend on a verbose and explicit syntax will help

Re: Unifying invocant and topic naming syntax

2002-11-11 Thread Damian Conway
ralph wrote: So what is driving you guys to deliberately avoid a brief def syntax? Can't speak for Larry. But what's driving me is the desire to balance conciseness with comprehensibility, and to keep the overall cognitive load manageable. If you're proposing that there be some special

Re: Unifying invocant and topic naming syntax

2002-11-11 Thread Me
method f ($self : $a) { ... } sub f ($a) is given ($line) { ... } what do you call $self The invocant. and $line? A lexical variable that happens to be bound to the caller's topic. The invokit perhaps? placeholders create subroutines, not methods. Oh. Are

Re: Unifying invocant and topic naming syntax

2002-11-07 Thread Damian Conway
ralph wrote: My estimate (based on the -- not inconsiderable -- code base of my own modules) is closer to 5%. Your estimate of what others will do when knocking out 10 line scripts in a hurry, or what's in your current p5 modules? Both. Can currying include the given topic? sub bar

Re: Unifying invocant and topic naming syntax

2002-11-07 Thread Me
Damian: [it will be passed to about 5% of subs, regardless of whether the context is your 10 line scripts or my large modules] If the syntax for passing it to a sub remains as verbose as it currently is, you are probably right that it won't be used to achieve brevity! I think it's a pity

Re: Unifying invocant and topic naming syntax

2002-11-05 Thread Damian Conway
ralph hypothesized: My imagination suggests to me that in a typical short perl 6 script, between 20% and 50% of all sub defs would use the upscope topic... ; That's some imagination you've got there! ;-) My estimate (based on the -- not inconsiderable -- code base of my own modules) is closer

Re: Unifying invocant and topic naming syntax

2002-11-05 Thread Allison Randal
On Tue, Nov 05, 2002 at 05:13:45AM -0600, Me wrote: relatively few subroutines need access to the upscope topic. Well, this is a central issue. What are the real percentages going to be here? Just how often will one type the likes of - is given($foo is topic) { ... } rather

Re: Unifying invocant and topic naming syntax

2002-11-04 Thread Allison Randal
On Sun, Nov 03, 2002 at 11:17:32PM -0600, Me wrote: I started with a simple thought: is given($foo) seems to jar with given $foo { ... } One pulls in the topic from outside and calls it $foo, the other does the reverse -- it pulls in $foo from the outside and makes it the

Re: Unifying invocant and topic naming syntax

2002-11-04 Thread Me
(naming) the invocant of a method involves something very like (naming) the topic Generally, there's no conceptual link... other than The similarity is that both are implicit parameters which was my point. Almost the entirety of what I see as relevant in the context of deciding

Re: Unifying invocant and topic naming syntax

2002-11-04 Thread Damian Conway
ralph wrote: It's clear you could have come up with something like one of these: method f ($a, $b) is invoked_by($self) method f ($a, $b) is invoked_by($self is topic) method f ($a, $b) is invoked_by($_) but you didn't. Any idea why not? Because most methods need some kind of

Unifying invocant and topic naming syntax

2002-11-03 Thread Me
I read Allison's topicalization piece: http://www.perl.com/pub/a/2002/10/30/topic.html I started with a simple thought: is given($foo) seems to jar with given $foo { ... } One pulls in the topic from outside and calls it $foo, the other does the reverse -- it pulls in $foo from