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

0020-macro-sensitive-imports #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions proposals/0020-macro-sensitive-imports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# ::enter feature name here::

* Proposal: [HXP-0020](0020-macro-sensitive-imports.md)
* Author: [0b1kn00b](https://github.com/ohmrun)

## Introduction

Cleaen imports without compiler switches

## Motivation

An error that often baffles me is where a type has been implemented at macro time but is also imported
at macro time and therefore compilation fails. Careful switches have to be placed and it's usability
minefield.

## Detailed design

Require imports to be qualified as `@:macro`, either in definitions (i.e `std`) or declaration side:

```haxe
@:macro import some.thing.i.NeedForMacros
```

This makes macro code more forgiving, and less error prone to badly placed switches and hunting through import dependency chains as it makes explicit what is needed in the macro context.

## Impact on existing code

I can't think of a backwards compatible version of this at the moment, but ports shouldn't be too much work given schlepping through dependency chain scope issues is something that macro writers already have to know how to do.

## Drawbacks

Tell me.

## Alternatives

I can do `#if macro #end` switches for every program that needs macros.

There might be a folder based version or a file extension version, I'm not sure.

## Opening possibilities

## Unresolved questions

What to you guys think?