r6rs | R6RS compliant Scheme interpreter in JavaScript | Interpreter library
kandi X-RAY | r6rs Summary
kandi X-RAY | r6rs Summary
A Scheme interpreter (Currently partly R6RS compliant).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of r6rs
r6rs Key Features
r6rs Examples and Code Snippets
Community Discussions
Trending Discussions on r6rs
QUESTION
The following get_file
function reads file from disk as a Scheme R6RS string:
ANSWER
Answered 2021-May-04 at 02:13You can use get-string-all
:
QUESTION
I'm new to Chez, and just looking for some clarity given the various maintained and unmaintained repos existing.
Is there a single commonly preferred source repo to obtain the R6RS SRFI libraries (specifically for Chez Scheme)?
I know about https://srfi.schemers.org/ which is good for searching for individual SRFI documentation, and has a tgz of all documentation and some scheme code, but there is no version or release info on the tgz (although the timestamps suggest it's fairly up to date https://srfi.schemers.org/srfi.tgz).
For R6RS I can find most of the SRFIs as separate repos under the following repo, which isn't very practical to grab all the code: https://github.com/scheme-requests-for-implementation
And then a variety of other repos, eg:
https://github.com/arcfide/chez-srfi
https://github.com/ovenpasta/thunderchez
https://github.com/dharmatech/surfage
https://bazaar.launchpad.net/~scheme-libraries-team/scheme-libraries/srfi/files
The only ones with recent activity, and luckily also seem to be Chez-focused, seem to be chez-srfi and thunderchez.
chez-srfi seems the most recently active, and once I worked out the requirement to run link-dirs.chezscheme.sps
and then softlink the chez-srfi
directory to srfi
it seems to work using the standard import references - (import (srfi :N lib))
.
That said I've had similar success using (import (srfi sN lib))
using Thunderchez.
I'm completely agnostic over which repo I use, providing it's easy to use and actively kept up to date. Is there a clear preferred choice providing this, or is choice based more cosmetically on personal opinion (in which case I'll form my own rather ask it on here!).
...ANSWER
Answered 2020-May-16 at 17:20The honest answer is probably "no" - there is not a single version of srfi preferred by the community.
But to (kinda) answer my own question, whilst I can't say it's a defacto standard yet, Akku is a package manager and virtual environment management system of Scheme that is miles ahead of any of the alternatives, and actively developed. It's not an individual implementation of srfi, but is a way to install various Scheme packages you need to use through a single interface.
It's not quite venv and pip - but it's getting there. I'm amazed this isn't talked about more, I only stumbled upon it some time after my initial search for a tool like this.
You get a single interface to pull packages for both R6RS and R7RS, and a range of Scheme implementations.
There is also Snow, which is currently only supporting R7RS: http://snow-fort.org/
But as Akku mirrors Snow as well as providing R6RS support, it is more comprehensive.
To answer the specifics of the original example - Akku installs chez-srfi by default (on a Chez Scheme system at least) on creation of a new project, but also offers thunderchez as a package. Whether that indicates a preference by the Akku developer's, I'll leave up to the reader to decide.
The original question was about a single defacto srfi implementation for Chez, rather than a more general package manager. In hindsight this misses the point a bit, simply because I didn't think a single package manager (beyond srfi) was a remote possibility.
So for my use at least - Akku, not only provides various implementations of srfi, but also offers a host of other packages, and largely answers my question.
QUESTION
Scheme provides a bytevector
type which can be used to do low-level operations on bytes abd array of bytes (see r6rs and chez manual). However, it does not seem to provide a way to retrieve the underlying pointer to the array of bytes it is storing and I need that pointer to pass to foreign C functions to fill or read data from the bytevector.
To be more precise about the context, I am trying to write some code for low-level handling of bytes in Idris2 which is using Scheme as its backend, but I am a newbie in Scheme so I am certainly overlooking something obvious: What's the preferred approach to extract this pointer from the bytevector?
...ANSWER
Answered 2020-Apr-19 at 10:22An operation that returned a bytevector's address as an integer would be dangerously unsafe, since the garbage collector might subsequently move the bytevector and place other objects there. Passing a stale address to C code could cause memory corruption.
The docs for Chez Scheme's foreign-procedure
say that an argument declared as u8*
accepts a bytevector and passes the address of its contents to the foreign function. That's safe, because the FFI and GC cooperate to make sure the object is not moved between taking the address and calling the foreign function --- but see the warning about retaining the pointer in foreign data structures. See also lock-object
, which temporarily prevents the GC from moving or reclaiming an object.
In Racket, the _bytes
and _pointer
foreign types work similarly. There's also a ptr-add
operation that combines a pointer-like object with an offset. For example, if bs
is a bytestring, then (ptr-add bs 1 _byte)
is reliably converted to the address of the second byte of bs
, even if the GC moves bs
. I don't know if Chez has a similar feature.
QUESTION
In r6rs grammar for numbers there is this rule:
...ANSWER
Answered 2020-Feb-29 at 14:00It's polar notation for complex numbers @. I've never found documentation for it other than the syntax but I'd guess that is in radians.
(magnitude 2@2) => 2.
(angle 2@2) => 2.
QUESTION
As an exercise to learn call/cc and macros, I tried to define goto.
...ANSWER
Answered 2019-Oct-19 at 22:44I think top level is different in different implementations. For Racket, call/cc
captures continuation up to a single, top-most expression, not the whole program. I think Guile captures up to the whole program. Hence the difference.
You can get Guile's behavior by writing your code in a function:
QUESTION
I'm using quite a lot of (standard R6RS) hashtables in Chez Scheme, but it's not very nice working with them at the REPL because they are just printed as #
. I have written a print-table
function but it's a bit annoying to keep calling it every time I want to inspect my data.
It looks like Racket has a way to do custom printing for a given type. Is there any way to do something similar in Scheme?
...ANSWER
Answered 2018-Dec-29 at 03:10Chez Scheme does allow for custom reading and writing of most records, including hashtables. Chez Scheme provides a record-writer
and record-reader
procedure which allow customizing the functions used to write and read records:
http://cisco.github.io/ChezScheme/csug9.5/objects.html#./objects:s176
There are some good examples on that page, but an important detail is that you can specify #f
as the writer, the default for new record types, which will use a format capable of being read back by the default reader. This won't work 100% of the time as there are some types which have no serializable representation, like functions.
Once I disable the special printer for eq-hashtables and the special printer for the base hashtables, I can see the default representation:
QUESTION
A way to rotate a matrix is by getting it's transpose and then reversing all the rows. I've got around it with two functions, map (which returns the transpose) and reverse (completing a 90° rotation), in console I do the following:
...(reverse (apply map list (list (list 1 2 3 4) (list 5 6 7 8) (list 9 10 11 12) (list 13 14 15 16)) ) )
ANSWER
Answered 2018-Nov-02 at 06:40Your input was incorrect.
QUESTION
This simple R6RS program:
...ANSWER
Answered 2018-Jun-12 at 16:15The Racket implementation of R6RS is not non-compliant in this case. Indeed, if anything, it is obeying the standard more closely: your program as-written is not careful about import phases. The problem is that define-syntax
evaluates its right-hand side during expand-time, as noted by section 11.2.2 Syntax definitions:
Binds to the value of , which must evaluate, at macro-expansion time, to a transformer.
Unlike other Scheme standards, R6RS takes care to distinguish between phases, since it permits arbitrary programming at compile-time (while other Scheme standards do not). Therefore, section 7.1 Library form specifies how to import libraries at specific phases:
Each specifies a set of bindings to be imported into the library, the levels at which they are to be available, and the local names by which they are to be known. An must be one of the following:
QUESTION
I am learning Scheme, coming from a background of Haskell, and I've run into a pretty surprising issue - scheme doesn't seem to have custom data types??? (ie. objects, structs, etc.). I know some implementations have their own custom macros implementing structs, but R6RS itself doesn't seem to provide any such feature.
Given this, I have two questions:
- Is this correct? Am I missing a feature that allows creation of custom data types?
- If not, how do scheme programmers structure a program?
For example, any function trying to return multiple items of data needs some way of encapsulating the data. Is the best practice to use a hash map?
...ANSWER
Answered 2018-Apr-18 at 22:42- Absolutely not. Scheme has several SRFIs for custom types, aka. record types, and with R7RS Red edition it will be SRFI-136, but since you mention R6RS it has records defined in the standard too.
Example using R6RS:
QUESTION
It's very common for Scheme macros to make "derived" identifiers, like how defining a record type foo
(using the R6RS syntactic record API) will by default define a constructor called make-foo
. I wanted to do something similar in my own macro, but I couldn't find any clean way within the standard libraries. I ended up writing this:
ANSWER
Answered 2017-Dec-29 at 21:43Although it might not be a hygienic macro, i suppose you could use define-syntax like this (in chicken scheme). For chicken scheme the documentation for macros is here. Also this SO question sheds some light on chicken scheme macros. Finally i don't know if this would be an idiomatic way to approach the problem.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install r6rs
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page