PureBasic Forum
http://forums.purebasic.com/english/

Allow UseModule to export inherited idententifiers
http://forums.purebasic.com/english/viewtopic.php?f=3&t=73710
Page 1 of 1

Author:  Mistrel [ Tue Oct 01, 2019 2:26 am ]
Post subject:  Allow UseModule to export inherited idententifiers

Allow UseModule in DeclareModule to export inherited identifiers.

For example:

Code:
DeclareModule Triangle
  #Triangle=1
EndDeclareModule
Module Triangle
EndModule

DeclareModule Square
  #Square=2
EndDeclareModule
Module Square
EndModule

DeclareModule Pentagon
  #Pentagon=3
EndDeclareModule
Module Pentagon
EndModule

DeclareModule Shapes
  UseModule Triangle
  UseModule Square
  UseModule Pentagon
EndDeclareModule
Module Shapes
EndModule

Debug Shapes::#Triangle


This results in the following error:

Quote:
Constant not found: #Triangle.


To work around this we have to do this:

Code:
DeclareModule Shapes
  #Triangle=Triangle::#Triangle
EndDeclareModule


This duplicates code and is error prone due to tight coupling.

Note that this is scoped in DeclareModule which is public. The same behavior would not occur for UseModule on a Module block which is private.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/