Re: Test for key on luabind class (userdata vs table?)
"Christian" <[email protected]> Sat, 26 Oct 2013 20:46:37 +0200
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
This is a multipart message in MIME format. --===============3217268378840335137== Content-Type: multipart/alternative; boundary="----=_NextPart_000_000D_01CED28C.78C0F8D0" Content-Language: de-at This is a multipart message in MIME format. ------=_NextPart_000_000D_01CED28C.78C0F8D0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Catching the error with pcall (and maybe checking if the error message = is an 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 = 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 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. =20 ------=_NextPart_000_000D_01CED28C.78C0F8D0 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dutf-8"> <html xmlns:v=3D"urn:schemas-microsoft-com:vml" = xmlns:o=3D"urn:schemas-microsoft-com:office:office" = xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" = xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta name=3DGenerator = content=3D"Microsoft Word 14 (filtered medium)"><style><!-- /* 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]--></head><body lang=3DDE-AT link=3Dblue = vlink=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal><span = lang=3DEN-US style=3D'font-size:11.0pt'>Catching the error with = </span><span lang=3DEN-US = style=3D'font-size:11.0pt;font-family:Consolas'>pcall</span><span = lang=3DEN-US style=3D'font-size:11.0pt'> (and maybe checking if the = error message is an expected one) is the only solution I can think = of.<o:p></o:p></span></p><p class=3DMsoNormal><span lang=3DEN-US = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"'><o:p> = </o:p></span></p><div style=3D'border:none;border-left:solid blue = 1.5pt;padding:0cm 0cm 0cm 4.0pt'><div><div = style=3D'border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm = 0cm 0cm'><p class=3DMsoNormal><b><span lang=3DDE = style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span>= </b><span lang=3DDE = style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Glen = Fraser [mailto:[email protected]] <br><b>Sent:</b> Saturday, October = 26, 2013 7:45 PM<br><b>To:</b> = [email protected]<br><b>Subject:</b> [luabind] Test for = key on luabind class (userdata vs = table?)<o:p></o:p></span></p></div></div><p = class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal = 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 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?<o:p></o:p></p><p = class=3DMsoNormal><o:p> </o:p></p><p = class=3DMsoNormal>[snip]<o:p></o:p></p><div><p = class=3DMsoNormal><o:p> </o:p></p></div><div><p = class=3DMsoNormal>Thanks,<o:p></o:p></p></div><div><p = class=3DMsoNormal>Glen.<o:p></o:p></p></div><div><p = class=3DMsoNormal><o:p> </o:p></p></div></div></div></body></html> ------=_NextPart_000_000D_01CED28C.78C0F8D0-- --===============3217268378840335137== 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 --===============3217268378840335137== 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 --===============3217268378840335137==--