-
-
Notifications
You must be signed in to change notification settings - Fork 36
Split Expression into OperandExpr and FunctionExpr #436
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
Comments
I like the change, but find the names a little confusing, since if you mentally expand "OperandExpr" you get "operand expression", which is weird because it suggests that this is an expression that is an operand, rather than having an operand. How about:
(I also thought about "UnaryExpr / NullaryExpr" instead of "AnnotatedExpr / AnnotationExpr", but then the annotation in a |
So if I understand right, with this proposal a variable reference expression {
type: 'expression',
body: { type: 'variable', name: 'foo' }
} would be represented instead as: {
operand: { type: 'variable', name: 'foo' }
} While this may match our syntax constructs better, why is that a good thing? Specifically, why should we expect someone reading We should also keep in mind that we may expect the data model to be used with messages originating in other syntaxes, which may not share the same structure as MF2. The current structure of a wrapper expression object with a body with variable shapes is intentionally aligned with such approaches. I also note that you've left out the reserved + private-use expressions from the proposal. Those will also need to be accounted for in the data model. |
@stasm Can I close? |
The data model proposed in #393 defines
Expression
as follows:A
FunctionRef
can also have aLiteral
or aVariableRef
as an argument, and in fact, due to how our syntax is designed, I'd argue that the function's argument is more important than the function. (E.g. it comes first in the syntax.)I'd like to suggest an alternative way to structure our expressions, to more closely map to our syntax:
Let's special-case argument-less functions rather than function-less operands.
Instead of
Literal | VariableRef | FunctionRef
here andoperand?: Literal | VariableRef
insideFunctionRef
, we can do:FWIW, this is how I implemented expressions in stasm/message2:
https://github.com/stasm/message2/blob/4abf43f2023b6e20d8ee1d462684d0741ece791b/syntax/ast.ts#L44-L70
Originally posted by @stasm in #393 (comment)
The text was updated successfully, but these errors were encountered: