Can someone give a relatively simple example of the differences in Racket between call-with-composable-continuation and call-with-current-continuation.
I've worked through the examples in the Racket Guide 10.3 of call-with-composable-continuation, and the examples of call-with-current-continuation in The Scheme Programming language section 3.3 but I'm not clear on the difference.
Could someone give an example where they would give different results in the same context.
A very thorough explanation is found in the paper "Adding Delimited and Composable Control to a Production Programming Environment" by Flatt, Yu, Findler and Felleisen.
http://www.cs.utah.edu/plt/publications/icfp07-fyff.pdf
Related
I don't really understand the arguments and usage of define-syntax within Scheme. For what it's worth, I'm using Petite Chez Cheme. I've looked at a few sources:
define-syntax issue in scheme
Scheme Macro for nesting expressions
http://docs.racket-lang.org/guide/pattern-macros.html
However, they haven't given me the understanding I'm looking for. I'm looking for an explicit explanation of what's happening when the new syntax is applied. I'm particularly curious about the use of ellipses ("...") when the syntax is defined.
I managed to find a detailed document about patterns and define-syntax through a little bit more search. If anybody else is curious, here is the link:
http://www.cs.uml.edu/~giam/91.531/Textbooks/RKDybvig.pdf
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.
I am learning my way around Scheme, and I am especially interested in how the language is constructed. I'm trying to find a nice description of the core syntax for a Scheme implementation. I don't know enough about the standards, but I assume that they all contain macro systems. If not, I'd like to read about a standard that also includes macros (they can't possibly be implemented in simpler Scheme constructs, can they?).
Does anyone have a good reference for the minimal syntax needed for a Scheme dialect?
Just an update:
I also stumbled upon this: http://matt.might.net/articles/compiling-to-java/#sec1. If you also add define-syntax and delay then it seems like it might be a good start.
In the R5RS specification, the following page appears to be what I was looking for: formal syntax
Although it may be a bit dry, you should read over the R5RS spec or the R6RS spec.
The docs really do not take that long to read through and you can just skim most of the sections until you need more detail. But either document does cover all of the minimal syntax required, including macros.
Is there a reference website to look up syntax for Scheme library function like http://www.cplusplus.com/reference/?
I'm looking for syntax of fold, but google gave me nothing :(
Thanks,
fold is from SRFI 1. Many functions have good documentation if you know where it "comes from".
Also, since you're using Racket (as mentioned in your previous questions), you should check out the Racket documentation. It has a very nice search facility. (Also, you might like to know about Racket's foldl, which is identical to SRFI 1's fold.)
I am playing with the Racket recently, currently implementing a lexer for a subset of scripting language...and wondering whether there are more examples to show how to use the lexer generator in Racket?
I understand the calculator example in the doc, but it is too simple to show the full features...
I am especially curious how to reference position of each character....
The libraries at PLaneT are a great resource for more elaborate examples.
Try for example the Infix Parser .