tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
185 stars 42 forks source link

MacroContext needs a real-/base-Name property #65

Closed tmedwards closed 4 years ago

tmedwards commented 4 years ago

MacroContext needs a realName/baseName property—something to that effect—so that user aliases may reference the correct macro.

Currently, macros that have multiple names by default—e.g., <<button>> and <<link>>—often use this.name to select features of the macro—e.g., which element to use, which behaviors, etc. User aliases break that by changing the name of the macro. Thus, MacroContext instances should include a property that specifies the real/base name of the macro, so that the handler may use that name when selecting features, rather than the current/apparent name. With that, user aliases of such macros would always use the proper code.

This will likely require modifications to Macro as well.

Uzume commented 4 years ago

I think I would have named the new context field alias instead of displayName. The existing name can then be consider the canonical name and alias already semantically means it is not canonical (meaning the name it was invoked under and errors, etc. can use it for display purposes, etc.).