Re: can I make a list of records? (OO Theory Hell)
Re: can I make a list of records? (OO Theory Hell)
- Subject: Re: can I make a list of records? (OO Theory Hell)
- From: has <email@hidden>
- Date: Wed, 30 Jan 2002 20:52:10 +0000
Nigel Garvey wrote:
>
>> What you'd expect from a concatentation of three lists - but not if
>
>> MyList is actually an empty record. Maybe {} is interpreted as a list or
>
>> a record according to the circumstances.
>
>
[...]
>
>
[weird Finder behaviour] is different from the current situation, where
>
the {} has been
>
created in AppleScript itself and *can* have its end set, so behaves like
>
an empty list. However, if a record is concatenated to it, the result is
>
a record, not a list, giving the impression that the empty list is really
>
an empty record.
[NOTE: My grip on OO concepts is still spectacularly shaky, so this is more
by way of thinking aloud and hoping someone smarter than me can point out
if/where I'm right/wrong.]
There's a feature of OO languages called "polymorphism" - literally
translated as "many forms". An object can take any of several forms as
needed. This lets another object (the needy one) to interact with it more
easily, and without having to ask it all sorts of embarrassing personal
questions first.
For example:
[Scene One]
Object A : "I am an object, bustling around cleaning house as I do.
Tra-la-la-la-la!"
[Knock at door; from outside a voice shouts]
Object B : "Hi there! I'm an object of the wild partying sort. We
should get together and boogie!"
[Object A thinks "Omigod, I look such a sight in these dirty old overalls!"]
Object A : "Sure thing! Just hang on a moment and I'll be right with
you..."
[Object A changes out of its workaday clothes and into its best party duds,
then opens door]
Object A : "Okaaay! Let's get it ON-N-N, baby!"
Object B : "Rockin'!"
[Objects A and B get together, party all night as the perfect couple and
live happily ever after...[1]]
At least I think that's how it works... I haven't been on a date
for...<COUGH!> I mean, I haven't been learning OO theory long and my brain
is still numb from trying.
Another example would be:
get 3 & 5
--> {3, 5}
where 3 sees 5 coming from a mile off and, knowing that numbers can't
concatenate for sh*t, decides to make like it's a list {3} instead (since
it knows that lists can).
At least, I HOPE I've got all that right. But it explains why {} can behave
in more than one different way, according to circumstances. [2]
Cheers,
has
[1] ...until Object C arrives nine months later. Then they start arguing
about whose turn it is this time to get up and feed it again...
[2] Though it doesn't explain the problems with '{} as record' claiming
that it's still the partying type... and then turning frigid on you at the
most inopportune moments. (Which sounds as if something busted deep inside
AS.)