Allow UseModule to export inherited idententifiers

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Allow UseModule to export inherited idententifiers

Post by Mistrel »

Allow UseModule in DeclareModule to export inherited identifiers.

For example:

Code: Select all

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:
Constant not found: #Triangle.
To work around this we have to do this:

Code: Select all

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.