uazu / stakker

A lightweight low-level single-threaded actor runtime
https://uazu.github.io/stakker/
Apache License 2.0
167 stars 9 forks source link

Can not initialise actor using fully qualified init method #20

Closed TmLev closed 3 years ago

TmLev commented 3 years ago

With the following code

let thing = actor!(
    stakker,
    some_crate::Struct::init(),
    ret_nop!()
);

Compiler fails with error:

error: no rules expected the token `::`
  --> tests/test.rs:37:35
   |
37 |             some_crate::Struct::init(),
   |                               ^^ no rules expected this token in macro call

I assume that the actor! macro does not expect anything apart from the struct's name and method, which is quite limiting.

uazu commented 3 years ago

You need: <some_crate::Struct>::init(). There is an example in the documentation for actor!. Perhaps it is not obvious enough?

As far as I can see, this is a limitation of the parsing rules for macro_rules!. I couldn't find a way to allow you to write it in a natural way. If I write $type:ty, that cannot be followed by a :: (see here).

If trying with <...> works, and reviewing the docs it seems clear enough, then please close this. If you can think of a better way to do this in macro_rules! let me know. If you think Stakker needs better documentation in this area, then let me know what would be helpful and I'll see about putting the changes in. Thanks.

TmLev commented 3 years ago

Oh, sorry -- I've been using stakker without the documentation for some time now, forgot to look there. Thanks for your quick response.