Joop Ringelberg | 1 Jun 2012 09:39
Picon
Gravatar

Re: eval in a module language

Matthias,

I apologise for the incomplete example.
And I apologise, too, for the email: it turns out to be a false alarm.
On stripping my module language file to make a small and complete example I noticed that I had included a syntax-rule for the bigloo module expression keyword "eval" - effectively ignoring it which of course explains what happens.
Thank you.
Joop


On Thu, May 31, 2012 at 11:34 PM, Matthias Felleisen <matthias-/kfV3HKrsts@public.gmane.org.edu> wrote:

On May 31, 2012, at 3:36 PM, Joop Ringelberg wrote:

>
> (define-namespace-anchor a)
> (define ns (namespace-anchor->namespace a))
> (eval (x 1) ns)
>
> I get the message:
> procedure application: expected procedure, given: #<void>;
>


This is not enough code. What is x? Do you mean '(x 1)? -- Matthias




--
06 26 148 310
Postbus 126
6950 AC Dieren

Parkweg 27, 
6994 CM De Steeg



____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Neil Toronto | 1 Jun 2012 20:01
Picon
Gravatar

Re: Plot woes

On 05/30/2012 11:12 AM, Jens Axel Søgaard wrote:
> Hi All,
>
> Attached is my version of a 2d-plotter that handles singularities.
> Give it a spin with your favorite ill-behaved functions and
> report back with ones badly handled.

For approaches like this, I think the definition of "well-behaved" is 
"locally Lipschitz continuous with Lipschitz constant < K", where K 
depends on the constants used to detect discontinuities (e.g. 
machine-epsilon, number-of-regions). For everywhere-differentiable 
functions, K is the maximum absolute derivative on the domain plotted, 
scaled by various plot- and detection-specific factors.

(Yes, "Lipschitz" is like, the most unfortunate name for a mathematical 
property EVER. It takes undergraduate math majors a whole semester to 
get over it, if they ever do.)

Knowing that, it doesn't take long to find an ill-behaved function. We 
just need one that's differentiable but not locally Lipschitz:

     (λ (x) (* (expt (abs x) 3/2) (sin (/ x))))

Things like this will always be ill-behaved when plotted on some domain, 
no matter how fine the discontinuity detection is.

Further, there are locally and globally Lipschitz functions whose K is 
too large. (I didn't spend time finding one, though.) For each one, some 
constant assignment in the discontinuity detection will make them plot 
nicely. But for any constant assignment, there are infinitely many of them.

</analysis_lesson>

That doesn't mean I won't try something like this. The definition of 
"functions without discontinuities that are well-behaved when plotted 
non-adaptively" is also "locally Lipschitz continuous with Lipschitz 
constant < K", where K depends on different constants like the 
discretization step size. I would be perfectly happy with an adaptive 
sampler or just discontinuity detection if I could show that its set of 
ill-behaved functions is no larger than those for the current sampler. 
That'll take some time.

Also, I'm still considering letting users specify discontinuities. That 
would allow them to tell plot what kind they are: removable, removable 
singularity, right-step, left-step, etc. Those kinds of properties are 
pretty much undetectable.

Neil ⊥
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Jon Rafkind | 1 Jun 2012 20:16
Picon
Favicon

quote-syntax in macro-generator

Today's macro PSA is about macro-generating-macro forms. If you use a macro to generate a transformer then you must be careful about nesting `syntax' forms otherwise you will interpolate templates too many times. Specifically #'#'x will interpolate x twice. Given the following bindings: chicken = (syntax (egg ...)) pattern = (syntax chicken) The problem is if an additional `syntax' is wrapped around `pattern'. After one interpolation of `syntax' we will have (syntax (egg ...)) At which point `egg' had better be bound as a pattern variable otherwise interpolation will fail. To work around this problem the `quote-syntax' form should be used: #'(quote-syntax pattern) which prevents the (syntax (egg ...)) layer from being interpolated because `quote-syntax' does not do interpolation. The following example demonstrates the issue. On the line 'HERE' the inner syntax should be `quote-syntax' otherwise the following error is produced x.rkt:27:24: syntax: no pattern variables before ellipses in template at: ... in: (_ x ...) To be fair this issue only comes up because I used `make-transformer' in the body of a phase 2 function so the output of `make-transformer' had to have two levels of syntax, because its a macro that should ultimately evaluate to a syntax form. A simpler solution would have been to do #'(define-syntax name (make-transformer pattern action)) So that `make-transformer' only had to return one level of syntax. But anyway I got into this situation for other reasons. #lang racket (require (for-meta 0 racket/splicing) (for-meta 1 syntax/parse) (for-meta 2 syntax/parse racket/base)) (begin-for-syntax (define-syntax (make-transformer stx) (syntax-parse stx [(_ (pattern ...) action) #'#'(lambda (stx) ;; HERE change to #'(quote-syntax (syntax-parse stx [(_ pattern ...) action]))]))) (define-syntax (macro-generator stx) (syntax-parse stx [(_ name pattern action) #'(splicing-let-syntax ([make (lambda (stx) (syntax-parse stx [(_ name) (with-syntax ([transformer (make-transformer pattern action)]) #'(define-syntax name transformer))]))]) (make name))])) (macro-generator foo (x ...) #'(list x ...)) (foo 1 2 3)
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Jay McCarthy | 2 Jun 2012 01:44
Picon
Gravatar

Re: xml/plist plist-dict

I just pushed the alist version

Jay

On Thu, May 31, 2012 at 3:52 PM, Steve Byan <stevebyan <at> verizon.net> wrote:
>
> On May 31, 2012, at 5:27 PM, Jay McCarthy wrote:
>
>> Tell me if this works well and I'll commit it:
>>
>> https://github.com/jeapostrophe/exp/blob/master/plist-dict.rkt
>
> Thanks, I'll give it a try.
>
>> One problem could be that it doesn't preserve the order of the
>> original plist dict entries. I could switch it to use an alist and the
>> dict interface, if that IS a problem.
>
> I believe plists are supposed to be order-independent, but I'm worried about triggering latent bugs if I
switch the order. (Especially so because I'm mucking with my mailer.) I hate to impose but an alist
implementation would let me sleep easier. Maybe I can fake one myself after I look at your code.
>
> Best regards,
> -Steve
>
> --
> Steve Byan <stevebyan <at> me.com>
> Littleton, MA 01460
>
>
>
>
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

--

-- 
Jay McCarthy <jay <at> cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Harry Spier | 2 Jun 2012 04:12
Picon

Debugging multiple modules in DrRacket

I have a main module which requires other modules.  I'm trying to
debug one of those modules using the debugger in DrRacket. (I'm using
windows Vista and the latest Racket.

  I open two tabs in DrRacket, one with the main module and one with
the module I'm trying to debug (lets call it M).  I click the debug
icon in the main module and set a breakpoint just before the call to
the procedure in module M.  I then step through the call to this
procedure and the second tab opens with module M but there are no
debug icons available and I can't step through module M.

I then tried first opening the tab with module M and clicking on the
debug icon and then opening the tab with the main module and clicking
on debug and setting the breakpoint etc.  but when I stepped into
module M, the debug icons were available but appeared to be disabled
(i.e. lighter color and didn't respond to clicking).

Section 1.8.4 for DrRacket says:
------------------------------------
1.8.4 Debugging Multiple Files

To debug a program that spans several files, make sure that all of the
files are open in DrRacket. Click the Debug button in the window
containing the main program. As this program loads additional files
that are present in other windows or tabs, message boxes will pop up
asking whether or not to include the file in the debugging session.
Including the file means that it will be possible to set breakpoints,
inspect variables, and single-step in that file.
-------------------------------------

But no message boxes popped up asking me whether I want to include
files in the debugging session..

In the Choose Language menu I have "Debugging" chosen under dynamic properties.

Can anyone suggest what might be the problem.

Thanks,
Harry
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Jon Rafkind | 2 Jun 2012 06:29
Picon
Favicon

Re: quote-syntax in macro-generator

Another thing about this, if the definition produced by the macro is instead generated by the `make-transformer' macro then it will have the wrong number of marks on it when everything is finally expanded. `syntax-local-introduce' fixes this by essentially removing that extra mark.

#lang racket (require (for-meta 0 racket/splicing) (for-meta 1 syntax/parse) (for-meta 2 syntax/parse racket/base)) (begin-for-syntax (define-syntax (make-transformer stx) (syntax-parse stx [(_ name (pattern ...) action) #'(quote-syntax (define-syntax name (lambda (stx) ;; HERE change to #'(quote-syntax (syntax-parse stx [(_ pattern ...) action]))))]))) (define-syntax (macro-generator stx) (syntax-parse stx [(_ name pattern action) #'(splicing-let-syntax ([make (lambda (stx) (syntax-parse stx [(_) (syntax-local-introduce (make-transformer name pattern action))]))]) (make))])) (macro-generator foo (x ...) #'(list x ...)) (foo 1 2 3)
The `name' passed as an argument to `make-transformer' will not have the mark applied to it by the transformer in the splicing-let-syntax, so the resulting define-syntax form will use a different 'foo' from the one passed to `macro-generator'. Using `syntax-local-introduce' applies the mark that was used when `(make)' was expanded thus removing all marks from the final expansion.

On 06/01/2012 12:16 PM, Jon Rafkind wrote:
Today's macro PSA is about macro-generating-macro forms. If you use a macro to generate a transformer then you must be careful about nesting `syntax' forms otherwise you will interpolate templates too many times. Specifically #'#'x will interpolate x twice. Given the following bindings: chicken = (syntax (egg ...)) pattern = (syntax chicken) The problem is if an additional `syntax' is wrapped around `pattern'. After one interpolation of `syntax' we will have (syntax (egg ...)) At which point `egg' had better be bound as a pattern variable otherwise interpolation will fail. To work around this problem the `quote-syntax' form should be used: #'(quote-syntax pattern) which prevents the (syntax (egg ...)) layer from being interpolated because `quote-syntax' does not do interpolation. The following example demonstrates the issue. On the line 'HERE' the inner syntax should be `quote-syntax' otherwise the following error is produced x.rkt:27:24: syntax: no pattern variables before ellipses in template at: ... in: (_ x ...) To be fair this issue only comes up because I used `make-transformer' in the body of a phase 2 function so the output of `make-transformer' had to have two levels of syntax, because its a macro that should ultimately evaluate to a syntax form. A simpler solution would have been to do #'(define-syntax name (make-transformer pattern action)) So that `make-transformer' only had to return one level of syntax. But anyway I got into this situation for other reasons. #lang racket (require (for-meta 0 racket/splicing) (for-meta 1 syntax/parse) (for-meta 2 syntax/parse racket/base)) (begin-for-syntax (define-syntax (make-transformer stx) (syntax-parse stx [(_ (pattern ...) action) #'#'(lambda (stx) ;; HERE change to #'(quote-syntax (syntax-parse stx [(_ pattern ...) action]))]))) (define-syntax (macro-generator stx) (syntax-parse stx [(_ name pattern action) #'(splicing-let-syntax ([make (lambda (stx) (syntax-parse stx [(_ name) (with-syntax ([transformer (make-transformer pattern action)]) #'(define-syntax name transformer))]))]) (make name))])) (macro-generator foo (x ...) #'(list x ...)) (foo 1 2 3)

____________________ Racket Users list: http://lists.racket-lang.org/users

____________________
  Racket Users list:
  http://lists.racket-lang.org/users
curtis wolterding | 2 Jun 2012 16:32
Picon

Articles or discussions on Racket's implementation

Hello Racketeers,

A friend and I recently finished working through this book together, The Elements of Computing Systems - http://www1.idc.ac.il/tecs/, where we built a computer (virtually) from the ground up: from NAND gates, to a (barely) working compiler and a very basic OS. After finishing all of the projects, and after having a month or so now to recover from the stress and pure insanity, I can't stop thinking about how fun it would be to learn about the implementation of Scheme, or, more specifically, Racket! Does anyone know where I could find a good discussion or explanation of the inner workings of either of these languages?

I apologize if this is an off-topic question for the mailing list.

Also, I want to sincerely thank the Racket Devs for creating such a well documented, and user-friendly project. Other than completing about half of HTDP (I'm planning on finishing the rest this summer!), and a very introductory C++ class many years ago in college, the Elements book was really my first introduction to computing. Having coded the assembler, VM, and compiler for the book in Racket, I have basically lived on the Racket docs pages for the last three quarters of a year. It's been an amazing journey, and I honestly could not have completed everything had Racket not come with such excellent documentation, such an easy to use IDE, or had it not been such a joy to code in. On behalf of a true beginner, thank you.

Cheers,

Curtis Wolterding

____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Neil Van Dyke | 2 Jun 2012 16:39
Picon
Favicon

Re: Articles or discussions on Racket's implementation

curtis wolterding wrote at 06/02/2012 10:32 AM:
> I can't stop thinking about how fun it would be to learn about the 
> implementation of Scheme, or, more specifically, Racket! Does anyone 
> know where I could find a good discussion or explanation of the inner 
> workings of either of these languages?

Have you seen the PLAI book, written by a Racket person (Shriram)? 
  http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/

Neil V.

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

curtis wolterding | 2 Jun 2012 16:43
Picon

Re: Articles or discussions on Racket's implementation



On Sat, Jun 2, 2012 at 10:39 AM, Neil Van Dyke <neil-iSOEUaFOKGKgBLj5vKMu3A@public.gmane.org> wrote:
curtis wolterding wrote at 06/02/2012 10:32 AM:

I can't stop thinking about how fun it would be to learn about the implementation of Scheme, or, more specifically, Racket! Does anyone know where I could find a good discussion or explanation of the inner workings of either of these languages?

Have you seen the PLAI book, written by a Racket person (Shriram)?  http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/

Neil V.


I will add it to my reading list. Thanks!
____________________
  Racket Users list:
  http://lists.racket-lang.org/users
Matthias Felleisen | 2 Jun 2012 16:57
Favicon

Re: Articles or discussions on Racket's implementation


On Jun 2, 2012, at 10:32 AM, curtis wolterding wrote:

> A friend and I recently finished working through this book together, The Elements of Computing Systems
-http://www1.idc.ac.il/tecs/, where we built a computer (virtually) from the ground up: from NAND
gates, to a (barely) working compiler and a very basic OS. 

Sorry for an off-topic reply, but this sentence reminded me of Dijkstra's quote that the name "computer
science" applied to astronomy would translate as "telescope science" and biologists should probably be
called "microscope scientists". Otherwise I will say that you deserve a badge of honor for completing the
above. 

HtDP's full philosophy is the exact opposite. Introduce the systematic design of software as the primary
idea of our discipline and the derivation of a machine, including assembler and friends, as the other
constraint-inducing end of it. These last few lectures are a part of the original course, including the
machine and the loader-linker-assembler, but they didn't make it into the book. 

For the basics of constructing a Racket interpreter, PLAI is the best starting point. It is inspired by
Essentials of Programming Languages (Friedman and Wand). To understand the actual implementation,
however, you will need to check out material about (jit) compilers once you're through those. The list
will help you

-- Matthias

____________________
  Racket Users list:
  http://lists.racket-lang.org/users


Gmane