Alexis King | 31 Aug 00:31 2015
Picon

Creating a language that extends typed/racket

(Disclaimer: I think this question may have been visited before on this mailing list, but I couldn’t find
any resolution, so I’m going to ask again.)

I would like to write a language that extends typed/racket or typed/racket/base. Specifically, I have a
collection, called “envy”. I would like to create a `#lang envy` that is just like #lang
typed/racket/base, but also includes (all-from-out envy). My first instinct was just to create a
language using syntax/module-reader, along with a simple module language:

   #lang typed/racket/base
   (require envy)
   (provide (all-from-out envy typed/racket/base))

Unfortunately, this doesn’t work. The `envy` module defines a macro called `define-environment`, but
attempting to use it in this `#lang envy` fails:

   Type Checker: Macro define-environment from typed module used in untyped code in: (define-environment)

So that doesn’t work. For some reason, the typechecker thinks `#lang envy` is untyped (though it seems to
typecheck properly when not using macros). However, I realized that `#lang typed/racket` is a module
language that obviously extends typed/racket/base. It uses typed-racket/minimal, but using that
instead of typed/racket/base didn’t alleviate my problem.

Is it possible to create a custom language that extends typed/racket/base? How does typed/racket itself
do it?

Alexis

--

-- 
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe@...
(Continue reading)

Matthew Butterick | 30 Aug 21:04 2015

unclear about this `parameterize` behavior

In the example below, I'm curious about the reason for the difference between the behavior of the system
parameter `error-print-width` and the custom parameter `my-param`. 

I understand why `my-param` doesn't take the parameterized value 'custom (= because
`namespace-require` causes a fresh instantiation of "param.rkt" in the new namespace, which binds
`my-param` with its default value). 

But if that's the case, then why does `error-print-width` accept the parameterized value? Why doesn't it
get instantiated at its default value of 250 when the new namespace is made?

;; param.rkt
#lang racket
(provide my-param)
(define my-param (make-parameter 'default))

;; param-test.rkt
#lang racket
(require "param.rkt")
(parameterize ([current-namespace (make-base-namespace)]
               [error-print-width 4242]
               [my-param 'custom])
  (namespace-require "param.rkt")
  (namespace-require 'rackunit)
  (eval '(begin (check-equal? (error-print-width) 4242) ;; not 250
                (check-equal? (my-param) 'default)))) 

--

-- 
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.
(Continue reading)

Marduk Bolaños | 28 Aug 22:06 2015
Picon

Question about log-ticks

Dear all,

I did a scatter plot with a logarithmic Y-axis. It looks fine but there
is something that really bugs me: there are no minor ticks between the
X-axis and the first major tick.

Here is the code:

#lang racket

(require plot)

(parameterize ([plot-y-transform log-transform]
               [plot-y-ticks (log-ticks #:number 6)])
  (define xs (range 1 11))
  (define ys (map (λ (x) (exp x)) xs))
  (plot (points (map vector xs ys) #:y-min 1)))

I tried different values for #:number to no avail. Is this the intended
functionality?

Best,
Marduk

--

-- 
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.

(Continue reading)

Andrew Kent | 28 Aug 18:44 2015
Picon

side-condition's in PLT Redex... tread carefully

PSA - careful using side-conditions in PLT Redex! (I'd stick to 'where' clauses, personally)

The fact that side-conditions exist in both metafunctions/reduction-relations *and* judgment-forms
but are *not* in fact the same thing (i.e. those found in the former accept racket expressions, the latter
accepts terms) can lead to nasty, subtle little bugs if you're not careful. (yes the difference is
documented, however it's still really easy to hang yourself with them if you forget the subtle
distinction in a sufficiently complicated model, IMHO).

For example, consider a little language which models propositional logic:

(define-language propositional-logic
  [φ ::= variable-not-otherwise-mentioned]
  [Γ ::= (φ ...)])

(define-judgment-form propositional-logic
  #:mode (proves I I)
  #:contract (proves Γ φ)
  ;; ...
  [(side-condition (memq (term φ) (term Γ)))
   -------------------------------- "L-Assumption"
   (proves Γ φ)]
  ;; ...
  )

(test-equal (judgment-holds (proves (P) P)) #t)
(test-equal (judgment-holds (proves (P) Q)) #f) ;; <-- fails test!

Uh oh, why did our second test fail? Ah yes, but of course! We forgot that in a judgment-form, side-condition
will end up quoting Racket expressions (since it accepts terms) and so the condition '(side-condition
(memq (term φ) (term Γ)))' is always true.
(Continue reading)

Antonio Menezes Leitao | 28 Aug 11:55 2015
Picon

Local require for Typed Racket

Hi,

Is there a local-require/typed for Typed Racket that combines Racket's local-require with Typed Racket's require/typed?

At the moment, I'm using a name-mangling approach that works but does not look pretty.

Best,
António.

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Jordan Johnson | 28 Aug 00:52 2015

Frog/Scribble: h* tag substitution

Hi all,

I’m using Greg Hendershott’s Frog[1] tool for my web site, and since I know I’m outputting HTML I
sometimes want to be able to tell Frog/Scribble, “Just use this HTML tag here.” I’ve looked at the
docs on implementing styles[2], and came up with this attempt:

> ;; string? -> (string? ... -> element?)
> (define (tag-function tag-name)
>   (lambda content
>     (keyword-apply elem
>                    '(#:style)
>                    (list (style #f (list (alt-tag tag-name))))
>                    content)))

This worked great for inserting EM and STRONG tags:

>  <at> (define em (tag-function "em”))
> ...
> Here’s something  <at> em{really important}!
> ...

What’s got me baffled is that if I try to access H1..H5 tags this way, other tags get substituted. For example:

>  <at> (define h3 (tag-function "h3”))
> ...
>  <at> h3{Section 2}

renders as

> <h1>Section 2</h1>

So far it’s just the H* tags I’ve found misbehaving.

So, my plea to Greg & other Scribblers: can you give any insight into where the H3 might be getting replaced
with an H1?

Thanks,
Jordan

[1] https://github.com/greghendershott/frog
[2] http://docs.racket-lang.org/scribble/extra-style.html

--

-- 
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.

Jos Koot | 27 Aug 16:53 2015
Picon

namespace-undefine-variable! question

The following works:
 
#lang racket/base
#;1 (define ns (make-base-namespace))
#;2 (namespace-variable-value 'list #t (λ () 'not-found) ns)
; -> #<procedure:print-syntax-width>
#;3 (namespace-set-variable-value! 'list 'whatever (λ () #f) ns)
#;4 (namespace-undefine-variable! 'list ns)
#;5 (namespace-variable-value 'list#t (λ () 'not-found) ns)
; -> not-found
 
But when I omit line 3 it does not work:
 
#lang racket/base
#;1 (define ns (make-base-namespace))
#;2 (namespace-variable-value 'list #t (λ () 'not-found) ns) ; -> #<procedure:list>
#;4 (namespace-undefine-variable! 'list ns)
;-> error namespace-undefine-variable!: given name is not defined
;       name: list

This I did with: Welcome to DrRacket, version 6.2.0.5--2015-07-06(d6fa581/a) [3m].
Code in the definitions window. The problem is not typical for 'list only.
The same happens with (at least some) other variables of a base-namespace.
 
I have no clue why commenting out line 3 gives an error.
Do I misinterpret the docs on namespaces?
 
Thanks, Jos
 
PS I use a base-namespace in a toy interpreter.
It allows me to easily borrow all variables from a base-namespace.
But some of them I want to undefine.
 
 
 

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

mattsap | 26 Aug 23:54 2015
Picon

Handin-Server Grading Utilities: write-report's start-timer

Hello,

I was wondering if someone could help me with the following. I'm setting up the handin collection for a
class. 

When I submit the code to my handin-server I get the following error:

-ERROR MESSAGE-----------------------------
commit error: start-timer: arity mismatch;
 the expected number of arguments does not match the given number
  expected: 3
  given: 2
  arguments...:
   0
   #<procedure>

-END ERROR MESSAGE-----------------------------

I traced the issue to the write-report function in the config file. Inside of write-report a start-timer
function call is made with 2 arguments. The start-timer function consumes 3 arguments per the
documentation here: http://docs.racket-lang.org/web-server-internal/timer.html?q=start-timer#%28def._%28%28lib._web-server%2Fprivate%2Ftimer..rkt%29._start-timer%29%29

I opened up the write-report's definition in the grading-utilities.rkt and here is the call to
start-timer which seems to be missing a parameter:

(start-timer (* 60 report-delay)
                        (thunk
                         (with-output-to-file
                             (build-path dir 
                                         (format "~a-report-~a.txt"
                                                 (string-join users "+")                                        
                                                 ts))
                           #:exists 'replace
                           (thunk (display report-string)))))

I'm not sure what to do now. Any suggestions? Below are my files.

------Student Submission-------
(define (bar x y)
  (+ x y))

------CONFIG file-----------------
((active-dirs ("test"))
 (deadline (("test" (2016 3 11 23 59 59) 3)))
 (max-submissions (("test" 200)))
)

------CHECKER.rkt-------------------
(module checker handin-server/checker

  (require handin-server/grading-utils)

  ; Checks that submission is on time and that the user has submissions left
  (pre:
   (check-deadline)
   (check-max-submissions))

  ; Ends the report by adding the score and writes it in the user directory
  ; This way, students can see their reports from the web interface.
  (post:
   (add-score-to-report!)
   (write-report))

  (check:
   ; Get timestamp of the submission and add it to header and report
   :language  '(special intermediate)
   (update-submission-timestamp!)
   (add-header-line! (get-submission-timestamp))
   (add-report-line! (get-submission-timestamp))

   ; Grading

   ; Initialize max score
   (set-test-max-score! 100)

   ; Failure discounts 25 points
   ( <at> test "Sample case 1"
          "Error using even? predicate"
          (bar 1 3)
          4
          25)
   ))

--

-- 
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.
Raoul Duke | 26 Aug 00:38 2015
Picon

cross-platform gui (Re: Re: My son's game in Racket)

> the agnostic, cross-platform GUI support.

"That trick never works!"

--

-- 
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.

Stephen Bloch | 25 Aug 13:09 2015
Picon

2htdp/universe performance

John Carmack writes:
The performance problems were related to the larger scrolling worlds. The H2DP versions got slower the more clouds were in the maps.

If the background is basically static but scrolling, you might get a substantial performance improvement by

(define background (freeze <big-expression-that-builds-the-background>)) 

and using that variable henceforth.  (The “freeze” function renders an image expression to a bitmap once and for all, trading memory for time.)  If not the WHOLE background is basically static, but you have a lot of repeated elements (say, a bunch of identical clouds), you can

(define cloud (freeze <big-expression-that-builds-a-cloud>))

and use that variable instead of the big expression henceforth.  There’s no harm in doing both, e.g.

(define background (freeze … cloud … cloud … cloud … ))

although this won’t buy you any additional performance.

The idea that you functionally compose images like this:
 ...
Which draws image1 on top of image2 on top of image 3, which is backwards from the "painters order" that would draw image 3, then image 2, then image 1.
 
This imperative, side-effect-ing code is a little less clear to a beginner with the OOP and DC concepts, but It better represents what actually happens, and it is much easier to modify the code without worrying about the nesting.

It’s not clear to me that the imperative style “better represents what actually happens,” nor that this matters.

However, there is a big win associated with the functional approach: it forces model-view separation from the beginning.  Model-view separation is how almost all GUI programs are written, and failures to follow it cause a lot of the display bugs in GUI programs.  Students who learn an imperative-first approach to GUI invariably end up writing display handlers that modify the model, or mouse handlers that draw to the display, causing the aforementioned display bugs.

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Alexander D. Knauth | 24 Aug 23:50 2015

(set-implements? (mutable-set) 'set-add)

It seems to me that (set-implements? (mutable-set) 'set-add) should return #f, and in 6.1.1 (and I think
6.2), that's true.

But in the latest snapshots, it produces #t.

It seems like it's implemented as an error message instead of not implemented at all, and
`set-implements?` can't tell the difference between implemented with an error message and actually implemented.

Is this a choice with reasons behind it, or should this be a bug?

--

-- 
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.


Gmane