You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to use the catch feature of the pl library. I also use the class.properties feature.
Expectation #1: That catch works without class.properties. This is not clear from the documentation, but it appears to be the case. If it is, it should be documented. I always use class.properties, so this isn't an issue that I would need changed, however.
Expectation #2: Within the initializer, I'm free to set up the class in whichever way that I need to. Then after the object is made, the catch function will catch any attempted access to uninitialized variables.
localmc=class.mc(class.properties)
mc:catch(
function(self,name)
--print('hello.')returnfunction()
error("no such method: " ..name, 2)
endend
)
functionmc:_init(args)
self.foo="bar"returnselfendlocalc=mc()
c.baz="I shouldn't be allowed."
Having taken a couple stabs at the related code I can confirm: class:catch() and class.properties will not play nice together. They are both trying to take over similar function using different Lua mechanisms. One or the other –not both– will ever work. Which one gets dibs is a mystery to me and may be different depending on which of the various alternative class instantiation syntax options you go with and/or what Lua VM you are using.
There may or may not be a way to resolve this. At this point I'm guessing they are mutually exclusive and should be documented as such.
I want to use the
catch
feature of the pl library. I also use theclass.properties
feature.Expectation #1: That
catch
works withoutclass.properties
. This is not clear from the documentation, but it appears to be the case. If it is, it should be documented. I always useclass.properties
, so this isn't an issue that I would need changed, however.Expectation #2: Within the initializer, I'm free to set up the class in whichever way that I need to. Then after the object is made, the catch function will catch any attempted access to uninitialized variables.
As it is, I get:
I wish that there was a way to initialize public (non getter/setter) properties inside of a class, while using
catch.
Approaches that my rebel forces may take, in order to create the changes we seek in the ruling class library
Attempt #1: I may attempt to 'turn off' the catch (or make that possible) during the init phase.
Attempt #2: I may make a method that is defined when
catch
is used calledpublic
. Everything inside of public is set as such:Attempt #3: I may make a class.properties.public method in which I can do something like:
I'll have to see which one I'm smart enough to implement... :)
-Andrew
The text was updated successfully, but these errors were encountered: