Chicken Scheme: make-table unbound variable - chicken-scheme

I am trying to declare a hash table. Based on this SRFI I believe that the form (define x (make-table)) ought to result in the correct behavior; however, I am getting the following error.
CHICKEN
(c) 2008-2017, The CHICKEN Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.12.0 (rev 6ea24b6)
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2017-02-19 on yves.more-magic.net (Linux)
#;1> (make-table)
Error: unbound variable: make-table
Call history:
eval.scm:211: ##sys#get
eval.scm:218: values
eval.scm:255: ##sys#alias-global-hook
modules.scm:769: ##sys#qualified-symbol?
modules.scm:777: ##sys#active-eval-environment
modules.scm:777: g2354
modules.scm:784: mrename
modules.scm:762: ##sys#current-module
eval.scm:259: ##sys#symbol-has-toplevel-binding?
eval.scm:265: ##sys#symbol-has-toplevel-binding?
library.scm:1668: after
eval.scm:857: g1785
<eval> (make-table)
library.scm:4051: ##sys#get-call-chain
library.scm:3834: ##sys#make-vector
library.scm:1371: ##sys#allocate-vector <--
In addition, I am getting similar errors for other functions. Is it possible I have installed the interpreter incorrectly?

CHICKEN does not ship with SRFI 90, and as far as I can tell so far nobody has made an egg for it, either. An earlier and more commonly used hash table library, SRFI-69, is part of core, though. It is also not available by default, you'll need to use it like so:
(use srfi-69)
In CHICKEN 5 (which I highly recommend you install, as it has many many improvements and is the currently supported major version), SRFI-69 is no longer part of core but can be installed as an egg via chicken-install. There, use no longer exists. Instead, after installing the egg you can import it like so:
(import srfi-69)
As an aside, SRFIs are "requests for implementation", and not every Scheme system implements every single SRFI. Sometimes because people object to the SRFI (some are controversial), sometimes because nobody has gotten around to it, sometimes because the SRFI is unimplementable/does make sense for a particular Scheme (for example, a C FFI makes no sense in a Scheme running on the JVM).
You'd have to check your Scheme's features to see if the SRFI you'd like to use is included. Note that for CHICKEN, many SRFIs are implemented outside of the core via eggs. CHICKEN core includes only a handful of SRFIs, like 0, 1, 2, 4, 6, 8, 9, 11, 13, 14, 15, 16, 17, 23, 30, 39, 55, 69. In CHICKEN 5, the SRFIs 1, 13, 14 and 69 have been taken out of core as they can be implemented externally quite easily. Check the list of eggs for more SRFI implementations.
Edit: I forgot, there's a wiki page that strives to list all supported SRFIs exhaustively. It hasn't been updated for CHICKEN 5 yet, but the list should eventually be the same, as more and more eggs get ported from CHICKEN 4 to 5 (and even become longer, given that CHICKEN 5 sees much new development).

Related

Chicken Scheme - Error: unbound variable: command-line-arguments

Chicken doesn't seem to recognize command-line-arguments. I've tried compiling the .scm and running (display (command-line-arguments)) and it throws unbound variable every time. I've reinstalled from the Void Linux repository.
You will have found the documentation for command-line-arguments on the documentation for the module (chicken process-context). These modules aren't loaded by default in CHICKEN 5, as opposed to CHICKEN 4 (where it was quite ill-defined what was loaded there by default).
In CHICKEN 5, as is documented in the manual page explaining about Modules, by default only scheme, (chicken base) and (chicken syntax) are available to a program. Anything else you will need to explicitly import.
So, long story short, your program needs a (import (chicken process-context)) at the start, that should fix it!

Swift 2.2: #if swift(>=x.y) version build configuration: can it be used to check sub-versions? (E.g. distinguish Swift 2.1 from 2.1.1)

With Swift 2.2, we can now make use of the #if swift(>=x.y) version build configuration, as proposed in SE-0020 of Swift evolution.
#if swift(>=2.2)
print("Active!")
#else
this! code! will! not! parse! or! produce! diagnostics!
#endif
I've tried, out of curiosity, to attempt to use this with one step lower subversion level comparison (say >=2.1.1 without passing Swift 2.1 from XCode 7.1 beta 2), but my own attempts don't really work:
>=x.y.z yields an error,
expected named member of numeric literal
>=x.y with y = 11 naturally compiles and passes but as a version we're yet to see, 2.11.
I can't find any further details regarding this in the XCode 7.3 release notes.
Question: Is this new version build configuration limited to a single .y subversion, or is there some trick to circumvent this?
Answer: The new version build configuration is limited to two version components.
From Swift Evolution, proposal SE-0020: Swift Language Version Build Configuration
Detailed design
...
For now, we'll only expect up to two version components, since it will
be unlikely that a syntax change will make it in a +0.0.1 revision.
More details can be found in the associated Swift Evolution thread, most specifically in this exchange between Chris Lattner and Douglas Gregor:
On Dec 18, 2015, at 3:34 PM, Douglas Gregor via swift-evolution wrote:
...
On Dec 18, 2015, at 12:29 PM, Chris Lattner via swift-evolution wrote:
...
The argument to use a string is if we wanted to support subversions, e.g. like “#if swift(2.2.1)”. This requires the parameter to be a string, because 2.2.1 isn’t a valid floating point literal - the lexer will be displeased.
...
This feature LGTM, and I also prefer that we drop the quotes.
Two levels of version number should be sufficient.

What extension allows access to time function in r5rs?

A 4-year-old old post suggests that one might be able access the current-seconds and related functions in the r5rs language.
Here's why I ask: I'm a high school teacher new to Racket and we are using the r5rs language. I would like to introduce students to functions by starting with a function that needs no arguments to make sense. The example that occurs to me is minutes-past-the-hour. But I am ignorant of how to make those functions recognized in an r5rs program.
Thanks for any helpful advice.
First of all, why not use #lang racket instead of r5rs? Racket is very much built with education in mind. It even has various teaching languages for use with the How to Design Programs textbook (or its second edition, which is still being worked on).
Racket's implementation of R5RS is intentionally limited—it's not usually intended to be used for anything practical, since Racket itself has outgrown its Scheme roots. It can be useful as a teaching tool, but as you've seen, it doesn't include any special extensions (beyond a small set of internal forms).
If you're really interested in using R5RS Scheme, there exists an implementation of SRFI 19: Time Data Types and Procedures bundled with Racket. R5RS does not have a module system, so there is no formally-specified way of loading external libraries in pure Scheme. You'll need to use the Racket #%require extension to load the SRFI implementation:
(#%require srfi/19)
This will give you access to all the SRFI 19 functions and values.
You could also just include the functionality you want from Racket itself, since the languages are actually interoperable. To include current-seconds, you'd want to do something like this:
(#%require (only racket/base
current-seconds))
If you're going to do that, though, it seems almost pointless to use the r5rs language. Just use racket or racket/base instead.

What is the main difference between SRFI 40 (deprecated) and 41?

In SRFI 40 we can see it is deprecated and superseded by SRFI 41. I'm using SISC where SRFI 40 is present but SRFI 41 isn't. I would like to know the main difference between them and can I use the SRFI 40 normally without fear?
SRFI-40 leaks in some circumstances. See the times3 function in the "Pitfalls" section of SRFI-41. See also the post-finalization discussion of SRFI-40.
It is possible to patch SRFI-40 to fix the problems, and some users have done so. I'm not sure if SISC has been patched. Also, David van Horn and Andre van Tonder have both made changes to the original reference implementation of SRFI-40, so I'm not sure but that may also work properly now. I personally avoid the problem and use SRFI-41.
Is there any reason SRFI-41 can't be used in SISC?
I am the author of SRFI-40 and SRFI-41.

HtDP / Chpt. 5: How do I use "symbol=?"? (Scheme)

I'm currently working through HtDP on my own.
In Chapter 5 "Symbolic Information" is covered. The example in the text is:
(define (reply s)
(cond
[(symbol=? s 'GoodMorning) 'Hi]
[(symbol=? s 'HowAreYou?) 'Fine]
[(symbol=? s 'GoodAfternoon) 'INeedANap]
[(symbol=? s 'GoodEvening) 'BoyAmITired]))
That's all clear. However, the second exercise asks:
Exercise 5.1.2. Develop the function check-guess. It consumes two numbers, guess and target. Depending on how guess relates to target, the function produces one of the following three answers: 'TooSmall, 'Perfect, or 'TooLarge.
Frankly, I don't really see when or why "symbol=?" comes in here. My solution only uses "cond". [EDIT: Code removed due to a suggestion since it is a solution to a textbook exercise.]
According to the text, "symbol=?" consumes two symbols and returns either true or false, depending on whether they are identical or not.
I fear that I am now deep into the realm of the Dunning-Kruger effect, but I really don't see a way to implement this piece of code with the use of "symbol=?". "cond" is covered in Chapter 4, which is why I am now confused.
Any help is highly appreciated.
If you want to have a look at the chapter in HtDP, then please go here:
http://www.htdp.org/2003-09-26/Book/curriculum-Z-H-8.html#node_sec_5.1
Unfortunately, the solutions are only accessible with a password.
use < and > to compare the numbers. You can't to use symbol=? for this.

Resources