Gluon: Add bindings to useful rust libraries

Created on 18 Aug 2016  路  10Comments  路  Source: gluon-lang/gluon

The current standard library is extremely minimal and so lacks a lot of stuff one may expect from a standard library. Creating and maintaining libraries are a ton of work though but if we use the embedding API it should prove much simpler (and we also get native performance for free!).

  • [ ] [regex](https://crates.io/crates/regex)
  • [ ] [rand](https://crates.io/crates/rand)
  • [ ] A vector/math library (Found these from a quick crates.io search vecmath cgmath nalgebra)
  • [ ] [num_bigint](http://rust-num.github.io/num/num_bigint/index.html)

These libraries do not necessarily need to be part of the standard distribution but bindings to these (or others!) would be really useful.

Marking as beginner since this should not require to deep knowledge of the internals, see the Tutorial on embedding and the primitives or the regex_bind module for how this is currently done. Also, it should be easier to start exporting APIs which do not require &mut references.

hacktoberfest help wanted

Most helpful comment

Adding simple bindings to regex, starting with just match : String -> String -> Bool and building from there would be a good idea.

All 10 comments

Adding simple bindings to regex, starting with just match : String -> String -> Bool and building from there would be a good idea.

I would like to take this!

Awesome! I noticed I didn't mention where to put these modules. I think for now the best place is in the main gluon crate as a submodule as the io module is now.

Don't hesitate to ask if you run into problems.

What type result should be... RuntimeResult<> ?

RuntimResult is used to indicate a function which may do a 'gluon panic' such as in array_index. Just as Rust would panic when doing an out of bounds index on a slice so do gluon (but 'gluon panic' are implemented without 'rust panic').

Only use it if you need a panicking function (such as array_index), otherwise you can return a Result<T, E> instead.

// Pseudo Rust
fn array_index(a: Array<A>) -> RuntimeResult<A, String>

// gluon type when embedded.
array_index : Array a -> a

Basic bindings to regex was added in #244. Extending this work with a find function should be possible without to much complexity.

Big integers would be nice to have http://rust-num.github.io/num/num_bigint/index.html !

Big integers can have prim literal 0n and type BigInt.

https://github.com/gluon-lang/gluon/blob/7b4a5a9923e8c01ebcbd60645d987f640883d880/base/src/ast.rs#L215-L221

BigInt(num_bigint::BigInt)

https://github.com/gluon-lang/gluon/blob/7b44c202ef17f2974e18d0b5998ac847f684b652/base/src/types/mod.rs#L217-L232

But how to deal with the original Int(i64) if it is a built-in type

How about std::Time bindings? I'll look into it if you think it's a good idea.

std::time is a good idea :+1: (just about anything in std that is useful in some way would be).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jrpascucci picture jrpascucci  路  6Comments

typesanitizer picture typesanitizer  路  12Comments

Marwes picture Marwes  路  3Comments

dgellow picture dgellow  路  7Comments

newtack picture newtack  路  14Comments