Re: [racket] Typed racket puzzle (ii)

2011-08-17 Thread Casey Klein
On Wed, Aug 17, 2011 at 9:10 AM, Sam Tobin-Hochstadt wrote: > On Wed, Aug 17, 2011 at 9:42 AM, Norman Gray wrote: >> Don't you mean "C must be a subtype of A", here? > > Yes, definitely.  It's hard to get math right in prose.  :) > Pretty hard to get right in LaTeX too.

Re: [racket] scribble/eval does not preserve syntax-original?

2011-08-17 Thread Casey Klein
Thanks! On Wed, Aug 17, 2011 at 7:23 AM, Matthew Flatt wrote: > This is now fixed. > > At Wed, 17 Aug 2011 05:59:06 -0500, Casey Klein wrote: >> 2011/8/16 Casey Klein : >> > Running this program: >> > >> >  #lang racket/base >> >

Re: [racket] scribble/eval does not preserve syntax-original?

2011-08-17 Thread Casey Klein
2011/8/16 Casey Klein : > Running this program: > >  #lang racket/base > >  (define binder #'x) >  (define bound #'x) > >  (syntax-case (parameterize ([current-namespace (make-base-namespace)]) >                 (expand `(λ (,binder) ,bound))) >    () >

[racket] scribble/eval does not preserve syntax-original?

2011-08-16 Thread Casey Klein
Running this program: #lang racket/base (define binder #'x) (define bound #'x) (syntax-case (parameterize ([current-namespace (make-base-namespace)]) (expand `(λ (,binder) ,bound))) () [(_ (_ (binder) bound)) `([binder ,(syntax-original? #'binder)] [b

Re: [racket] unsyntax in Scribble examples

2011-08-16 Thread Casey Klein
On Tue, Aug 16, 2011 at 9:15 AM, Matthew Flatt wrote: > At Mon, 15 Aug 2011 13:18:07 -0600, Matthew Flatt wrote: >> Forms like `racketblock' and `racketinput' have `RACKETBLOCK' and >> `RACKETINPUT' variants that use `UNSYNTAX' as the escae form, instead, >> but I never got around to `examples', e

[racket] syntax-local-value mystery

2011-08-15 Thread Casey Klein
Could someone explain why the program below raises a syntax error? The error goes away if you make either of the following changes: 1. enable errortrace, or 2. change `syntax' to `quote' in the `expand' argument. #lang racket/load ; Change #1 ;(require errortrace) (module t racket (pro

[racket] unsyntax in Scribble examples

2011-08-15 Thread Casey Klein
Compiling the following Scribble program complains that x is unbound on the last line: #lang scribble/doc @(require scribble/eval) @examples[#:eval (make-base-eval) (define x #'q) #`(a #,x c)] Of course, it is unbound in the expression doing the eval-ing, but that shouldn't

Re: [racket] Problem with macro

2011-08-12 Thread Casey Klein
On Fri, Aug 12, 2011 at 10:44 AM, Danny Yoo wrote: > Kent Dybvig's tutorial on syntax case was helpful for me: > >    http://www.cs.indiana.edu/~dyb/pubs/tr356.pdf > I second that recommendation. It was a huge help to me when learning to write macros in Racket. __

Re: [racket] Problem with macro

2011-08-12 Thread Casey Klein
On Fri, Aug 12, 2011 at 9:22 AM, Neil Van Dyke wrote: > 1. Without trying it, I'm pretty sure this particular syntax transformation > can be done in "syntax-rules", but I'm not certain it can be done using only > the power of "..." in "syntax-rules", without a helper macro.  Your life > might be e

Re: [racket] Problem with macro

2011-08-12 Thread Casey Klein
On Fri, Aug 12, 2011 at 7:39 AM, Robby Findler wrote: > Unfortunately, that position in a 'case' expression is not a place > where macro expansion happens. You can, however, use a 'cond' instead > of 'case'. > But you still can't use a macro like `process-state' to generate an entire `cond' claus

Re: [racket] Problem with macro

2011-08-12 Thread Casey Klein
On Fri, Aug 12, 2011 at 7:26 AM, Jay McCarthy wrote: > 2011/8/11 Racket Noob : >> >> (define-syntax automaton >>   (syntax-rules (: -> END) >>     [(_ init-state >>     (state : transition ...) >>     ...) >> (letrec ([curr-state empty] >>   [state >>    (lambd

Re: [racket] Creating a #lang language, and modifying contract system

2011-08-11 Thread Casey Klein
On Thu, Aug 11, 2011 at 9:03 AM, Robby Findler wrote: > > Matthew recently wrote an excellent note about the interactions with > eval and namespaces and why you should or shouldn't use one and I > would love to be able to provide you with the same, but I don't have > such an essay yet. I'm sorry.

Re: [racket] Sweet expressions; or making it easier to introduce Racket to me and my coworkers :-)

2011-07-26 Thread Casey Klein
On Mon, Jul 25, 2011 at 11:20 PM, David Van Horn wrote: > > Cute!  Thanks for the cool planet package.  Here's a slightly larger example > using Redex, adapted from redex/examples/arithmetic.rkt: > > #lang planet asumu/sweet racket > require rename-in(redex [term quote]) > > define-language lang >

Re: [racket] Redex typesetting

2011-07-05 Thread Casey Klein
Scaling: Use the pict library to scale the result of a non-file call to render-reduction-relation. Here's an example (though there may be a simpler way to get EPS): (require redex redex/examples/r6rs/r6rs file/convertible slideshow/pict) (define (render-reduction-relat

Re: [racket] different text colors in Redex traces nodes?

2011-05-04 Thread Casey Klein
On Wed, May 4, 2011 at 12:25 AM, Stephen Chang wrote: > When using Redex, for the traces nodes, is there any way to specify > how to color the text in each node? For example, I want to be able to > quickly identify the redex in each step by giving it a different > color. I looked in the docs and i

Re: [racket] in-line documentation program? Like Javadoc or Doxygen

2011-04-05 Thread Casey Klein
On Tue, Apr 5, 2011 at 4:54 PM, Charles Hixson wrote: > When it comes to Scheme/Lisp I'm nearly a total newbie.  So that page didn't > mean anything to me.  Perhaps some examples would have made it clear what it > was talking about, but also perhaps not.  (I *really* didn't understand it.) > Here

Re: [racket] exn:fail:contract:variable id field

2011-04-01 Thread Casey Klein
On Fri, Apr 1, 2011 at 7:45 AM, Matthew Flatt wrote: > At Fri, 1 Apr 2011 04:10:19 -0500, Casey Klein wrote: >> What exactly is in the `id' field of a `exn:fail:contract:variable' >> structure? It doesn't seem to be the symbolic name of the >> not-yet-defined

[racket] exn:fail:contract:variable id field

2011-04-01 Thread Casey Klein
What exactly is in the `id' field of a `exn:fail:contract:variable' structure? It doesn't seem to be the symbolic name of the not-yet-defined variable. #lang racket (define-syntax (m stx) (syntax-case stx () [(_ x) (let ([y (datum->syntax #'fresh (syntax-e #'x) #'x)]) #`(begin

Re: [racket] call-with-composable-continuation vs. call/cc

2011-03-25 Thread Casey Klein
On Sun, Mar 20, 2011 at 4:58 PM, Gregory Woodhouse wrote: > If I write a trivial loop using call/cc > > (call/cc >  (lambda (k) >   (define (loop) >     (let ([x (read)]) >       (if (eq? x '()) >           (k x) >           (loop >   (loop))) > > It does exactly what I expect. If I type anyth

Re: [racket] Keyboard input in DrRacket

2011-03-18 Thread Casey Klein
On Fri, Mar 18, 2011 at 7:11 AM, Robby Findler wrote: > On Fri, Mar 18, 2011 at 6:46 AM, Pierpaolo Bernardi > wrote: >> Could \tilde be added to the list of keyboard macros recognized by M-\ ? > > It is called \sim. > But \sim + M-\ does not produce the same character that ~ produces on my keyb

Re: [racket] Lazy take is the identity?

2011-01-26 Thread Casey Klein
On Wed, Jan 26, 2011 at 1:41 PM, John Clements wrote: > > On Jan 26, 2011, at 4:29 AM, Casey Klein wrote: > >> On Wed, Jan 26, 2011 at 1:27 AM, John Clements >> wrote: >>> I would expect this program to signal an error: >>> >>> #lang lazy >&

Re: [racket] Lazy take is the identity?

2011-01-26 Thread Casey Klein
On Wed, Jan 26, 2011 at 1:27 AM, John Clements wrote: > I would expect this program to signal an error: > > #lang lazy > > (define zeros (cons 0 zeros)) > > (define should-be-error (list-ref (take 15 zeros) 1324)) > > > ... but instead should-be-error is bound to zero.  How can I take the 1000th

Re: [racket] Question about Moby

2011-01-25 Thread Casey Klein
On Tue, Jan 25, 2011 at 1:35 PM, Mark Engelberg wrote: > This program: > > #lang racket > (require (planet dyoo/moby:3:9)) > > gives me this error: > >  ..\..\Documents and Settings\Mark\Application > Data\Racket\planet\300\5.0.2\cache\dyoo\js-vm.plt\1\12\private\translate-bytecode-structs.rkt:25:

Re: [racket] Confusing behavior with continuation-marks

2011-01-15 Thread Casey Klein
On Sat, Jan 15, 2011 at 12:49 AM, Eric Dobson wrote: > I was looking at the documentation on how continuation-marks work, and > the documented behavior is different than what I observed. > > The following programs add a continuation mark, then a prompt, then > try to look at the current continuati

Re: [racket] raise vs abort

2011-01-06 Thread Casey Klein
On Thu, Jan 6, 2011 at 11:14 AM, Keiko Nakata wrote: > So, I fall back into the same question of why 'raise' has to be a primitive, > given My totally uninformed guess is that it's because there are C-implemented primitives that need to raise exceptions, and it's easier for those primitives to ca

Re: [racket] raise vs abort

2011-01-06 Thread Casey Klein
On Thu, Jan 6, 2011 at 10:08 AM, Keiko Nakata wrote: > On Thu, Jan 6, 2011 at 3:20 PM, Casey Klein > wrote: >> > Still I am not certain that this behavior of 'raise' cannot be implemented >> > by other (delimited) control operators. And, probably I do not sti

Re: [racket] raise vs abort

2011-01-06 Thread Casey Klein
On Thu, Jan 6, 2011 at 10:15 AM, Robby Findler wrote: > On Thu, Jan 6, 2011 at 10:11 AM, Keiko Nakata > wrote: >> On Thu, Jan 6, 2011 at 3:29 PM, Robby Findler >> wrote: >> >>> If you wanted to try, I'd suggest adapting the redex model and then >>> using random testing to try to find the differ

Re: [racket] raise vs abort

2011-01-06 Thread Casey Klein
On Thu, Jan 6, 2011 at 7:18 AM, Keiko Nakata wrote: >> I'm not completely clear, but I think the only point is that 'raise' >> does not, in general, actually abort. It calls a handler that makes >> the decision to abort or not. When aborting actually happens, however, >> abort is what does the abo

Re: [racket] raise vs abort

2011-01-06 Thread Casey Klein
On Thu, Jan 6, 2011 at 6:32 AM, Keiko Nakata wrote: >> I don't think you could rebuild the >> missing portion of the continuation by reinstalling it before calling >> the exception handler due to dynamic-wind frames, which could notice >> the exit and re-entry, and continuation barriers, which cou

Re: [racket] continuation barrier in raise

2011-01-05 Thread Casey Klein
On Wed, Jan 5, 2011 at 8:55 AM, Keiko Nakata wrote: >> A `with-handlers' handler and a `call-with-exception-handler' handler >> are invoked with different continuations. A `with-handlers' handler is >> invoked with the continuation of the entire `with-handlers' >> expression; a `call-with-exceptio

Re: [racket] raise vs abort

2011-01-05 Thread Casey Klein
On Wed, Jan 5, 2011 at 8:22 AM, Keiko Nakata wrote: >> raise just calls a handler that is the one that does the interesting >> control. > > So having separate implementations is for optimization? > I don't think `raise' can be defined via `abort'. `raise' calls the exception handler in the curren

Re: [racket] continuation barrier in raise

2011-01-05 Thread Casey Klein
On Wed, Jan 5, 2011 at 7:40 AM, Keiko Nakata wrote: > Thanks for the code. > > I'm a bit confused as replacing 'call-with-exception-handler' by > 'with-handlers' seem to not produce the same bahavior: > > (call-with-continuation-prompt >  (lambda () >  (with-handlers >   ([(lambda (_) true) (lambd

Re: [racket] continuation barrier in raise

2011-01-05 Thread Casey Klein
On Wed, Jan 5, 2011 at 6:32 AM, Keiko Nakata wrote: > Hello, > > Will someone give me an example which shows the continuation barrier > introduced by 'raise'?  I.e., I want an program which raises an exception > because of the barrier. > > I think I do not understand the documentation properly, >

Re: [racket] Quick question - use of ". -> ." synatx

2010-12-25 Thread Casey Klein
On Sat, Dec 25, 2010 at 1:48 AM, Scott McLoughlin wrote: > Couldn't find docs on this syntax form using regular > docs search. > I don't know how to find it with search either, but here it is. http://docs.racket-lang.org/reference/reader.html#%28part._parse-pair%29 "If the reader finds three or

Re: [racket] DrRacket indent of "let:"

2010-12-24 Thread Casey Klein
On Fri, Dec 24, 2010 at 2:56 PM, Neil Van Dyke wrote: > Casey Klein wrote at 12/24/2010 03:42 PM: >> >> Adding `let:' to the list of "Lambda-like Keywords" in DrRacket's >> "Editing" preferences makes your first two examples indent as in

Re: [racket] DrRacket indent of "let:"

2010-12-24 Thread Casey Klein
On Wed, Dec 22, 2010 at 6:28 PM, Neil Van Dyke wrote: > DrRacket 5.0.2 isn't indenting Typed Racket "let:" forms idiomatically.  It > indents them in the default way rather than a special way like it does for > Racket "let" forms. > > In case anyone wants to fix this, here's how Quack currently in

[racket] syntax-parse error reporting for ...+ patterns

2010-11-01 Thread Casey Klein
I'd like to rework Redex's `define-language' form to use syntax-parse, but I'm having trouble getting the error message I want. Here's the best I've been able to do (for a simplification of `define-language'): (define-syntax (define-language stx) (syntax-parse stx [(_ lang:id (nt:id (~descr

Re: [racket] what is this thing: '#(struct:foo 3 4) ?

2010-09-10 Thread Casey Klein
On Fri, Sep 10, 2010 at 11:40 AM, John Clements wrote: > > On Sep 10, 2010, at 9:34 AM, Matthew Flatt wrote: > >> At Fri, 10 Sep 2010 09:21:28 -0700, John Clements wrote: >>> I've spent long enough with the docs on this not to feel too embarrassed >>> about >>> this question: what kind of value i

Re: [racket] [redex] define list for metafunctions

2010-09-09 Thread Casey Klein
On Wed, Sep 8, 2010 at 10:36 AM, Eric Tanter wrote: > Hi, > > Is there a way to have the (define ...) dropdown button be customized for > define-metafunction, so that it displays the name of the metafunction instead > of just showing the language name? > The dropdown menu assumes that the first

Re: [racket] [redex] Structured Semantics

2010-07-07 Thread Casey Klein
On Wed, Jul 7, 2010 at 10:53 PM, Jay McCarthy wrote: > How should I use Redex to encode a structured semantics... For example, > > Suppose I have the L_thread language and the ->_thread reduction > relation with contract > > (store_global store_local term) ->_thread (store_global store_local term)

Re: [racket] [plt-scheme] [redex] matching question

2010-06-22 Thread Casey Klein
On Fri, Jun 4, 2010 at 1:48 PM, Casey Klein wrote: > On Fri, Jun 4, 2010 at 1:14 PM, Eric Tanter wrote: >> Hi, >> >> I have a subtype? metafunction where one clause is as follows: >> >> ((subtype? C_0 C_1 CT) >>   #t >>   (side-condition (not (equal?