Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Recommended Posts

Posted

I would like to ask how to implement class inheritance in HC3.

 

class "abc" (cde) 

 

I expected this construction creates "abc" (a table) inherit from "cde".

Seems not to work in fibemu, but I assume that in HC3 too.

It's like "abc" table was not created.

How it should be coded properly?

Posted (edited)

It works the same in fibemu as in the HC3.

 

Please login or register to see this code.


Note, on the HC3, objects are 'userdata' types and can not be iterated over like a Lua table. In fibemu the objects are Lua tables.

Edited by jgab
  • Thanks 1
  • Topic Author
  • Posted

    Thank you. I'm not skilled OOP and thrown in the deep water.

    So, could I assume that class 'A' is the same as A = {} ?

    Posted (edited)
    15 minutes ago, Łukasz997 said:

    Thank you. I'm not skilled OOP and thrown in the deep water.

    So, could I assume that class 'A' is the same as A = {} ?

    Almost,

    Please login or register to see this code.

    Please login or register to see this code.

    Both A and an are of 'userdata' type, but they are different.

    'userdata' just tells us that it is data represented outside lua (in C in this case)

    A is a class (and is printed as "class A"), but 'a' is an object, instance of A, and

    another 'userdata' type. Prints as the more ugly "custom [luabind::detail::null_type] object: (nil)"

     

    We can peek into objects with 

    Please login or register to see this code.

    but we can't peek into classes

    Please login or register to see this code.

    gives an error if A doesn't contain a static x, which it doesn't do in this case as self.x is dynamically added at initialization.

    fibemu will not give an error but return nil in this case.

     

    and you can't iterate over the object
     

    Please login or register to see this code.

     

    Edited by jgab
  • Topic Author
  • Posted

    Thank you. I do not know where is the error regarding inheritance, my code is too complicated for me. Never sure what's behind.
    I will manage inheritance by hand, as I see it's also possible. At last I can peek what I am doing.
    This, what I'm doing is ideal for OOP, which I don't like... So, I'll keep doing.

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...