Giter VIP home page Giter VIP logo

Comments (5)

Kobzol avatar Kobzol commented on July 16, 2024 1

I changed it to use and I like how it reads, but if I'm not missing anything it seems that it cannot actually be used, because it's an actual keyword and when I parse the attribute, it expects a path after use and therefore I cannot use it as use(name). Unless we want to write something like r#use :-)

call doesn't have this problem, since it's not a keyword and I think that it's more explicit, even though we actually generate #[inline(always)] by default, so the call might only be there at compile time :)

Also when the user specifies inline manually, like this:

#[inline(always)]
#[call(method)]
...

it reads a bit weird, but it's a small detail I suppose.

Another thing that came up is wrap, but it doesn't have a well established meaning in this crate (and in general it's a very overloaded term), so that's probably worse than call.

from rust-delegate.

Kobzol avatar Kobzol commented on July 16, 2024

I like as, but I see two problems with it:

  1. In my opinion the name as implies that it will generate code like this:
#[as(len)]
pub fn size(&self) -> usize;
v
pub fn len(&self) -> usize { self.inner.size() }

But in the current implementation, the renaming order is reversed, i.e. it would actually generate this:

pub fn size(&self) -> usize { self.inner.len() }

I looked at the implementation briefly and it's much easier for me to change the name in this direction. I will try to modify it so that I could also use the other direction, but I'm not sure if it's possible to do so easily.

  1. When the user writes pub fn size(&self) -> usize;, I think that it is more natural that the actual method will have exactly this signature, i.e. I think it's better if the attribute changes the underlying method call and not the signature. as sounds like you are changing the signature (export this function as len).

If we keep the current implementation, we have to use a name that obviously changes the called method and not the signature. call(len) or use(len) seem like good alternatives to me.

from rust-delegate.

Boscop avatar Boscop commented on July 16, 2024

@Kobzol
Yes, I agree, I did not mean to suggest swapping the order of the callee and caller (and I don't think we should support this swapping in any way, to avoid confusion).
I also agree that as could be misinterpreted to mean that.
Actually, I hadn't thought of use(len), but it looks like the best option to me! :)

from rust-delegate.

chancancode avatar chancancode commented on July 16, 2024

What about target or using πŸ€” it’s a few characters more but I honestly don’t think that difference would matter

from rust-delegate.

Boscop avatar Boscop commented on July 16, 2024

I think call is a good choice!

from rust-delegate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.