Jump to content

Category:Wren-i64

From Rosetta Code
Library
This is an example of a library. You may see a list of other libraries used on Rosetta Code at Category:Solutions by Library.

Wren-i64 is a module which brings support for 64-bit integer arithmetic to the Wren programming language by wrapping the corresponding C99 fixed length types. It consists of 4 classes: I64, U64, I64s and U64s. The first two deal respectively with signed and unsigned arithmetic and the latter two contain static methods for dealing with lists of such objects.

It is the thirty-third in a series of modules (listed on the language's main page) designed to assist with writing Rosetta Code tasks so the same code does not have to be written or copy/pasted time and time again thereby bloating a task's script code unnecessarily.

To use it you need to copy the Wren source code (in the talk page) to a text file called i64.wren and place this in the same directory as the importing script so the Wren-i64 executable can find it.

As there is a dependency on the Wren-trait module, you also need to copy that (if it is not already present) to the same directory as described here. Unless you are using classes in that module directly, there is no need to 'import' them into your script and the Comparable class can even be imported via Wren-i64 itself.

Currently, Wren-cli does not support plug-ins though this or similar functionality is likely to be added in a future version (it's already present in DOME). Consequently, scripts using the Wren-i64 module must be run under the control of a special executable whose source code (wren-i64.c) is also included (in the talk page). This executable translates Wren method calls to calls to the corresponding C99 functions and can be built with a command line such as the following using GCC under Linux:

   $ gcc -O3 wren-i64.c -o wren-i64 -lwren -lm

If you then want to run a script called myscript.wren you would type at the command-line:

   $ ./wren-i64 myscript.wren

myscript.wren should include a line such as the following to import the classes you want to use in that particular script:

   import "./i64" for I64, U64, I64s, U64s // only import ones you actually need

The same executable can be used to run any other Wren-i64 scripts unless they require additional functionality not available in Wren itself in which case the C code will need to be suitably modified and recompiled.

The executable is written using standard C99 code and has no external dependencies.

Pages in category "Wren-i64"

This category contains only the following page.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.