Giter VIP home page Giter VIP logo

Comments (5)

mulkieran avatar mulkieran commented on July 3, 2024

There is a question of types. Looking at the Python version that does the wrapping, and imagining the same actions...

  • A simple type is easy, I think. |_:T| |x: u16| MessageItem::UInt16(x) should do it, assuming a signature of 'q' The type is obvious.
  • An array is tricky, maybe. We have to take a function arg, the function for handling the array elements. So, something like: |func| |vec: Vec<T>| MessageItem::Array(<calling func on each element>). What is the type of func? T -> MessageItem, presumably.

The parameter type of the inner functiion will vary. Ultimately, it will depend on the signature.
But it will end up being applied to something of the correct type.

Of course, whether or not there is a Rust parser that will do the trick is not yet known.

There is not an obviously better way, though.

Probably the best way to use such a function would be to define methods that simply returned the message values as a tuple of native Rust types.

Then define a generic function that takes a return message and the arguments, transforms the arguments, and appends them to the message before returning.

from stratisd.

mulkieran avatar mulkieran commented on July 3, 2024

rust peg would work just fine: https://github.com/kevinmehall/rust-peg

from stratisd.

mulkieran avatar mulkieran commented on July 3, 2024

This blog article gives a long list of other: http://smallcultfollowing.com/babysteps/blog/2015/09/14/lalrpop/.

  • nom is definitely overkill
  • oak looks thorough and is embeddable as an extension, which is nice
  • nailgun is not ready, says the developer
  • peggler, ditto
  • combine looks promising
  • LALRPOP might be excessive
  • racc is not ready
  • lemon_rust doesn't look bad either

from stratisd.

mulkieran avatar mulkieran commented on July 3, 2024

Well, it turns out that the CLI approach is absolutely impossible, because it would require Rust to have dependent types, which it doesn't.

It also turns out that the dbus-rs has functionality that is supposed to make this much easier, but it seems to prevent our distinguishing between missing arguments and arguments with the wrong type.
See: diwic/dbus-rs#51.

from stratisd.

mulkieran avatar mulkieran commented on July 3, 2024

Closed by #76.

from stratisd.

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.