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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any plans for annotations on methods? #403
Comments
wren is a simple single-pass compiler, it could be tricky to support them. But if proved possible, it would probably not as powerful as those languages鹿. What do you need to do with them ? 鹿: I have no idea how they work in general. |
@minirop For my use case it'd be proposal 2. Some way for me to get a list of strings which represent the metadata "tagged" to the method or function. I don't need to be able to store information in the annotation. I.e. No This way I could load a directory of wren sources at server startup, inspect the functions for their annotations and wire that into our server socket hooks for the realtime pipeline. |
This is a really interesting idea. Wren's metaprogramming story is pretty barebones in general right now. One thing I worry about with metadata annotations (which I've seen be a problem in both Java and Dart) is that they tend to be used for two mostly unrelated things:
Annotations can support both of those, but I've seen it be a problem when the annotations from 1 are kept around at runtime where they aren't needed. They waste memory and code size. That may be less of an issue for Wren since Wren isn't an ahead-of-time compiled language anyway, but it left me feeling like annotations were a weird fit sometimes. Maybe the right answer is two separate solutions. Something like annotations in comments ( Python's decorators are also quite a bit more powerful than annotations in Java, because they can imperatively affect how the decorated function behaves. That could be useful for Wren, or could be a rathole of complexity. :) |
@munificent Thanks for the reply. I completely agree annotations are overused for two distinct use cases. I like the idea that there's a way to mark an annotation as retained at runtime separately to those which are part of some kind of compiler annotation pipeline. I'm not very familiar with Python's decorators but for my use case I don't need any way to imperatively affect decorated functions. I simply need a way at VM start to cycle through functions registered in modules and wire them into the socket pipeline. Let me know what syntax you have in mind and I'd be happy to work on bits of an implementation. 馃槃 |
@munificent Would you be able to give me an idea on what sort of syntax you have in mind for Wren and annotations? |
I am adding annotation functionality to my Gravity language, I decided for the following syntax and I'd like to make a suggestion for Wren: I think it could be also really useful to support the notations: |
It's hard to do good syntax design in a vacuum, so it depends a lot on:
Having said that |
Some languages have a way to attach and process custom syntactic metadata on methods in source code:
I wonder if there's plans to add support for this feature to Wren. I'm currently looking around for a potential alternative to Lua as an embedded scripting language for our distributed game server. We had/have planned to use Lua and used it in a previous generation of our server technology but I found Wren and it fits the perfect sweet spot with its rationale as an alternative choice to Lua.
The only part it misses before I can investigate it on an experimental branch for the server is some way to attach metadata to methods. This would be nice for our use case because we have a sequence of hooks points in the socket pipeline where custom scripts can be used to execute on input data like a user's virtual wallet or their quest/challenge reward. Ideally I'd like to keep the registration for the hooks next to the method which they register. For example (Wren pseudo code):
The text was updated successfully, but these errors were encountered: