Closed metagn closed 2 years ago
Having one way to two ways to do things in macros would seriously complicate their maintenance and lead to spaguetti if/elif/else
I don't see what's complex with the postfix marker. There is plenty of examples out there that exist today. If anything "How-to" are needed. If we now have both ways, writing an "How-to" will be even more complex.
Lastly you can write a template or macro as pragma to do what you want.
There were already some defenses to those statements in the post (except yes postfixes aren't really complex), and I would expand further, but yeah this is an unproductive proposal
The export
method is for forwarding of symbols that stem from an imported module. It was never anticipated as an alternative to the export marker, that was a side-effect of the implementation that then got exploited.
There are 2 syntaxes for exporting newly defined symbols in current Nim.
These have some weaknesses:
class Foo*:
is impossible). Complicates the parsing of things like tuple unpacking syntax. Complicates macros as well when used, as they have to account for its unique syntax.The proposal is an additional syntax which also has weaknesses and is redundant in places; but is not super foreign, does not break existing code and compensates for the other export syntaxes.
Proposal
The
export
keyword can also be used as a pragma to export symbols it is attached to.Advantages
class Foo {.export.}:
compiles, meaning macros can use this.{.push export.}
, which saves having to type tons of*
s. This would only injectexport
into where*
is allowed.export
is a keyword, there is way less of a chance of conflict with existing custom pragmas.Criticisms
push
ed, Macros in general suck at being "standard" solutions for reasons beyond not being powerful enough.{.push export.}
is bad practice.exportc
.importc
/exportc
's fault for being named this way and they should have different names, but the average user shouldn't have to deal with this problem. So I don't know about this one.{.cast().}
was added recently.