From: [EMAIL PROTECTED] (Randal L. Schwartz)
Date: 25 Apr 2001 07:23:44 -0700
In-Reply-To: <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>
Lines: 50
User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.3
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
>>>>> "Peter" == Peter Scott <[EMAIL PROTECTED]> writes:
Peter> At 09:06 PM 4/24/2001 -0700, Larry Wall wrote:
>> Edward Peschko writes:
>> : Ok, so what does:
>> :
>> : my %hash = ( 1 => 3);
>> : my $hash = { 1 => 4};
>> :
>> : print $hash{1};
>> :
>> : print?
>>
>> 4. You must say %hash{1} if you want the other.
Peter> I was teaching an intro class yesterday and as usual, there were
Peter> several people who typed just that instead of what I'd taught, so
Peter> there is obviously some intuitive merit to it.
I found that to be true until I discovered a trick about teaching this
stuff, which we've incorporated into the Stonehenge "Llama" materials
over the past 18 months, and thus the forthcoming "Learning Perl (3rd
edition)" book.
We spend about 20 minutes in class talking about everything
you can do with $foo[3], without having ever mentioned @foo at all.
When we introduce it, we treat the @ as an operator, phrased "all of
the". So "@rocks" is "all of the rocks", the same as ($rocks[0],
$rocks[1], $rocks[2],...), which they've already seen at that point.
We've not had anyone try to use @foo[3] since then!
Ditto $foo{"smile"}.... we don't introduce %foo until we start talking
about operators that work on "all of the hash of ...". Nobody ever
tries to type %foo{"smile"} after that either.
And yes, these work quite nicely, and the new llama reflects this new
teaching style.
So, I'd say if you get %hash{1} in an intro class, it's the way you
teach it. I'd also dare say you're teaching the language you want,
instead of the language that it is. Materials always reflect that.
Better to get within the paradigm.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!