On Thu, Feb 28, 2002 at 03:30:00PM -0600, Garrett Goebel wrote:
> 
> Hmm... Out of curiosity what kind of user-extensible topicalizer aware
> constructs would you make? 

I'm envisioning something along the lines of: while parsing a file, you
have a C<for> loop through the file and a series of subroutines that
operate on the topic, the current line. 

Or since methods topicalize their object, you might have the ability to
make abbreviated ".methodname()" calls from within one method to other
methods in the same object.

And, since I really want everything to default to topic, there's a good
chance I'll have my own "tprint", "tchomp", etc. 

> And thinking of this in the context of user defined functions, am I
> correct in assuming that we would need to be able to specify
> per-parameter topicalizer awareness? So this would impact whatever
> replaces function prototypes?

Well, we'd certainly need some way to say that a parameter had the
option of defaulting to the current topic. It might work out to
something as simple as:

        sub foo ($bar is topic_default) {
                ...
        }

We'll see.
 
> Larry Wall in Apocalypse 4 writes:
> > A when is the only defaulting construct that pays attention
> > to the current topicalizer regardless of which variable it
> > is associated with.
> 
> Which is fine when there's only one topicalizer. But is the C<when> EXPR's
> current topicalizer awareness limited to the current C<given> scope? 
> Or the scope of any topicalizer which might be later introduced? I.e.,
> will we be able to specify which topicalizers a topicalizee pays
> attention to? Or will all topicalizees be aware of all topicalizers?

As it stands now, there can be only one topic, and it is strictly
limited to the scope of the topicalizer that brought it into being.
Outside the scope of any topicalizer a C<when> matches against $_ (a,e).
When you enter the scope of a topicalizer, C<when> matches against that
topicalizer's topic (b,c). When you leave the scope of a topicalizer,
the topic returns to whatever it was in the outer scope, so after we
leave the scope of "given 'baz'" the topic is $x again (d), and after we
leave the scope of "given 'bar'", the topic is $_ again (e). (Larry can
confirm/deny (d), it's a deduction of behavior based on A4).

        $_ = 'foo';
        when /a/ {...} # matches against $_
        given 'bar' -> $x {
                when /b/ {...} # matches against $x
                given 'baz' -> $y {
                        when /c/ {...} # matches against $y
                }
                when /d/ {...} # matches against $x (again)
        }
        when /e/ {...} # matches against $_ (again)

This makes topic quite different from $_. Instead of being constantly
clobbered unless you "my" it, topic is always self-preserving.

But much is still left to be decided. The notion of "topic" will develop
over time. Topic may not be the only form of new default we get
("assumed"). A third default may come with a third set of rules. 

Allison

Reply via email to