Skip to content
Tcl Source Code Artifact [4790114238]
Login

Artifact [4790114238]

Artifact 479011423863fdc476c4f8fe2dbe265c80dfa6af:

Ticket change [4790114238] - Ticket [3474460fffffffff|3474460fff] <i>targetObject should be optional for oo::copy</i> status still Open with 4 other changes by basilik99 on 2012-01-24 03:35:34.
D 2012-01-24T03:35:34
J icomment Hi,\n\nIndeed!\sI\swas\sabout\sto\sopen\sanother\sticket\s(probably\sa\sfeature\srequest)\sabout\sthe\sfact\sthat\sgiven\sa\sclass\sA\swhich\sis\san\sinstance\sof\sclass\sX\s(rather\sthan\soo::class\sas\susual),\sthen\swhen\scopying\sA\sto\sB,\sthe\sconstructor\sof\sX\sdoes\snot\sget\scalled.\sI\sthink\sthat\swould\sbe\sthe\snatural\shook.\n\nI\salso\shad\sanother\sconcern:\swhen\sI\sfirst\sused\soo:::copy,\sI\sexpected\sthe\snew\sclass\sto\sbe\screated\sthe\ssame\sway\sas\sthe\sfirst\sone.\sEg:\n\noo::class\screate\sCLASS1\s\\\n{\n\s\s\ssuperclass\sMYBASE\s[oo::copy\sSTORABLE\s[expr\srand()]]\s\s;#\srand\sis\sbecause\stargetObject\sis\snot\soptional\n\s\s\svariable\sEXPRESSIONS\n\n\s\s\sputs\s"We\sare\sbuilding\sa\sclass."\n\n\s\s\sconstructor\s{pL_EXPRESSIONS}\s\\\n\s\s\s{\n\s\s\s\s\s\sset\sEXPRESSIONS\s$pL_EXPRESSIONS\n\s\s\s}\n\n\s\s\smethod\sWRITE\s{}\s\\\n\s\s\s{\n\s\s\s\s\s\sputs\s$EXPRESSIONS\n\s\s\s}\n\s\s\sexport\sWRITE\n}\n\noo::copy\sCLASS1\sCLASS2\noo::define\sCLASS2\ssuperclass\sMYBASE\s[oo::copy\sSTORABLE\s[expr\srand()]]\n\n1)\sIn\sthat\sexample,\sWRITE\smethod\son\san\sobject\sof\sCLASS1\sworks:\sthe\s"variable"\scommand\sgiven\sa\sclass\sdeclaration\smakes\sthat\svariable\svisible\sin\sall\smethods\swithout\shaving\sto\swrite\s"my\svariable\sEXPRESSIONS"\sat\sthe\sbeginning\sof\seach\smethod.\sThat\sno\slonger\sworks\sfor\sCLASS2:\sthe\s"variable"\scommand\sdoes\snot\sseem\scopied...\n\n2)\sAlso,\s"rand"\sfunction\sdoes\snot\sget\scalled\sonce\sfor\sCLASS1\sand\sonce\sfor\sCLASS2.\sIts\sresult\sis\sre-used\swhen\screating\sCLASS2.\sThis\sforces\sme\sto\soverride\sthe\ssuperclasses\sof\sCLASS2\susing\soo::define\scommand\sin\sorder\sto\sgenerate\sa\snew\scopy\sof\sSTORABLE\sclass\sfor\sCLASS2.\n\nSimilarly,\sthe\stext\s"We\sare\sbuilding\sa\sclass."\sgets\sprinted\sonly\sfor\sCLASS1,\snot\sfor\sCLASS2.\n\nIn\sother\swords,\sit\sseems\sonly\sthe\sconstructor,\sdestructor\sand\smethods\sare\scopied.\sBut\sit\scould\sbe\suseful\sif\sall\sthe\scode\spassed\sto\s"oo::class\screate"\swould\sbe\scopied.\n\nTell\sme\sif\sI\sshould\sopen\sanother\sticket\swith\sthese.\sThanks,\nEtienne\n
J login basilik99
J mimetype text/plain
J username basilik99
K 3474460fffffffffffffffffffffffffffffffff
U basilik99
Z 3c59faf666147e46811143466c529ea0