<p dir="ltr">Agreed. This is much clearer than a (inexpressively) null check. </p>
<p dir="ltr">Von meinem Xperia™ von Sony-Smartphone gesendet</p>
<br><br>---- jwlua-request@jwmusic.nu schrieb ----<br><br>Send JWLua mailing list submissions to<br> <a href="mailto:jwlua@jwmusic.nu">jwlua@jwmusic.nu</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br> <a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a><br>or, via email, send a message with subject or body 'help' to<br> <a href="mailto:jwlua-request@jwmusic.nu">jwlua-request@jwmusic.nu</a><br><br>You can reach the person managing the list at<br> <a href="mailto:jwlua-owner@jwmusic.nu">jwlua-owner@jwmusic.nu</a><br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of JWLua digest..."<br><br><br>Today's Topics:<br><br> 1. Re: RFC: Adding Methods/Properties to RGP Lua that only exist<br> in certain Finale versions (Nick Mazuk)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Wed, 24 Aug 2022 16:42:17 <a href="tel:+0000">+0000</a><br>From: "Nick Mazuk" <<a href="mailto:nick@nickmazuk.com">nick@nickmazuk.com</a>><br>To: "The JW Lua script plug-in." <<a href="mailto:jwlua@jwmusic.nu">jwlua@jwmusic.nu</a>><br>Subject: Re: [JW Lua] RFC: Adding Methods/Properties to RGP Lua that<br> only exist in certain Finale versions<br>Message-ID:<br> <<a href="mailto:l77ufq8b.e8ce6bf0-bc59-4c31-b9b3-c690f52f929c@we.are.superhuman.com">l77ufq8b.e8ce6bf0-bc59-4c31-b9b3-c690f52f929c@we.are.superhuman.com</a>><br>Content-Type: text/plain; charset="utf-8"<br><br>This seems like a good plan to me.<br><br>On Wed, Aug 24, 2022 at 8:58 AM, Robert Patterson < <a href="mailto:robert@robertgpatterson.com">robert@robertgpatterson.com</a> > wrote:<br><br>> <br>> Instead of pcall, you do:<br>> <br>> <br>> if <a href="http://finenv.RawFinaleVersion">finenv.RawFinaleVersion</a> >= <min-vers> then<br>> do something<br>> end<br>> <br>> <br>> It doesn't seem much worse than null checking, and it shows what's really<br>> going on. This could all be encapsulated in a client library of course.<br>> <br>> <br>> <br>> On Wed, Aug 24, 2022 at 10:51 AM Robert Patterson < robert@ robertgpatterson.<br>> com ( <a href="mailto:robert@robertgpatterson.com">robert@robertgpatterson.com</a> ) > wrote:<br>> <br>> <br>>> I have been experimenting with throwing an error out of C++ this morning ,<br>>> and it works seamlessly exactly as one would hope. I much prefer an error<br>>> message that says, "<a href="http://modula.lua">modula.lua</a> line 420: Finale 26.9 required". (To make<br>>> up a Finale version.)<br>>> <br>>> <br>>> Plus, you'll only have to use pcall if you are unwilling to specify<br>>> MinFinaleVersion in your plugindef.<br>>> <br>>> <br>>> <br>>> <br>>> On Wed, Aug 24, 2022 at 10:26 AM Nick Mazuk < nick@ nickmazuk. com (<br>>> <a href="mailto:nick@nickmazuk.com">nick@nickmazuk.com</a> ) > wrote:<br>>> <br>>> <br>>>> Throwing an error might be redundant. For instance, if the following<br>>>> prints out nil (for instance, if the method doesn't exist on the object):<br>>>> <br>>>> <br>>>> <br>>>> local entry = <a href="http://finale.FCEntry">finale.FCEntry</a>()<br>>>> <br>>>> print(<a href="http://entry.FooBar">entry.FooBar</a>)<br>>>> <br>>>> <br>>>> <br>>>> then the following will already be thrown an error since nil is not a<br>>>> function:<br>>>> <br>>>> <br>>>> <br>>>> local entry = <a href="http://finale.FCEntry">finale.FCEntry</a>()<br>>>> <br>>>> entry:FooBar() ? error!<br>>>> <br>>>> <br>>>> <br>>>> The only advantage I can think of by having RGP Lua throw an error if you<br>>>> even access it is that you'll potentially get more meaningful error<br>>>> messages as a user. As a developer, the plugin will still tell you exactly<br>>>> what line of code threw the error. However, it has the disadvantage that<br>>>> you must use pcall to capture the error and you cannot simply check if the<br>>>> method exists or not (which developers should be doing anyways for any<br>>>> newly added features to RGP Lua).<br>>>> <br>>>> <br>>>> <br>>>> On Wed, Aug 24, 2022 at 5:24 AM, Robert Patterson < robert@ robertgpatterson.<br>>>> com ( <a href="mailto:robert@robertgpatterson.com">robert@robertgpatterson.com</a> ) > wrote:<br>>>> <br>>>>> Throwing an error is a good idea that I hadn't thought of. However, these<br>>>>> errors would have to be thrown out of the PDK Framework, which is not Lua.<br>>>>> So far, there is no try/catch/throw in the PDK Framework codebase. That is<br>>>>> not to say we couldn't start using it, but it will require approvals from<br>>>>> the other clients that share that code.<br>>>>> <br>>>>> <br>>>>> Meanwhile, if the function is missing you'll get the same behavior. It<br>>>>> just won't have as helpful an error message. And by leaving it missing,<br>>>>> you don't have to resort to pcall. You can simply test if it is there.<br>>>>> <br>>>>> <br>>>>> <br>>>>> On Wed, Aug 24, 2022 at 6:18 AM Daniel Grunwald < dgr@ leng. de (<br>>>>> <a href="mailto:dgr@leng.de">dgr@leng.de</a> ) > wrote:<br>>>>> <br>>>>> <br>>>>>> <br>>>>>> <br>>>>>> Hi there,<br>>>>>> <br>>>>>> <br>>>>>> <br>>>>>> it seems my first reply didn't get through. So I repeat it. I case you<br>>>>>> receive this twice you know why.<br>>>>>> <br>>>>>> <br>>>>>> <br>>>>>> I am a lua novice having no actual experience in lua so my idea might be<br>>>>>> foolish. However from what I learned in terms of clean code in other<br>>>>>> languages I would prefer to raise an error instead of not providing the<br>>>>>> function.<br>>>>>> In order to deal with this users will have to use pcall, as described in https:/<br>>>>>> / www. lua. org/ pil/ 8. 4. html ( <a href="https://www.lua.org/pil/8.4.html">https://www.lua.org/pil/8.4.html</a> )<br>>>>>> <br>>>>>> <br>>>>>> <br>>>>>> Although not knowing if it really is (by lack experience) to me it sounds<br>>>>>> like a cleaner approach.<br>>>>>> <br>>>>>> <br>>>>>> <br>>>>>> However if you like to use the nil-approach I suggest putting "OrNil" as<br>>>>>> suffix to the function's name so the name indicates it possibly being nil.<br>>>>>> <br>>>>>> <br>>>>>> <br>>>>>> <br>>>>>> Hope this was helpful.<br>>>>>> <br>>>>>> <br>>>>>> <br>>>>>> Best regards<br>>>>>> Daniel<br>>>>>> <br>>>>>> <br>>>>>> <br>>>>>> Von meinem Xperia? von Sony-Smartphone gesendet<br>>>>>> <br>>>>>> <br>>>>>> <br>>>>>> ---- jwlua-request@ jwmusic. nu ( <a href="mailto:jwlua-request@jwmusic.nu">jwlua-request@jwmusic.nu</a> ) schrieb ----<br>>>>>> <br>>>>>> Send JWLua mailing list submissions to<br>>>>>> jwlua@ jwmusic. nu ( <a href="mailto:jwlua@jwmusic.nu">jwlua@jwmusic.nu</a> )<br>>>>>> <br>>>>>> To subscribe or unsubscribe via the World Wide Web, visit<br>>>>>> http:/ / jwmusic. nu/ mailman/ listinfo/ jwlua_jwmusic. nu (<br>>>>>> <a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a> )<br>>>>>> or, via email, send a message with subject or body 'help' to<br>>>>>> jwlua-request@ jwmusic. nu ( <a href="mailto:jwlua-request@jwmusic.nu">jwlua-request@jwmusic.nu</a> )<br>>>>>> <br>>>>>> You can reach the person managing the list at<br>>>>>> jwlua-owner@ jwmusic. nu ( <a href="mailto:jwlua-owner@jwmusic.nu">jwlua-owner@jwmusic.nu</a> )<br>>>>>> <br>>>>>> When replying, please edit your Subject line so it is more specific<br>>>>>> than "Re: Contents of JWLua digest..."<br>>>>>> <br>>>>>> <br>>>>>> Today 's Topics:<br>>>>>> <br>>>>>> 1. RFC: Adding Methods/Properties to RGP Lua that only exist in<br>>>>>> certain Finale versions (Robert Patterson)<br>>>>>> <br>>>>>> <br>>>>>> ----------------------------------------------------------------------<br>>>>>> <br>>>>>> Message: 1<br>>>>>> Date: Mon , 22 Aug 2022 15:03: <a href="tel:15 -0500">15 -0500</a> ( tel:15%20-0500 )<br>>>>>> From: Robert Patterson < robert@ robertgpatterson. com (<br>>>>>> <a href="mailto:robert@robertgpatterson.com">robert@robertgpatterson.com</a> ) ><br>>>>>> To: "The JW Lua script plug-in." < jwlua@ jwmusic. nu ( <a href="mailto:jwlua@jwmusic.nu">jwlua@jwmusic.nu</a> )<br>>>>>> ><br>>>>>> Subject: [JW Lua] RFC: Adding Methods/Properties to RGP Lua that only<br>>>>>> exist in certain Finale versions<br>>>>>> Message-ID:<br>>>>>> < CAACnceu23XaymU4XNBZQ-1e6wDdP5xP6-ht8fdk3trUduahrUA@ mail. gmail. com (<br>>>>>> <a href="mailto:CAACnceu23XaymU4XNBZQ-1e6wDdP5xP6-ht8fdk3trUduahrUA@mail.gmail.com">CAACnceu23XaymU4XNBZQ-1e6wDdP5xP6-ht8fdk3trUduahrUA@mail.gmail.com</a> ) ><br>>>>>> Content-Type: text/plain; charset="utf-8"<br>>>>>> <br>>>>>> I will soon be adding to RGP Lua some methods and properties that are not<br>>>>>> available before a certain Finale version. Previously when this has<br>>>>>> happened, the methods and properties appear in all Finale versions but<br>>>>>> return a default value in earlier Finale versions where they aren't<br>>>>>> supported. Until now there has always been an appropriate default value.<br>>>>>> <br>>>>>> However, these new methods and properties I plan to add do not have useful<br>>>>>> <br>>>>>> default values in earlier Finale versions. In fact, it would be a bad idea<br>>>>>> <br>>>>>> to return anything at all unless running in an supported Finale version.<br>>>>>> <br>>>>>> To me the best solution would appear to be not to hook up these methods<br>>>>>> and<br>>>>>> properties to Lua if the Finale version doesn't support them. But that<br>>>>>> means, in perpetuity, Lua programmers will have to check them for `nil`<br>>>>>> before calling them. Does anyone have other/better ideas?<br>>>>>> -------------- next part --------------<br>>>>>> An HTML attachment was scrubbed...<br>>>>>> URL: < http:/ / jwmusic. nu/ pipermail/ jwlua_jwmusic. nu/ attachments/ <a href="tel:20220822">20220822</a>/<br>>>>>> 224e51a5/ attachment-0001. html> (<br>>>>>> <a href="http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20220822/224e51a5/attachment-0001.html>">http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20220822/224e51a5/attachment-0001.html></a><br>>>>>> ) ;<br>>>>>> <br>>>>>> ------------------------------<br>>>>>> <br>>>>>> Subject: Digest Footer<br>>>>>> <br>>>>>> _______________________________________________<br>>>>>> JWLua mailing list<br>>>>>> JWLua@ jwmusic. nu ( <a href="mailto:JWLua@jwmusic.nu">JWLua@jwmusic.nu</a> )<br>>>>>> http:/ / jwmusic. nu/ mailman/ listinfo/ jwlua_jwmusic. nu (<br>>>>>> <a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a> )<br>>>>>> <br>>>>>> <br>>>>>> ------------------------------<br>>>>>> <br>>>>>> End of JWLua Digest, Vol 94, Issue 5<br>>>>>> ************************************<br>>>>>> _______________________________________________<br>>>>>> JWLua mailing list<br>>>>>> JWLua@ jwmusic. nu ( <a href="mailto:JWLua@jwmusic.nu">JWLua@jwmusic.nu</a> )<br>>>>>> http:/ / jwmusic. nu/ mailman/ listinfo/ jwlua_jwmusic. nu (<br>>>>>> <a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a> )<br>>>>>> <br>>>>> <br>>>>> <br>>>>> <br>>>>> <br>>>>> _______________________________________________<br>>>>> JWLua mailing list<br>>>>> JWLua@ jwmusic. nu ( <a href="mailto:JWLua@jwmusic.nu">JWLua@jwmusic.nu</a> )<br>>>>> http:/ / jwmusic. nu/ mailman/ listinfo/ jwlua_jwmusic. nu (<br>>>>> <a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a> )<br>>>>> <br>>>>> <br>>>>> <br>>>> <br>>>> <br>>>> <br>>>> _______________________________________________<br>>>> JWLua mailing list<br>>>> JWLua@ jwmusic. nu ( <a href="mailto:JWLua@jwmusic.nu">JWLua@jwmusic.nu</a> )<br>>>> http:/ / jwmusic. nu/ mailman/ listinfo/ jwlua_jwmusic. nu (<br>>>> <a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a> )<br>>>> <br>>> <br>>> <br>>> <br>> <br>> <br>> <br>> _______________________________________________<br>> JWLua mailing list<br>> JWLua@ jwmusic. nu ( <a href="mailto:JWLua@jwmusic.nu">JWLua@jwmusic.nu</a> )<br>> <a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a><br>> <br>> <br>><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <<a href="http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20220824/befa49c3/attachment.html>">http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20220824/befa49c3/attachment.html></a>;<br><br>------------------------------<br><br>Subject: Digest Footer<br><br>_______________________________________________<br>JWLua mailing list<br><a href="mailto:JWLua@jwmusic.nu">JWLua@jwmusic.nu</a><br><a href="http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu">http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu</a><br><br><br>------------------------------<br><br>End of JWLua Digest, Vol 94, Issue 8<br>************************************<br>