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

rutie proc macros #145

Open
dsisnero opened this issue May 11, 2021 · 9 comments
Open

rutie proc macros #145

dsisnero opened this issue May 11, 2021 · 9 comments

Comments

@dsisnero
Copy link

wasmer-ruby wrote some proc proc macros - it would be good if these were integrated in rutie - haven't brought it up in the wasmer project yet.

wasmerio/wasmer-ruby#48

@syrusakbary
Copy link

cc @Hywan

@Hywan
Copy link
Contributor

Hywan commented May 13, 2021

Hi!

I wrote those macros. They aren't perfect, but they helped me on the short-term. I can dedicate some times to improve them if @danielpclark believes it can be useful for rutie :-).

@danielpclark
Copy link
Owner

Can I have some clarification on what exactly is being proposed to be added and improved upon? Is it some of the written crates/ in the link provided above?

I'm open for improvements, macros, helpers, and the like. If you're wanting to just add macros that help with the ease of use in writing Ruby methods/objects feel free to place those in src/dsl.rs. If the feature(s) require any external dependencies then I would recommend have them implemented as an optional feature.

From the sound of it it may indeed be something we want in Rutie itself.

@Hywan
Copy link
Contributor

Hywan commented May 17, 2021

I believe @dsisnero is talking about rutie-derive (I just wrote a succinct documentation today). It's the #[rubyclass], #[rubymethods] and #[rubyfunction] procedural macros. It's far from being perfect, but from my point of view, it provide a more intuitive API than the existing class! and methods! macro.

See a usage example, crates/wasmer/src/module.rs (or any file in this crates/wasmer/src/ directory).

I've also defined a new ruby_define! macro to declare the modules, classes, methods and functions, see it in action in crates/wasmer/src/lib.rs. We can do better here with proc macros but I was missing time.

If you find them useful, I can open a PR to integrate them inside rutie itself.

Bonus: I've also used rustdoc to generate a documentation for Ruby, see it in action here. All examples are tested by rustdoc (it's based on the rutie-test crate, see it in crates/rutie-test/).

@danielpclark
Copy link
Owner

@Hywan excellent! Yes I like those. Feel free to add them to this project.

@Hywan
Copy link
Contributor

Hywan commented May 25, 2021

I will try to find time to do that then!

@Hywan
Copy link
Contributor

Hywan commented May 25, 2021

The macros must be polished. For example, it's not possible to support optional parameter, or named parameter for a function or a method for the moment. Do we want to migrate the macros, and polish them here in this repository, or do you prefer to get a fully polished version first?

@danielpclark
Copy link
Owner

You can work on them here and polish them here. They don't have to be the best to go public, they just have to work. Those features you're describing that don't work yet can simply be a future update to this project.

@ilyazub
Copy link

ilyazub commented Jan 13, 2022

I'm working on a PR with migration. I've copied source files of rutie-derive and rutie-derive-macros from wasmer-ruby/crates/ to the newly created rutie/src/dsl folder and moved rutie/src/dsl.rs to rutie/src/dsl/mod.rs. I want to keep the directory structure of rutie with the least possible changes.

Not sure it's the best approach. Currently fixing compilation errors.

Maybe a better option is move rutie/src/* to rutie/crates/rutie and copy wasmer-ruby/crates/{rutie-derive,rutie-derive-macros} to rutie/crates/. Similar to what wasmer-ruby/crates.

@danielpclark @Hywan What do you think?

ilyazub added a commit to ilyazub/rutie that referenced this issue Jan 19, 2022
Copied rutie-derive and rutie-derive-macros crates with Git history
from https://github.com/wasmerio/wasmer-ruby.

According to wasmerio/wasmer-ruby#55 and
danielpclark#145.
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

5 participants