gluon icon indicating copy to clipboard operation
gluon copied to clipboard

Add bindings to useful rust libraries

Open Marwes opened this issue 8 years ago • 10 comments

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!).

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.

Marwes avatar Aug 18 '16 18:08 Marwes

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

Marwes avatar Sep 29 '16 21:09 Marwes

I would like to take this!

nxnfufunezn avatar Oct 13 '16 06:10 nxnfufunezn

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.

Marwes avatar Oct 13 '16 07:10 Marwes

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

nxnfufunezn avatar Oct 13 '16 08:10 nxnfufunezn

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

Marwes avatar Oct 13 '16 08:10 Marwes

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

Marwes avatar Jan 26 '17 16:01 Marwes

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

Marwes avatar Nov 22 '17 09:11 Marwes

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

oovm avatar Jun 18 '19 02:06 oovm

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

Etherian avatar Aug 22 '19 02:08 Etherian

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

Marwes avatar Aug 22 '19 08:08 Marwes