-
Notifications
You must be signed in to change notification settings - Fork 543
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
Convenience syntax for helper functions #174
Comments
We could also try to have a way to "initialize" inline // no arguments
callback foo => { /*...*/ }
// with arguments
callback foo(abc: int) -> int => { /* ... */ } Or is this We also need to consider the side effects an threading issues of these function. I think we have the following dimention for different kind of function or callback:
Maybe we can use these keywords
|
IMO yes. I'd prefer I like the proposed table though, that's nice. |
@tronical and I discussed this today. We realized that there is many dimension to the problem of declaring a callback:
We haven't agreed on a good way to declare purity and if it should be the default and enforced. ( But we agreed that there is a need for non over-writable function such as
For callback, we decided to
|
To clarify what you mean, in that example |
Our current thinking is this:
If you want to call a function from a binding or pure function, you then need to declare it pure. Later, if you |
PR that implements it: #1989 |
Elsewhere in Rust the default is the "safe" or "better" option and you have to opt-in to the other option, eg by using |
We indeed are wondering if the default should be pure or impure. For function it is a bit less clear what the default should be. Making it a different default based on the return value doesn't sound like a good idea. That said, it is not clear what in pure or impure is the "safer" or "better". The equivalent of pure in rust would be |
Right, so maybe having a side affect isn't strong enough reason to choose between pure/impure by default. And as you say for functions Rust doesn't use Reading your blog there is the example of calling a function that has a side affect during property evaluation.
Once there are pure/impure, are you thinking here that the binding would need to have something tagged onto or an unsafe block to indicate that the developer really does want to call an impure function ? such as |
Based on the experiment in #1989 , I noticed that, after porting the examples to annotate the callback with |
Done |
At moment it's possible to use callback handlers to define what can function as helper functions:
This works well in the sense that the
callback helper
declaration acts like it is declaring a property and the handler declaration assigns the right body to it. It would be great if the parser would support a more convenient syntax to achieve the same semantical result:The text was updated successfully, but these errors were encountered: