Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2016-01-05 Thread Matthias Felleisen
> On Dec 22, 2015, at 8:46 AM, Matthew Flatt wrote: > > I think Robby was just confused by your example, because he's used to > starting with a fresh REPL. :) When Dan F. and I worked on TLL/3 way back in the 80s together, we confused ourselves several times with just HO functions and some au

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-22 Thread Leif Andersen
Okay, thank you for the explanation. I totally see what you mean now by the top level being hopeless. (Or at least I think I do.) It seems there is no way to get a meaning that does everything we would want it to... As a side not Matthew, I notice that you seem to be sending out two identical em

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-22 Thread Robby Findler
Oh right. Sorry for the confusion! Robby On Tuesday, December 22, 2015, Matthew Flatt wrote: > I think Robby was confused by your example (which is understandable). > > The `expand` function does not splice any differently than `compile`, > so `compile` behaves the same as `expand` in your exam

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-22 Thread Matthew Flatt
I think Robby was confused by your example (which is understandable). The `expand` function does not splice any differently than `compile`, so `compile` behaves the same as `expand` in your example: > (eval (compile #'(begin (define-syntax (foo stx) (displa

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-22 Thread Matthew Flatt
Expanding a form triggers compile-time evaluation in the sense of running macros. Currently, though, compilation treats changing the set of bindings at the top level as a kind of run-time effect (to be avoided at compile time). For example, compiling `(define x 5)` does not change the current bind

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-22 Thread Matthew Flatt
At Mon, 21 Dec 2015 21:30:45 -0700, Leif Andersen wrote: > Ah, that's a good question. One that I don't really know the answer > too, because when I do: > > > (compile #'(begin >(define-syntax (foo stx) > (displayln "hello") > #'5) >

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-21 Thread Leif Andersen
Wait, now I'm even more confused. If expand does the splicing and compile time evals song and dance, why do we need a separate function for: expand-syntax-top-level-with-compile-time-evals ? ~Leif Andersen On Mon, Dec 21, 2015 at 9:48 PM, Robby Findler wrote: > I believe that's because expand

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-21 Thread Robby Findler
I believe that's because expand does the splicing dance, but compile doesn't (which is why you need the funny-named function ... "need" is perhaps a poor choice of words here :). Robby On Mon, Dec 21, 2015 at 10:30 PM, Leif Andersen wrote: > Ah, that's a good question. One that I don't really k

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-21 Thread Leif Andersen
Ah, that's a good question. One that I don't really know the answer too, because when I do: > (compile #'(begin (define-syntax (foo stx) (displayln "hello") #'5) foo)) I get back the compiled object. Also foo is not displayed. And wh

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-21 Thread Alex Knauth
> On Dec 21, 2015, at 10:53 PM, Leif Andersen wrote: > But `compile` is not supposed to evaluate any code, it just compiles > it. Which is why it fails to compile that code. But if you interleave > it with evals, it will run the require code, which gives the phase > level 2 code some meaning. I

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-21 Thread Leif Andersen
So, the way I understand it (and please correct me if I'm wrong), is that require is a macro for #%require, which is converted by the compiler to either a top level require form, or part of the module's require field. (Depending on where it goes). When you put a `begin-for-syntax` or a `define-syn

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-21 Thread Alex Knauth
I get that `compile` doesn't evaluate the require form, but why doesn't it evaluate what's needed for compile time? I thought that was the reason for needing require as a macro instead of a function. Or am I getting the purpose of compile wrong? Alex Knauth > On Dec 21, 2015, at 7:47 PM, Matth

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-21 Thread Leif Andersen
Ah, okay, that makes sense. Thank you. I didn't realize begin was evaluating each expression as it went. Thank you. ~Leif Andersen On Mon, Dec 21, 2015 at 5:47 PM, Matthew Flatt wrote: > In the REPL, `begin` splices at the granularity of expansion and > evaluation. That is, the first of the tw

Re: [racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-21 Thread Matthew Flatt
In the REPL, `begin` splices at the granularity of expansion and evaluation. That is, the first of the two forms grouped by `begin` is compiled and evaluated, and only afterward the second one is compiled and evaluated. The `compile` function can't do that, because it's only supposed to compile --

[racket-users] Confused about the difference between the REPL and the toplevel.

2015-12-21 Thread Leif Andersen
So, I was under the impression that the REPL was the toplevel (unless you entered a module context or something like that). But I just had something challenge that assumption and so now I'm a bit confused. I have the following top level program: (begin (require (for-meta 1 racket)