Re: Test for key on luabind class (userdata vs table?)
Glen F <[email protected]> Sat, 26 Oct 2013 21:51:02 +0200
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
--===============1096661814646129845== Content-Type: multipart/alternative; boundary=Apple-Mail-A0A654F5-AD41-44CE-B991-A9476B38A8CF Content-Transfer-Encoding: 7bit --Apple-Mail-A0A654F5-AD41-44CE-B991-A9476B38A8CF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Thanks, that seems to do the trick. Glen. On 26/10/2013, at 20:46, "Christian" <[email protected]> wrote: > Catching the error with pcall (and maybe checking if the error message is a= n expected one) is the only solution I can think of. > =20 > From: Glen Fraser [mailto:[email protected]]=20 > Sent: Saturday, October 26, 2013 7:45 PM > To: [email protected] > Subject: [luabind] Test for key on luabind class (userdata vs table?) > =20 > Hi there, I know it's possible to set "properties" on luabind classes in L= ua. You can set and get these keys, no problem. However, it doesn't seem p= ossible to "get" (or test for the existence of) an unset key -- you'd expect= it to return 'nil', but it crashes. Is there a way to test a luabind class= for the existence of a key (as though it were a table), without crashing? > =20 > [snip] > =20 > Thanks, > Glen. --Apple-Mail-A0A654F5-AD41-44CE-B991-A9476B38A8CF Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D= utf-8"></head><body dir=3D"auto"><div>Thanks, that seems to do the trick.<br= ><br>Glen.<div><br></div></div><div>On 26/10/2013, at 20:46, "Christian" <= ;<a href=3D"mailto:[email protected]">[email protected]</a>> wrote:<br><br></div><blo= ckquote type=3D"cite"><meta http-equiv=3D"Content-Type" content=3D"text/html= ; charset=3Dutf-8"> <meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)"><st= yle><!-- /* Font Definitions */ @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} @font-face {font-family:Consolas; panose-1:2 11 6 9 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} span.E-MailFormatvorlage17 {mso-style-type:personal-reply; font-family:"Calibri","sans-serif"; color:windowtext;} .MsoChpDefault {mso-style-type:export-only; font-size:10.0pt;} @page WordSection1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 2.0cm 70.85pt;} div.WordSection1 {page:WordSection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--><div class=3D"WordSection1"><p class=3D"Ms= oNormal"><span lang=3D"EN-US" style=3D"font-size:11.0pt">Catching the error w= ith </span><span lang=3D"EN-US" style=3D"font-size:11.0pt;font-family:Consol= as">pcall</span><span lang=3D"EN-US" style=3D"font-size:11.0pt"> (and maybe c= hecking if the error message is an expected one) is the only solution I can t= hink of.<o:p></o:p></span></p><p class=3D"MsoNormal"><span lang=3D"EN-US" st= yle=3D"font-size:11.0pt;font-family:"Calibri","sans-serif&quo= t;"><o:p> </o:p></span></p><div style=3D"border:none;border-left:solid b= lue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div style=3D"border:none;border-t= op:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class=3D"MsoNormal"><b>= <span lang=3D"DE" style=3D"font-size:10.0pt;font-family:"Tahoma",&= quot;sans-serif"">From:</span></b><span lang=3D"DE" style=3D"font-size:= 10.0pt;font-family:"Tahoma","sans-serif""> Glen Fraser [= <a href=3D"mailto:[email protected]">mailto:[email protected]</a>] <br><b>= Sent:</b> Saturday, October 26, 2013 7:45 PM<br><b>To:</b> <a href=3D"mailto= :[email protected]">[email protected]</a><= br><b>Subject:</b> [luabind] Test for key on luabind class (userdata vs tabl= e?)<o:p></o:p></span></p></div></div><p class=3D"MsoNormal"><o:p> </o:p= ></p><p class=3D"MsoNormal" style=3D"margin-left:5.25pt">Hi there, I know it= 's possible to set "properties" on luabind classes in Lua. You can set= and get these keys, no problem. However, it doesn't seem possible to "= get" (or test for the existence of) an unset key -- you'd expect it to retur= n 'nil', but it crashes. Is there a way to test a luabind class for th= e existence of a key (as though it were a table), without crashing?<o:p></o:= p></p><p class=3D"MsoNormal"><o:p> </o:p></p><p class=3D"MsoNormal">[sn= ip]<o:p></o:p></p><div><p class=3D"MsoNormal"><o:p> </o:p></p></div><di= v><p class=3D"MsoNormal">Thanks,<o:p></o:p></p></div><div><p class=3D"MsoNor= mal">Glen.</p></div></div></div></blockquote></body></html>= --Apple-Mail-A0A654F5-AD41-44CE-B991-A9476B38A8CF-- --===============1096661814646129845== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk --===============1096661814646129845== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user --===============1096661814646129845==--