Basic racket syntax question - syntax

I came across the following piece of syntax in Racket, could anyone tell me what it means? I tried Googling it to no avail.
symbol=?

If you're using DrRacket, then hit F1 to find this documentation:
(symbol=? symbol1 symbol2 symbol3 ...) procedure
Returns #t if the symbols are the same, i.e., if their names are spelled the same.

I think that the confusion here is that symbol=? looks like some syntax for some weird expression. Racket follows Scheme and Lisp tradition where the syntax is pretty minimal: identifiers are very permissive, so this whole thing is just a name of a function. (And see rm's answer for what the function actually does.)

Related

Little Schemer - IDE [duplicate]

I'm starting to read the Little Schemer and now instead of PLT Scheme we have Racket. I would like to know if Racket is suitable for doing the exercises in the book or do I need to get another true Scheme compiler. Before I forgot to tell you, my OS is Windows x64.
The book, language and paradigm is complex enough, I would love to avoid struggling with a compiler.
DrRacket is the (r)evolution of DrScheme; DrRacket will work perfectly for the exercises in "The Little Schemer". Just don't forget to:
In the Language dialog, choose "Use the language declared in the source"
Write #lang racket at the top of each file you create
Implement the atom? predicate in each file as explained at the very beginning of the book
If you're going to re-implement an existing procedure, do so in a separate tab or window, because trying to rewrite a procedure in the edit window will result in a duplicate definition for identifier error. If necessary, use several files for saving the procedure definitions
You really just need the atom? function. What’s described in the book's preface is essentially:
(define (atom? x)
(and (not (pair? x)) (not (null? x))))
As mentioned, it should satisfy this test:
(atom? '()) ;=> #f
Note that there is also a definition in Racklog that will not satisfy that test.
A more detailed discussion on atom? is here.
Despite the book's suggestion to implement add1 and sub1, Racket does already provide them.
BTW, I use Vim for editing Racket, but a few other editors are capable.
I have had the author of the book as a professor. He now uses Racket himself, but he uses Emacs as a text editor.
Racket/Scheme are interchangeable. You should be able to answer any exercise with it. Good luck.
Also, I recommend downloading Dr. Racket as your interpreter.

ERROR: sllgen:make-rep-loop: unbound identifier in module in: sllgen:make-rep-loop

(define read-eval-print (sllgen:make-rep-loop "--> "
(lambda (pgm) (eval-program pgm))
(sllgen:make-stream-parser
the-lexical-spec
the-grammar)))
Is anyone familiar with this type of error?
Help please.
You need to use the right language. According to the documentation, it looks like you need to start your source file with #lang eopl:
#lang eopl
(define read-eval-print
(sllgen:make-rep-loop
"--> "
(lambda (pgm)
(eval-program pgm))
(sllgen:make-stream-parser
the-lexical-spec
the-grammar)))
Once you do this, of course, you'll start getting some other errors, e.g., that eval-program isn't defined. If you define a dummy one, e.g.,
(define (eval-program pgm)
(values))
You'll then get an error that
sllgen:make-stream-parser: bad scanner specification in: the-lexical-spec
You'll need to replace that lexical specification with an actual specification, and similarly (I expect, though I didn't explore this far) with the-grammar. The documentation linked above might (or might not) help you out with those. It looks like you can get the code for the book that this is based on, Essentials of Programming Languages, from the book's website.
What really looks the most promising, though, are results like
Environment-Passing Interpreters, Programming Language Essentials, 2nd edition, Appendix: The SLLGEN Parsing System (PDF)
SLLGEN tutorial (PDF)
sllgen source (sllgen.scm) (a somewhat older version)
other sources (I found the above just by searching with Google for sslgen)

Little Schemer and Racket

I'm starting to read the Little Schemer and now instead of PLT Scheme we have Racket. I would like to know if Racket is suitable for doing the exercises in the book or do I need to get another true Scheme compiler. Before I forgot to tell you, my OS is Windows x64.
The book, language and paradigm is complex enough, I would love to avoid struggling with a compiler.
DrRacket is the (r)evolution of DrScheme; DrRacket will work perfectly for the exercises in "The Little Schemer". Just don't forget to:
In the Language dialog, choose "Use the language declared in the source"
Write #lang racket at the top of each file you create
Implement the atom? predicate in each file as explained at the very beginning of the book
If you're going to re-implement an existing procedure, do so in a separate tab or window, because trying to rewrite a procedure in the edit window will result in a duplicate definition for identifier error. If necessary, use several files for saving the procedure definitions
You really just need the atom? function. What’s described in the book's preface is essentially:
(define (atom? x)
(and (not (pair? x)) (not (null? x))))
As mentioned, it should satisfy this test:
(atom? '()) ;=> #f
Note that there is also a definition in Racklog that will not satisfy that test.
A more detailed discussion on atom? is here.
Despite the book's suggestion to implement add1 and sub1, Racket does already provide them.
BTW, I use Vim for editing Racket, but a few other editors are capable.
I have had the author of the book as a professor. He now uses Racket himself, but he uses Emacs as a text editor.
Racket/Scheme are interchangeable. You should be able to answer any exercise with it. Good luck.
Also, I recommend downloading Dr. Racket as your interpreter.

racket/base namespace

Anyone know what is included in the racket/base language. I am looking to compare the racket/base namespace definitions with the R7RS draft to get a first hand idea of how divergent Racket is from Scheme.
The difference is going to be huge, just like any other practical Scheme implementation. To give you a rough idea, I see more than 1300 identifiers from racket/base, and racket goes up to over 2000. Also, note that comparing the names is not going to be the whole story -- there are additional differences, like the fact that Racket uses immutable pairs by default, and like the fact that you get guaranteed left-to-right evaluation order.
A quick way to get the lists yourself for the former would be to make sure that XREPL is installed (have your ~/.racketrc file contain (require xrepl)), then start Racket with racket/base as the REPL language, and use the ,ap (apropos) command with no arguments so it shows you all of the bound names:
$ racket -I racket/base
Welcome to Racket v5.2.1.
-> ,ap
To read about the names, you can use the ,doc command, or just use the search box in the docs.
According to The Racket Reference:
Unless otherwise noted, the bindings defined in this manual are exported by the racket/base and racket languages.
Unfortunately that is not terribly helpful since it is a large reference manual. But, since you are comparing R7RS to Racket, it may be useful to just browse through the whole reference to get an idea of what is available.

Guile scheme - quoted period?

What does the following Guile scheme code do?
(eq? y '.)
(cons x '.)
The code is not valid in MzScheme, is there a portable equivalent across scheme implementations?
I am trying to port this code written by someone else. Guile seems to respond to '. with #{.}#, but I'm not sure what it means or how to do this in another scheme.
Okay, it seems that '. is valid syntax for (string->symbol ".") in Guile, whereas MzScheme at least requires |.| for the period as a symbol.
#{.}# is Guile specific way to define the symbol contains some delimiters of Scheme.
http://www.gnu.org/software/guile/manual/html_node/Symbol-Read-Syntax.html
For other Scheme dialect, there should be another way.
I'm surprised any Scheme system will accept a dot symbol at all. My advice is to use another symbol as (I'm sure you're aware) the dot is a shorthand to represent a pair, and even if you can find a Scheme that will take your code you will likely confuse anyone that has the unfortunate task of actually reading your code.

Resources