Deutsch   English   Français   Italiano  
<20240626220200.0613ab6c@lud1.home>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Luc <luc@sep.invalid>
Newsgroups: comp.lang.tcl
Subject: Re: My hang-up about OOP (snit)
Date: Wed, 26 Jun 2024 22:02:00 -0300
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <20240626220200.0613ab6c@lud1.home>
References: <20240625180928.43fcc5c1@lud1.home>
	<v5fgcq$1oiln$2@dont-email.me>
	<20240625195730.26db3755@lud1.home>
	<v5i4th$2br31$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jun 2024 03:02:01 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="45a762fadea9095f510d51d9df4273ce";
	logging-data="2529711"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX189xHsVDDNFf1rhhuSj5l+nN+NDdu2az38="
Cancel-Lock: sha1:i+WwaAMqO/EW9IWsxdCDMm3T4R8=
Bytes: 1860

On Wed, 26 Jun 2024 22:32:17 -0000 (UTC), Rich wrote:

>As a thought experiment, consider how you'd make your 'dog' proc 
>'count' (say you have circus dogs that can 'count' ...) and imagine how 
>to give each of four different dogs their own, independent, counter to 
>store their current value into.
>
>Then, compare the code you'd need to add to the dog proc to make a 
>'counting dog' proc with separate counter variables for each dog to the 
>code necessary to achieve the same result from the counting class 
>above.

lassign "1 1" c_01 c_02

proc countcees {cee}	{
	upvar \#0 $cee _cee
	incr _cee
	puts $_cee
}

countcees c_01
2
countcees c_01
3
countcees c_02
2
countcees c_02
3
countcees c_01
4


In reality though, nobody needs a proc for that.

incr c_o1
1
incr c_o2
1
incr c_o2
2
incr c_o2
3
incr c_o2
4
incr c_o1
2

-- 
Luc
>>