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

Stable methods with enumerations as input #216

Open
markATavail opened this issue Jul 30, 2021 · 0 comments
Open

Stable methods with enumerations as input #216

markATavail opened this issue Jul 30, 2021 · 0 comments

Comments

@markATavail
Copy link
Member

markATavail commented Jul 30, 2021

When a stable method is invoked with a constant argument, a macro gives it the opportunity to be evaluated at compile time, producing a literal phrase in response. If the arguments have any non-singular enumeration types, the macro aborts.

Instead, at compile time we could invoke the method for each value, since it’s stable. If all runs succeed, we can then narrow the semantic restriction to be the enumeration of each of the produced values, substituting a literal phrase if all invocations produced the same value. We could also collect the inputs and outputs into a map, and produce a send phrase that simply looks up the answer.

Use case:

c : ¢[A-Z]ᵀ;
i ::= c’s code point;

The current Avail behavior is for i to be typed [0..1114111]. I’d like it to be [$A’s code point..$Z’s code point].
I guess a stronger semantic restriction in this one case would be enough.

We could make the above behavior be an implicit part of the compiler, as long as we tagged method signatures and raw functions as stable. Then even methods like map_through_ could be marked stable, but abort the macro if it detects the transformation function's raw function isn’t stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant