These questions were asked on in-class quizzes, or on the Assignment 0 hand-in sheet.
Course Policies | How do I know when I am required to bring my computer to class? | Almost never! I'll let you know in advance if you need it. |
Scheme | What is the difference between let and define? | Define binds a value to a variable in the global environment. Let binds a value to a variable in the local environment in which the body of the let will be executed. Scheme always looks for values in the local environment (roughly the same as local scope) first, then in the global environment. |
Scheme | What is an example of a first class data type? | In Java: Every primitive type and object type In Scheme: Every type (including procedure and continuation) In Java, the expression a instanceof Method makes no sense.In Scheme, the expression (procedure? a) makes sense and is legal. |
Scheme | Is there a simple way to accept user input dynamically in a Scheme program? | The main procedures you need to know are read and read-char. I
show them here with no arguments. They can also be called with an
input-port as their argument (an input-port can be created by calling
open-input-file ). A simple example: (display "enter a Scheme expression: ") (define x (read)) (display (cons x x)) (newline) (define junk (read-char)) ;; skip the new-line from the input (display "enter three characters: ") (define c (read-char)) (display c) (newline) (set! c (read-char)) (display c) (newline) (set! c (read-char)) (display c) (newline)And a sample run of this code (user inputs are shown in bold): enter a Scheme expression: (x y z) ((x y z) x y z) enter three characters: abc a b c |
Scheme | If a function is created without giving it a name, is it released from memory immediately after execution, or does a garbage collector reclaim it later? | Procedures, like all other non-primitive data. live in the heap. The garbage collector "patrols" the heap looking for unused memory it can recycle. |
Scheme | Can you trace functions that use lambda? Like makeAddr:
(define makeAddr
(lambda (n) (lambda (m) (+ m n)))) |
Chez Scheme has trace-lambda, trace-let, trace-define. http://scheme.com/csug8/debug.html#./debug:s0 |
Scheme |
Can you overwrite lambda? Like (define (lambda n) (* n n)) |
Yes. But you probably would not want to do this! |
Scheme |
What is Scheme used for in present day technology? |
Scheme and its cousin Common Lisp are frequently use in AI
applications. The example I am most familiar with is Beckman Coulter in Indianapolis, where they use Scheme for the real-time scheduling engine in their robotics software. They wrote some nifty code to allow Scheme and the .NET CLR to talk to each other. They have also implemented Erlang in Scheme so they can do concurrency cleanly. Cisco wanted Scheme technology badly enough that they hired Kent Dybvig, purveyor of Chez Scheme, away form Indiana University, and bought the rights to future Chez Scheme development. Perhaps more relevant now is how Scheme will be used in this course. Not as an end in itself, but as a platform for exploring various language concepts. |
Scheme | What use is creating a procedure in a procedure? Is there a reason to use lambda outside of define? If not, why is it necessary? Why would I ever create a procedure and not give it a name? Procedures maybe useful later on in the program. What is the advantage of using lambda over how most other languages define functions? |
Stay tuned. You'll see lots of examples in the next few weeks. |
Scheme | Can you specify what data type you want to use? I understand that you don’t normally, but there could be cases where you wanted to. | Not in Standard scheme. Several people have written extensions of Scheme that allow or require type specification or inference. For example, http://www.ccs.neu.edu/racket/pubs/popl08-thf.pdf |
Style | Which do you prefer: (define a '(1 2 3)) or (define b (list 1 2 3))? |
It doesn't really matter, but I have a slight preference for the first one. It is shorter and more readable. |
Emacs | Does Emacs give you a big advantage, especially considering that it is hard to learn? | You'll have to decide this. I will show some of the nice features during live coding sessions in the classroom, and you can decide whether it is worth climbing Emacs's steep learning curve in order to get to use its Scheme-specific features. |
PL Concepts | Currying? | Changing the interface of a multiple-argument function so it takes one argument at a time. It's sort of an example of the Adapter pattern (Weiss, Section 4.6.3). |
PL Concepts | What is lambda calculus used for outside of programming languages? | Lambda calculus (http://en.wikipedia.org/wiki/Lambda_calculus
)was invented in the 1930's before there were any programming languages.
It is used as a representation of computation. The untyped lambda-calculus is Turing Complete (http://en.wikipedia.org/wiki/Turing_complete). You can find a lot more info (pretty theoretical) in the articles I referenced here. Here is a reference on an astronomy page: http://www.absoluteastronomy.com/topics/Lambda_calculus |
Miscellaneous | What is emacs? | Emacs is a "smart" programmable text editor. Many people would say that it is the best text editor.(I have my flame shield up!) It has been around for about 35 years and is available for almost all operating systems. Things I like about include the ease of customizing it (via code or keyboard macros) and its excellent interaction with Scheme. Before Eclipse came along, I also used it for Java development. |
Miscellaneous |
Is it possible to create an executable with Maple? |
I doubt it. Such an executable would have to include the Maple run-time system, and I doubt that the folks at MapleSoft would allow that. |
Lexical scoping | What is lexical scoping | http://whatis.techtarget.com/definition/lexical-scoping-static-scoping |
lists | How exactly are internal list structures formed? | They are plain vanilla linked lists, such as you saw in CSSE 220 |
Not answered yet. I will answer these as I find time to do so. |
|
|