Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

There will be big changes for you but you will be happy.


comp / comp.lang.tcl / Tcl TIP → auto call destructor of embedded class

SubjectAuthor
o Tcl TIP → auto call destructor of embedded classaotto1968

1
Subject: Tcl TIP → auto call destructor of embedded class
From: aotto1968
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Sat, 25 May 2024 21:58 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: aotto1968@t-online.de (aotto1968)
Newsgroups: comp.lang.tcl
Subject: Tcl_TIP_→_auto_call_destructor_of_embedded_class
Date: Sat, 25 May 2024 23:58:21 +0200
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <v2tmtu$327q4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 25 May 2024 23:58:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ec3f762647f4efe4eb005516734427a3";
logging-data="3219268"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Yg2KI+UZeAo+mLUDKgs+yXOhTnHToZEI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:fs9Dbu/3ftXarUvVTMvifZeffY0=
Content-Language: en-US
View all headers

Hi, this is an "interface" class used as callback in tcl-oo
→ In the class are TWO other tcl-oo objects embedded (valBFL and colBFL)
→ the both objects are created with "create" *in* the namespace of the
LibSq3LiteRpcServerExecIF→instance because the name was part of the
"variable" declaration.
→ TRICK: if the instance (myInst) is deleted (destroy) than automatic the both
MkBufferListC→objects are delete too because the valBFL are created *in*
the namespace of the LibSq3LiteRpcServerExecIF→instance.
→ TRICK: no additional cleanup (destructor) is required.

oo::class create LibSq3LiteRpcServerExecIF {
variable rpc bus tok valBFL colBFL

constructor {myRpc myBus myTok} {
set rpc $myRpc
set bus $myBus
set tok $myTok
MkBufferListC create valBFL
MkBufferListC create colBFL
}

method callback {sq3lite valL colL} {
valBFL Reset
valBFL AppendLA {*}$valL
colBFL Reset
colBFL AppendLA {*}$colL
if {$bus eq "MK_NULL"} {
$rpc Send "W" "$tok:LL" valBFL colBFL
} else {
$bus Reset
$bus WriteBFL valBFL
$bus WriteBFL colBFL
}
}
}

LibSq3LiteRpcServerExecIF create myInst
myInst destroy ...

mfg ao

1

rocksolid light 0.9.8
clearnet tor