Re: Are .key and .value right for Pairs?

2001-10-07 Thread Mark Koopman
Damian Conway wrote: >Very nice. And yes, too many brackets of various kinds. >Also $this doesn't really describe what it stores. >Maybe $first would be better? > as i see it, $first describes what is true of the implementation of passing the object reference, but looking at the $this in the f

Re: Are .key and .value right for Pairs?

2001-10-06 Thread Damian Conway
Very nice. And yes, too many brackets of various kinds. Also $this doesn't really describe what it stores. Maybe $first would be better? And we can also optimize the performance by making the lexicals constant (so the optimizer can hard-wire the method names into the closure). That gives us:

Re: Are .key and .value right for Pairs?

2001-10-06 Thread Randal L. Schwartz
> "Damian" == Damian Conway <[EMAIL PROTECTED]> writes: Too much typing: Damian> module PAIR; Damian> method car { return .key } Damian> method cdr { return .value } Damian> method AUTOVIVIFY (&default, $name) { Damian> if ($name =~ m/^c([ad]

Re: Are .key and .value right for Pairs?

2001-10-05 Thread Damian Conway
> Can I get a .car and a .cdr please? In my limited mind "key" and "value" > are specific to hashes and their wimpy brother associative lists. Sure. Roll-you-own with: module PAIR; method car { return .key } method cdr { return .value } or, if you're really

Re: Are .key and .value right for Pairs?

2001-10-05 Thread Mark J. Reed
On Fri, Oct 05, 2001 at 06:59:52PM -0400, Sam Tregar wrote: > > But you can always define your own accessor methods with whatever > > names you like. :) > > I can? How do I do that? My understanding is that there won't be anything terribly magical about the built-in datatypes/classes. So if you

Re: Are .key and .value right for Pairs?

2001-10-05 Thread Sam Tregar
On Fri, 5 Oct 2001, Mark J. Reed wrote: > Well, "car" and "cdr" don't really fit; the key and value of a pair can be any > type of object, unlike the Lisp case where the cdr is always a list > (while the car can be either a list or an atom). Incorrect - "cdr" can be anything at all, just like

Re: Are .key and .value right for Pairs?

2001-10-05 Thread Mark J. Reed
Well, "car" and "cdr" don't really fit; the key and value of a pair can be any type of object, unlike the Lisp case where the cdr is always a list (while the car can be either a list or an atom). But you can always define your own accessor methods with whatever names you like. :) What's an assoc

Are .key and .value right for Pairs?

2001-10-05 Thread Sam Tregar
Can I get a .car and a .cdr please? In my limited mind "key" and "value" are specific to hashes and their wimpy brother associative lists. -sam Can I get a what what?