<i>msgcat with oo: error "self may only be called from inside a method"</i> status still Open with 3 other changes
by
.
D 2024-07-15T11:04:15.555
J icomment I've\sreviewed\sthis\sfurther;\s"fixing"\s`namespace\sinscope`\sisn't\spractical.\sThis\sis\sbecause\sit\swould\sinvolve\ssynthesising\sa\scall\scontext,\swhich\sis\sa\scomplex\sentity\s(which\swould\sneed\sto\sbe\scarried\sin\sthe\s`clientData`\sof\sthe\sstack\sframe).\r\n\r\nIt\swould\sbe\s"easier"\sto\s"fix"\s`namespace\scode`\sto\sbe\saware\sthat\sit\sis\srunning\sin\san\sobject,\sbut\snot\sactually\seasy\sbecause\syou\sstill\srun\sinto\sthe\sstack\sframe\sneeding\sto\sbe\sspecial\s(because\s`self`\suses\sthat\sinfo).\r\n```\r\n\s\s%\soo::object\screate\sfoo\r\n\s\s::foo\r\n\s\s%\soo::objdefine\sfoo\sexport\seval\r\n\s\s%\sfoo\seval\sself\r\n\s\sself\smay\sonly\sbe\scalled\sfrom\sinside\sa\smethod\r\n```\r\nI've\sno\sidea\swhat\swill\shappen\sif\sI\smake\sthe\s`eval`\smethod\sused\sabove\sexport\sits\sspecial-ness\sinto\sthe\sframe\sit\spushes.\s(It's\s*one*\spossibility,\sand\sperhaps\sone\sthat\sI\sshould\shave\sthought\sabout\sbefore...)\r\n\r\n[`callback`](https://www.tcl-lang.org/man/tcl9.0/TclCmd/callback.html)\sand\susing\sa\smethod\sfor\sthe\stooltip\sshowing\swould\sseem\sbetter.\sOr\spassing\smore\sarguments\sfrom\sthe\scontext\sthat\ssets\sup\sthe\scallback\s(pre-resolving\sthe\snamespace).\sThe\scode\sto\sit\scan\sbe\scopied\sfor\s8.6;\sit's\sliterally\sjust\sa\ssmall\sprocedure.\r\n\r\nI\sdoubt\sthat\sI'll\sever\smake\sthis\s"work"\sfor\sdefinitions.\r\n\r\n----\r\n\r\nI\s**strongly\srecommend**\sadding\s`try`/`on\serror`\shandling\sto\sthis\sto\sfall\sback\sto\sthe\snon-OO\sway\sof\sdoing\sthings,\sas\sthat\swill\sbe\ssignificantly\sless\swrong.\sI\salso\sstrongly\srecommend\sresolving\sthe\snamespace\sprior\sto\sregistering\sthe\scallback.\sIn\sfact,\sthat's\slikely\sto\sbe\smy\scentral\srecommendation;\s**resolve\sthe\snamespace\simmediately**.\s(Namespaces\scan't\sbe\srenamed,\sso\sthe\sresolution\sshould\sremain\sthe\ssame\sfor\showever\slong\sthe\scontext\sis\smeaningful\sfor.)
J login dkf
J mimetype text/x-markdown
K 91b3a5bb14e6e8ae1d1c5349af12e08879ea152d
U dkf
Z 479720ad49df4235b1eebc390c0fb817