[racket-users] saving a BMP in racket

2015-07-20 Thread copycat
Hi, not sure if this is considered a bug?

(send model save-file model1.bmp 'bmp)

save-file in bitmap%: kind saving not yet implemented: 'bmp

I found this link, and it's been 2 years since. Is it an update that will take 
a long time?

http://stackoverflow.com/questions/14987784/how-can-i-save-a-bmp-in-racket

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: How to draw a 3D ball?

2015-07-20 Thread Mianlai Zhou
Hi,

Thanks for your answer. I meant the former, i.e., a 2D pict of a ball with
some shading to make it look 3D.
Is there any quick way to do it or I have to implement the algorithm by
myself?

Thanks again.


On Mon, Jul 20, 2015 at 8:38 AM, Jack Firth jackhfi...@gmail.com wrote:

 On Saturday, July 18, 2015 at 7:30:42 PM UTC-7, Mianlai Zhou wrote:
  Hi all,
 
 
  I am wondering how to change the following code of a 2D circle into a 3D
 ball:
 
 
  (require slideshow)
  (colorize (filled-ellipse (* size 15) (* size 15)) red)
 
 
 
  My intention is to make the picture look like a real ball in
 3-dimension. Is there such
  a function existing already in Racket?
 
 
  Thank you in advance.

 By 3D ball do you want a 2D pict of a ball with some shading to make it
 look 3D, or a 3D model of a ball? If it's the latter you can use the pict3d
 package (raco pkg install pict3d):


 (require pict3d)
 (sphere origin 1)

 If you do this in DrRacket, the repl will show a window with a 3D ball
 model in it. You can click it and use the arrow keys to change the angle
 and position you view the ball from.

 --
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Current snapshot: problem with generic interfaces and contracts

2015-07-20 Thread Matthew Flatt
That was a bug in the revised implementation of `define-generics` for
the new expander. I've pushed a repair.

At Sun, 19 Jul 2015 22:34:36 -0400, Alexander D. Knauth wrote:
 This is a simplified example of something that worked in racket version 
 6.2.0.4 from 2015-06-08, but is now broken in version 6.2.900.4 from 
 2015-07-17.
 
 gen-foo.rkt:
 #lang racket
 (provide gen:foo foo? foo/c (contract-out [bar (foo? . - . any/c)]))
 (require racket/generic)
 (define-generics foo
   (bar foo))
 
 contract.rkt:
 #lang racket
 (require gen-foo.rkt)
 (define (foo/c* c)
   (foo/c
[bar (foo? . - . c)]))
 
 This works fine in the snapshot from last month, but in the current one, it 
 fail with this error:
 . redirect-generics: bar is not a method of generic interface gen:foo in: bar
 
 One way to get around this is to export an uncontracted version from 
 gen-foo.rkt, and possibly put the `bar` contract in a separate, third module, 
 but why would this be broken now?
 
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] db: postgresql current_date - timestamptz

2015-07-20 Thread George Neuner

Hi all,

I'm found something strange with Racket 6.1.1  and Postgresql (9.3.6):  
SQL that works differently in a Racket query than in the DB console.



I have a table defined as

   create table blah
   (
  a  char(15),
  b  char(15),
  created timestamp with time zone,
  expires timestamp with time zone
   );

and an insert query

   (set! sql-cmd (string-join `(
 insert into blah (a,b,created,expires)
   values ( $1
   ,$2
   ,current_date
   ,current_date + interval ' ,(number-string 
(expire-days))  days'

   )
 )))
   (query-exec db sql-cmd  some_characters more_characters )

where the value of (expire-days) is 30.


When I execute this in Racket, the dates entered into the table are off 
by 1 day and have an erroneous hour component:  e.g., today is 7-20, the 
values entered are  created =  2015-07-19 20:00:00-04 and  expires = 
2015-08-18 20:00:00-04.


Obviously the problem is with current_date, however ...


When I execute the analogous code directly from the DB console

   insert into stats.surveys_restrict (a,b,created,expires)
 values ('some_characters'
,'more_characters'
,current_date
,current_date + interval '30 days')

I get the expected values:  created = 2015-07-20 00:00:00-04  and 
expires = 2015-08-19 00:00:00-04.



Since the dates are in the SQL code rather than passed arguments to the 
Racket query call, I don't understand how this is happening ... I would 
have expected to see the same behavior in the console. Casting the dates 
to type timestamptz in the SQL doesn't change the results (in either 
Racket or the console).


If I substitute current_timestamp  instead of current_date, the query 
works as expected both in Racket and in the console.  However, the 
Postgresql docs say that current_date is coerced to timestamp and the 
behavior of the console seems to confirm that.  I don't understand why I 
get a different value from the Racket query.


This isn't a I problem per se as I can substitute current_timestamp 
without issue, but since the program logic currently doesn't need the 
time component, I had thought to use current_date instead.


Any clues as to what is happening?
George


--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Macro introduce identifiers in the new expander

2015-07-20 Thread Alexander D. Knauth
I don't really know what's going on, but this might help:

;; It seems to be introducing the definition correctly, but not the use:
;; this works
(let ()
  (def) ; no difference between (def) and (define id 5)
  id)

;; this doesn't
(let ()
  (def)
  (use)) ; but there is a difference between (use) and id

;; and this doesn't either
(let ()
  (define id 5)
  (use))

On Jul 20, 2015, at 12:35 PM, Spencer Florence spen...@florence.io wrote:

 Hello,
 
 I'm trying to update some code to the new expander. The below code works on 
 6.2 but fails on the new expander with an unbound identifier error. 
 
 #lang racket
 (require (for-syntax syntax/parse))
 
 ;; a standard context for identifiers
 (define-for-syntax ctx #'ctx)
 
 ;; create an ID with the context `ctx`, and the current
 ;; expander mark (so that the mark is canceled later),
 ;; and the location loc
 (define-for-syntax (make-id loc)
   (syntax-local-introduce
(datum-syntax ctx 'id loc)))
 
 ;; This introduces a binding
 (define-syntax (def stx)
   (syntax-parse stx
 [(def)
  (with-syntax ([id (make-id #'here)])
#'(define id 5))]))
 
 ;; this attempts to use the binding introduced by `def`
 (define-syntax (use stx)
   (syntax-parse stx
 [(use)
  (with-syntax ([id (make-id #'here)])
#'id)]))
 
 ;; this works
 #;
 (begin
   (def)
   (use))
 
 ;; this fails
 (let ()
   (def)
   (use))
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Macro introduce identifiers in the new expander

2015-07-20 Thread Spencer Florence
Hello,

I'm trying to update some code to the new expander. The below code works on
6.2 but fails on the new expander with an unbound identifier error.

#lang racket
(require (for-syntax syntax/parse))

;; a standard context for identifiers
(define-for-syntax ctx #'ctx)

;; create an ID with the context `ctx`, and the current
;; expander mark (so that the mark is canceled later),
;; and the location loc
(define-for-syntax (make-id loc)
  (syntax-local-introduce
   (datum-syntax ctx 'id loc)))

;; This introduces a binding
(define-syntax (def stx)
  (syntax-parse stx
[(def)
 (with-syntax ([id (make-id #'here)])
   #'(define id 5))]))

;; this attempts to use the binding introduced by `def`
(define-syntax (use stx)
  (syntax-parse stx
[(use)
 (with-syntax ([id (make-id #'here)])
   #'id)]))

;; this works
#;
(begin
  (def)
  (use))

;; this fails
(let ()
  (def)
  (use))

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] 6.2 regression in running tests?

2015-07-20 Thread Gustavo Massaccesi
Sorry for the delay. It has been a very interesting week in the low
level implementation of Racket. A few days ago, Matthew fixed the bug
and enabled the new expander, and then he fixed most of the problems
that appear with the changes. So now looks like a good time to retry
all the tests and see if the test are working with the snapshot
version of Racket.

Following this idea, I remembered that the rackjure project (
https://github.com/greghendershott/rackjure ) has a .travis.yml file,
to get continuous integration tests in Travis. It uses a trick to run
the project with the latest 10 versions of Racket. You can configure
it to run less versions, for example only 6.0.1, 6.1.1 and HEAD (but
allow errors in HEAD). You should look at the file in the repository
because it's very clear, and if you have a problem you may ask the
author because he usually reads the list.

This will give you a report of the errors that the next version of
Racket would create, and you can send an early warning to the list.
This will be helpfull to fix the errors before shipping.

Gustavo


On Wed, Jul 15, 2015 at 4:14 AM, Ryan Davis zenspi...@gmail.com wrote:

 On Jul 14, 2015, at 20:19, Gustavo Massaccesi gust...@oma.org.ar wrote:

 Replacing the line 1758 of optimize.c

 -  if ((info-inline_fuel  0)  info-has_nonleaf  !noapp)
 +  if ((info-inline_fuel = 0)  info-has_nonleaf  !noapp)

 make the problem disappear, but I still don't understand why (dup
 rep) is the only combination that creates a problem.

 I also want to think about the (info-inline_fuel = 0) in line 1872
 and how that interacts with the if (noapp) in line 1876 ...

 Thanks! I can test against my whole suite in tomorrow's daily if you'd like.


-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] db: postgresql current_date - timestamptz

2015-07-20 Thread Jay Kominek
You might be ending up with different timezones set on the different
connections, as libpq clients can automatically set/change some
session settings that the racket library does not. I'd try running
show timezone via both connections, and see what you end up with.

On Mon, Jul 20, 2015 at 12:29 PM, George Neuner gneun...@comcast.net wrote:
 Hi all,

 I'm found something strange with Racket 6.1.1  and Postgresql (9.3.6):  SQL
 that works differently in a Racket query than in the DB console.


 I have a table defined as

create table blah
(
   a  char(15),
   b  char(15),
   created timestamp with time zone,
   expires timestamp with time zone
);

 and an insert query

(set! sql-cmd (string-join `(
  insert into blah (a,b,created,expires)
values ( $1
,$2
,current_date
,current_date + interval ' ,(number-string
 (expire-days))  days'
)
  )))
(query-exec db sql-cmd  some_characters more_characters )

 where the value of (expire-days) is 30.


 When I execute this in Racket, the dates entered into the table are off by 1
 day and have an erroneous hour component:  e.g., today is 7-20, the values
 entered are  created =  2015-07-19 20:00:00-04  and  expires = 2015-08-18
 20:00:00-04.

 Obviously the problem is with current_date, however ...


 When I execute the analogous code directly from the DB console

insert into stats.surveys_restrict (a,b,created,expires)
  values ('some_characters'
 ,'more_characters'
 ,current_date
 ,current_date + interval '30 days')

 I get the expected values:  created = 2015-07-20 00:00:00-04  and  expires =
 2015-08-19 00:00:00-04.


 Since the dates are in the SQL code rather than passed arguments to the
 Racket query call, I don't understand how this is happening ... I would have
 expected to see the same behavior in the console.  Casting the dates to type
 timestamptz in the SQL doesn't change the results (in either Racket or the
 console).

 If I substitute current_timestamp  instead of current_date, the query works
 as expected both in Racket and in the console.  However, the Postgresql docs
 say that current_date is coerced to timestamp and the behavior of the
 console seems to confirm that.  I don't understand why I get a different
 value from the Racket query.

 This isn't a I problem per se as I can substitute current_timestamp without
 issue, but since the program logic currently doesn't need the time
 component, I had thought to use current_date instead.

 Any clues as to what is happening?
 George


 --
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.



-- 
Jay Kominek

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Macro introduce identifiers in the new expander

2015-07-20 Thread Matthew Flatt
Repair pushed.



 On Jul 20, 2015, at 11:14 AM, Matthew Flatt mfl...@cs.utah.edu wrote:
 
 Thanks for the info. I think it's a bug in the expander, and I have a
 repair, but I think that repair might point to another bug that I'm
 still investigating.
 
 At Mon, 20 Jul 2015 12:56:49 -0400, Alexander D. Knauth wrote:
 I don't really know what's going on, but this might help:
 
 ;; It seems to be introducing the definition correctly, but not the use:
 ;; this works
 (let ()
  (def) ; no difference between (def) and (define id 5)
  id)
 
 ;; this doesn't
 (let ()
  (def)
  (use)) ; but there is a difference between (use) and id
 
 ;; and this doesn't either
 (let ()
  (define id 5)
  (use))
 
 On Jul 20, 2015, at 12:35 PM, Spencer Florence spen...@florence.io wrote:
 
 Hello,
 
 I'm trying to update some code to the new expander. The below code works on
 6.2 but fails on the new expander with an unbound identifier error. 
 
 #lang racket
 (require (for-syntax syntax/parse))
 
 ;; a standard context for identifiers
 (define-for-syntax ctx #'ctx)
 
 ;; create an ID with the context `ctx`, and the current
 ;; expander mark (so that the mark is canceled later),
 ;; and the location loc
 (define-for-syntax (make-id loc)
  (syntax-local-introduce
   (datum-syntax ctx 'id loc)))
 
 ;; This introduces a binding
 (define-syntax (def stx)
  (syntax-parse stx
[(def)
 (with-syntax ([id (make-id #'here)])
   #'(define id 5))]))
 
 ;; this attempts to use the binding introduced by `def`
 (define-syntax (use stx)
  (syntax-parse stx
[(use)
 (with-syntax ([id (make-id #'here)])
   #'id)]))
 
 ;; this works
 #;
 (begin
  (def)
  (use))
 
 ;; this fails
 (let ()
  (def)
  (use))
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.
 

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] using `module*` with the new macro expander

2015-07-20 Thread Matthew Butterick
 The new expander treats submodules like everything else. Since
 `racket/math`, is macro-introduced while the body of the submodule `pi`
 is not, the import doesn't bind `pi`. For that matter, the initial
 `racket/base` import is also macro-introduced and doesn't bind `#%top`
 for `pi`.

OK, this is the part I was missing: the old expander did a little magic with 
certain identifiers within submodules, but no longer.


 To make this example work with the new expander, one solution is to use
 `syntax/strip-context` to make a macro that behaves like
 `module*-macro` with the old expander, but with context stripping by
 the macro instead of by `module*`:

As an alternative, is it acceptable / wise to continue use `with-syntax` to 
introduce the identifiers that the new expander omits? E.g., this also will fix 
the macro:

(define-syntax (module*-macro stx)
  (syntax-case stx ()
[(_ exprs ...)
 (with-syntax ([racket/base (format-id stx ~a #'racket/base)])
   #'(module* submod-name racket/base 
 exprs ...))]))


 I think it's relatively common for macros that introduce submodules to
 intend non-hygienic binding for the macro body --- so, this is a
 significant incompatibility. I didn't see a way to keep the old
 behavior, though, without defeating some advantages of the new
 expander.


It sounds like the new expander doesn't forbid this kind of macrology, but 
rather requires the author to be more explicit about it.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Macro introduce identifiers in the new expander

2015-07-20 Thread Matthew Flatt
Thanks for the info. I think it's a bug in the expander, and I have a
repair, but I think that repair might point to another bug that I'm
still investigating.

At Mon, 20 Jul 2015 12:56:49 -0400, Alexander D. Knauth wrote:
 I don't really know what's going on, but this might help:
 
 ;; It seems to be introducing the definition correctly, but not the use:
 ;; this works
 (let ()
   (def) ; no difference between (def) and (define id 5)
   id)
 
 ;; this doesn't
 (let ()
   (def)
   (use)) ; but there is a difference between (use) and id
 
 ;; and this doesn't either
 (let ()
   (define id 5)
   (use))
 
 On Jul 20, 2015, at 12:35 PM, Spencer Florence spen...@florence.io wrote:
 
  Hello,
  
  I'm trying to update some code to the new expander. The below code works on 
 6.2 but fails on the new expander with an unbound identifier error. 
  
  #lang racket
  (require (for-syntax syntax/parse))
  
  ;; a standard context for identifiers
  (define-for-syntax ctx #'ctx)
  
  ;; create an ID with the context `ctx`, and the current
  ;; expander mark (so that the mark is canceled later),
  ;; and the location loc
  (define-for-syntax (make-id loc)
(syntax-local-introduce
 (datum-syntax ctx 'id loc)))
  
  ;; This introduces a binding
  (define-syntax (def stx)
(syntax-parse stx
  [(def)
   (with-syntax ([id (make-id #'here)])
 #'(define id 5))]))
  
  ;; this attempts to use the binding introduced by `def`
  (define-syntax (use stx)
(syntax-parse stx
  [(use)
   (with-syntax ([id (make-id #'here)])
 #'id)]))
  
  ;; this works
  #;
  (begin
(def)
(use))
  
  ;; this fails
  (let ()
(def)
(use))
  
  -- 
  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+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/d/optout.
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Macro to extract select subexpressions into other locations

2015-07-20 Thread Jack Firth
I'm trying to create a way to automatically turn test cases into examples. I'd 
like a macro that turns this:

(extract-expressions
 (module+ test
   (check-equal? (extract-expression (square 5)) 25)
   (check-equal? (extract-expression (square -5)) 25))
 (module+ doc
   @defproc[(square [x real?]) real?]{
 Returns the square of @racket[x], the result of
 multiplying @racket[x] by itself.
 @examples[#:eval evaluator (include-extracted-expressions)]}))

into this:

(begin
  (module+ test
(check-equal? (square 5) 25))
  (module+ doc
@defproc[(square [x real?]) real?]{
  Returns the square of @racket[x], the result of
  multiplying @racket[x] by itself.
  @examples[#:eval evaluator (square 5) (square -5)]}))

That's the general idea anyway. I want to be able to gather arbitrary 
expressions inside a region and copy them into some other marked place inside 
the expressions. How exactly do I go about doing this, and how should I do it 
properly?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] db: postgresql current_date - timestamptz

2015-07-20 Thread George Neuner

On 7/20/2015 6:08 PM, Jay Kominek wrote:

You might be ending up with different timezones set on the different
connections, as libpq clients can automatically set/change some
session settings that the racket library does not. I'd try running
show timezone via both connections, and see what you end up with.


Hi Jay,

I think you hit the nail on the head.  Somewhere I am setting the 
timestamp in UTC and somehow reading it back in local time.  I think I 
was confused because the PG docs say *current_date* always produces time 
= 00:00:00 when coerced to a timestamp ... but I glossed over that the 
docs were using timestamp _without_ time zone.   After a bit of 
experimenting, it appears that if a date is coerced to 'timestamp with 
time zone', the hour is adjusted so the time only reads 00:00:00 if you 
write and read back using the same time zone setting.


I am using a connection pool, but I /thought/ I was executing /*set 
session time zone 0*/  (for UTC) on every connection before using it.


Thanks for pointing me in the right direction.
George

--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.