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
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:
> "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]
> 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
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
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
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
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?