Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subclasse "capture" super's __subclasses entry #32

Open
cpeosphoros opened this issue Jul 18, 2017 · 0 comments
Open

Subclasse "capture" super's __subclasses entry #32

cpeosphoros opened this issue Jul 18, 2017 · 0 comments

Comments

@cpeosphoros
Copy link

Title says it all. Code says it better than words, so, here is a code demonstration (with the irrelevant entries stripped from the tables):

local Class = require "30log.30log-clean"
local Base  = Class("Base")
-- class 'Base' (table: 0x23656b0) * {
--   __subclasses : table: 0x2365980 * {
--                    },
-- }
local Sub1 = Base:extend("Sub1")
-- class 'Base' (table: 0x23656b0) * {
--   __subclasses : table: 0x2365980 * {
--                       class 'Sub1' (table: 0x2367ee0) : true,
--                    },
-- }
-- class 'Sub1' (table: 0x2367ee0) * {
--   super : class 'Base' (table: 0x23656b0) * {
--                __subclasses : table: 0x2365980 * {
--                                    class 'Sub1' (table: 0x2367ee0) : true,
--                                 },
--             },
--   __subclasses : table: 0x23680c0 * {
--                       class 'Sub1' (table: 0x2367ee0) : true,
--                    },
-- }
local Sub2 = Base:extend("Sub2")
-- class 'Base' (table: 0x23656b0) * {
--   __subclasses : table: 0x2365980 * {
--                       class 'Sub1' (table: 0x2367ee0) : true,
--                       class 'Sub2' (table: 0x236a490) : true,
--                    },
-- }
-- class 'Sub1' (table: 0x2367ee0) * {
--   super : class 'Base' (table: 0x23656b0) * {
--                __subclasses : table: 0x2365980 * {
--                                    class 'Sub1' (table: 0x2367ee0) : true,
--                                    class 'Sub2' (table: 0x236a490) : true,
--                                 },
--             },
--   __subclasses : table: 0x23680c0 * {
--                       class 'Sub1' (table: 0x2367ee0) : true,
--                    },
-- }
-- class 'Sub2' (table: 0x236a490) * {
--   super : class 'Base' (table: 0x23656b0) * {
--                __subclasses : table: 0x2365980 * {
--                                    class 'Sub1' (table: 0x2367ee0) : true,
--                                    class 'Sub2' (table: 0x236a490) : true,
--                                 },
--             },
--   __subclasses : table: 0x236af80 * {
--                       class 'Sub1' (table: 0x2367ee0) : true,
--                       class 'Sub2' (table: 0x236a490) : true,
--                    },
-- }
local SubSub2 = Sub2:extend("SubSub2")
-- class 'Base' (table: 0x17614c0) * {
--   __subclasses : table: 0x1761790 * {
--                       class 'Sub1' (table: 0x1761a10) : true,
--                       class 'Sub2' (table: 0x1762140) : true,
--                    },
-- }
-- class 'Sub2' (table: 0x1762140) * {
--   __subclasses : table: 0x1762320 * {
--                       class 'Sub2' (table: 0x1762140) : true,
--                       class 'SubSub2' (table: 0x1762870) : true,
--                       class 'Sub1' (table: 0x1761a10) : true,
--                    },
--   super : class 'Base' (table: 0x17614c0) * {
--                __subclasses : table: 0x1761790 * {
--                                    class 'Sub1' (table: 0x1761a10) : true,
--                                    class 'Sub2' (table: 0x1762140) : true,
--                                 },
--             },
-- }
-- class 'SubSub2' (table: 0x1762870) * {
--   super : class 'Sub2' (table: 0x1762140) * {
--                __subclasses : table: 0x1762320 * {
--                                    class 'Sub2' (table: 0x1762140) : true,
--                                    class 'SubSub2' (table: 0x1762870) : true,
--                                    class 'Sub1' (table: 0x1761a10) : true,
--                                 },
--                super : class 'Base' (table: 0x17614c0) * {
--                             __subclasses : table: 0x1761790 * {
--                                                 class 'Sub1' (table: 0x1761a10) : true,
--                                                 class 'Sub2' (table: 0x1762140) : true,
--                                              },
--                          },
--             },
--   __subclasses : table: 0x1762a10 * {
--                       class 'Sub2' (table: 0x1762140) : true,
--                       class 'SubSub2' (table: 0x1762870) : true,
--                       class 'Sub1' (table: 0x1761a10) : true,
--                    },
-- }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant