You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[...] macros can also accept arguments as values. However, only built-in value types (int, bool, etc.) are allowed and arguments must be simple literal expressions.
I think we should support "collections" of built-in value types and (adjascent or as part of #2091) type literals and identifiers. "Collections" means Lists, Sets, and Maps, though I don't have thoughts on any type restrictions on the key of a Map (maybe just String? Maybe no restriction beyond "only built-in value types"?).
For example:
@GenerateSomething([Foo, Bar])
which allows access to Foo and Bar as Identifiers, or as type literals, etc.
This raises a question about spreads. Today, the typical way to write an annotation which includes a list literal which folds in elements from a constant defined elsewhere is a spread. Can we allow:
Allowing this would be consistent with the support that constant evaluation provides, but might be extremely difficult / impossible because it requires constant evaluation. Maybe we could sidestep constant evaluation by saying only a subset of constant values are supported in a collection of type literals or Identifiers...
#2094)
Attempt to close#2093, and #2092. Related to #2012.
- Adds `Identifier`, `List`, and `Map` as valid parameter types for macro constructors (and thus valid arguments for macro applications).
- List and Map are allowed to have type arguments that are any of the supported types. This allows for `List<Identifier>`, etc.
- Specify the scope for identifiers in macro application arguments better (both bare and in code objects).
- Some other unrelated cleanup (can remove if desired).
- Fixed up some old links
- Removed the section on `Fragment` (you can just use `Code` for this now).
The macro spec currently says:
I think we should support "collections" of built-in value types and (adjascent or as part of #2091) type literals and identifiers. "Collections" means Lists, Sets, and Maps, though I don't have thoughts on any type restrictions on the key of a Map (maybe just String? Maybe no restriction beyond "only built-in value types"?).
For example:
which allows access to
Foo
andBar
as Identifiers, or as type literals, etc.This raises a question about spreads. Today, the typical way to write an annotation which includes a list literal which folds in elements from a constant defined elsewhere is a spread. Can we allow:
Allowing this would be consistent with the support that constant evaluation provides, but might be extremely difficult / impossible because it requires constant evaluation. Maybe we could sidestep constant evaluation by saying only a subset of constant values are supported in a collection of type literals or
Identifiers
...cc @munificent @jakemac53
The text was updated successfully, but these errors were encountered: