On Fri, Sep 03, 2004 at 06:31:49PM -0700, Jonathan Lang wrote:
: I wonder if this notion of contextualizing a method's signature could be
: generalized... I could see a case for treating most methods as if the
: expressions in each parameter were being evaluated within the caller's
: class:
: 
:    scratch $jack: .back
: 
: would be equivalent to
: 
:    $jack.scratch($jack.back)

But wouldn't that mean Jack scratching my back instead of his?
I think we'd have people losing track of the current topic all the
time if we did something like that.

: This isn't quite the same thing as the index operator given above:
: 
:    @ints[.begin + 2, .end - 3]
: 
: would be equivalent to
: 
:    @[EMAIL PROTECTED] + 2, @ints.end - 3]
: 
: by this logic, which isn't what we want.  We'd either have to make this a
: special case or say:
: 
:    @ints[.shape[0].begin + 2, .shape[1].end - 3]
: 
: ...which would be unneccessarily bulky.  OTOH, it would be annoying if we
: had to say
: 
:    @[EMAIL PROTECTED], @ints.shape[0].begin]
: 
: if we wanted to access the index whose first dimension corresponds to the
: lowest bound of the second dimension and vice versa - though why you'd
: ever want to do something like that is beyond me.  Perhaps this is
: appropriate Huffman coding after all...
: 
: How to declare this?  Perhaps you could do something like:
: 
:    method postcircumfix:[] 
:      ($object: [EMAIL PROTECTED] is context($object.shape[$_])) {...}
: 
: where the "context" trait normally has a value of $object in a method. 
: The above is an example of how the thing would be applied to the list
: parameter, with the context being applied to each element in turn and $_
: being set to the list's index for that element; similarly, an anonymous
: named parameter might work the same way, with $_ being set to the
: parameter's key.  Any function that has exactly one invocant would have a
: default context of that invocant for every parameter, while any function
: that has anything _but_ one invocant would have _no_ default parameter
: context - which wouldn't stop programmers from explicitly adding contexts
: where appropriate.  

I think we just need something really short and unconfusing for the
commonest cases, and let people write it out longhand for the others.
Somebody needs to talk me out of using A..Z for the simple cases.

Larry

Reply via email to