At 9:46 -0800 2001_12_04, Irv Kalb wrote:
>>iii.we can define our own handlers in parent scripts?
>
>Yes. The only handler you absolutely need is "on new me". The rest
>is completely up to you.
Complementary ramble:
I know the "new" method as written in the scriptText is generally
thought of and described as "the black box wherein objects are born",
but this is wrong, and actually I don't even think it is productive
to use this explanation as a pedagogical vehicle for any
target-group, newbies or experienced.
Of course "the real" mechanism cannot be explained without involving
ancestry, which is probably too complex a concept to start OOP 101
with, so we'll have to accept some initial "magic" in the explanation
of "instantiation".
But I'm much more in favor of starting by showing that a script -
even an "empty" one containing only two dashes - is a magic object
from which you can derive clones with the "new" or "rawNew" method,
and then legitimizing these clones by showing that they can have
separate "property-variables", and then show, that they are more than
just proplists, because they can also have methods, that relate to
the data they contain.
Then after that explanation, it would be relevant to show, that there
is a convenient way to have an "initialization" method called through
the "new"-creator-call, without the need for an extra line with an
explicit call to a method in the new instance.
I think it is more fair to the "student" to frankly say "up-front"
that the "new" handler is not the "womb" of objects, but simply a
convenience. In my view that would help to take some of the mystery
and confusion out of the "mind-set", that often haunts newbies during
their OOP paradigm-absorbtion.
I know this is probably controversial to "the usual way Lingo-OOP is
taught", and it may not be an easy goal to achieve, but I think it
could be a paradigm-shift in "explaining Lingo-OOP", that is worth
wrestling.
Perhaps we would think of it as: "Lingo-OOP the hard way", and maybe
it is - but maybe if we tried to refine it, it could turn out not to
be so hard after all.
One of the most confusing and devastating aspects of the "new"
handler, is that it compromises everything the student has learned
about "passing parameters": Why is the passed value changed when it
enters the "new" handler??? And where else does Lingo break such
consistent rules?
In my view, that is at the root of much of the "uncertainty" that
people feel about Lingo-OOP: You never know what to expect, because
you never understood, in the first place, why - or for what reason -
the "new" handler magically transformed the passed variable.
The fact alone that the "new" handler introduces these complex
"inconsistencies", suggests to me, that it is not well suited to be
the first thing shown in a Lingo-OOP lesson, especially since it is
really not required.
But regardless: Irv it's admirable that you have made the effort and
written a Lingo-OOP tutorial, and I'll call back when I've grown
enough hair on my chest, to write my "Lingo-OOP the hard way"... ;-)
A stab at showing some of my thinking behind this, admittedly more
addressed to geeks, than newbies:
Given the script "myClass":
----<script myClass>----
on mInstantiate me
put #mInstantiate, #me, me
tInstance = me.rawNew()
tResult = tInstance.new()
return tResult
end
on new me
put #new, #me, me
return me
end
----</script myClass>----
The idea of the "mInstantiate" handler is to mimic what happens
internally in the script, when you call it's implicit "new" handler.
For better focus I do not use the more precise line:
<tResult = call(#new, [tInstance])>
-- Welcome to Director --
tMember = member "myClass"
put tMember
-- (member 1 of castLib 1)
put tMember.ilk
-- #member
put tMember.objectP
-- 1
tScript = tMember.script
put tScript
-- (script "myClass")
put tScript.ilk
-- #script
put tScript.objectP
-- 1
tObject = tScript.mInstantiate()
-- #mInstantiate #me (script "myClass")
-- #new #me <offspring "myClass" 3 b5138a4>
put tObject
-- <offspring "myClass" 2 b5138a4>
put tObject.ilk
-- #instance
put tObject.objectP
-- 1
And then to show the same in a "normal" way:
put tScript.new()
-- #new #me <offspring "myClass" 2 dd020ec>
-- <offspring "myClass" 1 dd020ec>
And in complete classic parlance:
put script("myClass").new()
-- #new #me <offspring "myClass" 2 dcfee74>
-- <offspring "myClass" 1 dcfee74>
And then amaze your audience by exchanging all the scriptText by two
dashes, and do the last trick again:
put script("myClass").new()
-- <offspring "myClass" 1 dcffb80>
Oh, and by the way: Even "Scripts" are instances themselves, so
beware, but that's another story.
Hope this was food for thought?
regards, Jakob
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]