[racket-users] Are canvases stackable?

2018-02-23 Thread Alex Harsanyi
You want to use a pasteboard% for the chess table and snip% objects for the 
pieces.  You can draw the board as the pasteboard background in the on-draw 
method. 

You will have to implement snip management in the pasteboard though because by 
default snips can just be dragged around and placed anywhere. 

There’s a racket game collection which might provide useful classes, but I have 
no experience with those. 

Best regards,
Alex

-- 
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] Are canvases stackable?

2018-02-23 Thread David Alkire
Is it possible to stack two (or more) canvases on top of one another. I'm 
working on a chess app and I don't want to draw individual squares under 
each piece. I would prefer to have a board canvas that doesn't change and a 
transparent canvas with pieces overlaying it. Is that possible? Is that the 
right approach or are there better alternatives?

Thanks,
David

-- 
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] What are good references for implementing interpreters in Racket (or Scheme/LISP)?

2018-02-23 Thread Matthias Felleisen

You need to distinguish different types of implementations: 

1. An interpreter is a function that consumes a representation of your (J) 
program and determines its value (and output, if any). 
2. A compiler is a function that consumes a representation of your (J) program 
and produces a (hopefully equivalent) program in another language. 
Then you run this second program on an interpreter for this second (aka 
target) language. 
3. A Racket embedding elaborates J programs (possibly parenthesized, possibly 
in original ugly syntax) into Racket and then Racket takes over. 
What’s the difference to 2? You directly re-use the underlying language 
and you can build the language in an incremental manner writing incredibly 
small pieces of a compiler at a time. 

The efforts are vastly different, and so are the trade-offs. 


> On Feb 23, 2018, at 7:31 PM, Raoul Schorer  wrote:
> 
> Hi,
> 
> I am trying to write an interpreter for J in Racket as a hobby project.
> Would you guys know of good references on writing interpreters?
> 
> Some nice things I found:
> craftinginterpreters.com 
> 
This teaches you how to write an interpreter (1). I’d also look at Shriram 
Krishnamurthi’s PLAI, which is also linked into the Racket web site. 

> beautifulracket.com This is about Racket 
> embeddings (3). Great approach, everyone’s darling around here. 

> Racket J experimental package The docs 
> suggest that this is a truly strange approach, writing programs as strings 
> and then compiling them into Racket. If I misunderstood, the author of the 
> package should please speak up. 

I think approach 3 is your best bet to learn Racket and the capability of 
producing a language. 


> 
> Would you know of more?
> 
> Cheers,
> Raoul
> 
> -- 
> 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] What are good references for implementing interpreters in Racket (or Scheme/LISP)?

2018-02-23 Thread Raoul Schorer
Hi,

I am trying to write an interpreter for J in Racket as a hobby project.
Would you guys know of good references on writing interpreters?

Some nice things I found:

   - craftinginterpreters.com 
   
   - beautifulracket.com
   - Racket J experimental package 


Would you know of more?

Cheers,
Raoul

-- 
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] racket (7) on a new arch

2018-02-23 Thread Alexander McLin
On Friday, February 23, 2018 at 11:08:23 AM UTC-5, David K. Storrs wrote:
>
>
> On Thu, Feb 22, 2018 at 11:14 AM, Alexander McLin  > wrote:
>
>> As one of those who have been following RISC-V progress for several years 
>> and also interested in seeing Racket being ported to that architecture I 
>> want to drop a note to let you know you have my support!
>>
>
> As someone who doesn't know a lot about hardware, I'm curious:  what 
> effect would runningthe new architecture have?  Would it enable new 
> functionality, provide performance boosts...?
>

In the near-future, none. 

RISC-V is designed to be an open-source ISA free of any royalties or 
licensing concerns whatsoever. The idea is to provide a flexible family of 
ISAs which can be combined as needed for one's purposes and any company or 
foundry can manufacture RISC-V CPUs without restrictions. RSIC-V's long 
term goal is to become a universal ISA anyone can use in contrast to X86 or 
ARM which come with hefty licensing fees and restrictions on who can 
manufacture chips which makes it difficult for anyone else to innovate in 
those spaces.

As for enabling new functionality, one major goal for RISC-V is to allow 
the ISA to be extended in well-defined ways which preserve backward 
compatibility but allow innovative features to be enabled for specific 
applications. It remains to see how successful that would be. My 
expectation is better support for hardware-based security features and 
audit of hardware designs by independent parties which is significant given 
how the Meltdown and Spectre vulnerabilities have highlighted the opaque 
nature of the closed-source X86 hardware.

Once anyone who's interested can at relatively low costs explore the design 
space of possible RISC-V hardware, who knows what performance benefits may 
become possible.

-- 
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] racket (7) on a new arch

2018-02-23 Thread David Storrs
On Thu, Feb 22, 2018 at 11:14 AM, Alexander McLin 
wrote:

> As one of those who have been following RISC-V progress for several years
> and also interested in seeing Racket being ported to that architecture I
> want to drop a note to let you know you have my support!
>

As someone who doesn't know a lot about hardware, I'm curious:  what effect
would runningthe new architecture have?  Would it enable new functionality,
provide performance boosts...?


> --
> 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] Building full racket 6.10 and up fails on Nix/MacOS

2018-02-23 Thread Claes Wallin
On Friday, February 23, 2018 at 9:52:40 PM UTC+8, Claes Wallin wrote:
>
> On Friday, February 23, 2018 at 8:50:22 PM UTC+8, Claes Wallin wrote:
>>
>> On Friday, February 23, 2018 at 8:37:17 PM UTC+8, Matthew Flatt wrote:
>>>
>>>
>>>  (define convert (bytes-open-converter "UTF-8" "UTF-16")) 
>>>  (bytes-convert convert (bytes 65 66 67 68)) 
>>>
>>> which will fail if the iconv installation doesn't recognize "UTF-8" or 
>>> "UTF-16".
>>>
>>> Ok, so (bytes-open-converter) will return #f if it receives an unknown 
>>> encoding?
>>>
>>> I guess I'll have to look at what kind of iconv library racket is being 
>>> built with.
>>>
>>
> I can confirm that my (bytes-open-converter) doesn't understand "UTF-16" 
> and returns #f. Thanks for the lead!
>

Replacing the system libiconv with GNU libiconv works! We should have a 
full racket in Nix/Darwin in few days.

-- 
   /c 

-- 
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] Generating automatic testsuites using a macro

2018-02-23 Thread Ryan Culpepper

On 2/23/18 3:36 PM, 'Paulo Matos' via Racket Users wrote:


On 23/02/18 15:13, 'Paulo Matos' via Racket Users wrote:

That's true, thanks for pointing it out. I only just noticed you could
generate test-suites and test-cases at runtime with make-testcase and
make-testsuite. Therefore I will actually be doing this without a macro.
However, it's always very useful to attempt this macro katas. :)



I will take that back. There is a make-test-suite but not a
make-test-case. Since test-case is syntax, I don't think there's a way
to programmatically create a list of test-cases, put them in a test
suite and later run them.

I tried
#lang racket

(require rackunit)

(define (make-suite n)
  (make-test-suite
   (format "Testsuite of ~a tests" n)
   (for/list ([i (in-range n)])
 (test-case (format "test ~a" i)
(check = i i)

(define s (make-suite 100))

(require rackunit/text-ui)
(run-tests s)

But this doesn't actually work. I think I really need to stick to the
macro stuff.


You can write `make-suite` like this:

  (define (make-suite n)
(test-suite
  (format "Testsuite of ~a tests" n)
  (for ([i (in-range n)])
(test-case (format "test ~a" i)
  (check = i i)

Ryan

--
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] Generating automatic testsuites using a macro

2018-02-23 Thread 'Paulo Matos' via Racket Users


On 23/02/18 15:13, 'Paulo Matos' via Racket Users wrote:
> That's true, thanks for pointing it out. I only just noticed you could
> generate test-suites and test-cases at runtime with make-testcase and
> make-testsuite. Therefore I will actually be doing this without a macro.
> However, it's always very useful to attempt this macro katas. :)
> 

I will take that back. There is a make-test-suite but not a
make-test-case. Since test-case is syntax, I don't think there's a way
to programmatically create a list of test-cases, put them in a test
suite and later run them.

I tried
#lang racket

(require rackunit)

(define (make-suite n)
  (make-test-suite
   (format "Testsuite of ~a tests" n)
   (for/list ([i (in-range n)])
 (test-case (format "test ~a" i)
(check = i i)

(define s (make-suite 100))

(require rackunit/text-ui)
(run-tests s)

But this doesn't actually work. I think I really need to stick to the
macro stuff.

-- 
Paulo Matos

-- 
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] Generating automatic testsuites using a macro

2018-02-23 Thread 'Paulo Matos' via Racket Users


On 23/02/18 15:20, Philip McGrath wrote:
> The "Introduction" from the syntax/parse docs
> (http://docs.racket-lang.org/syntax/stxparse-intro.html), is very good
> in the spirit of the Racket Guide and also explains why you want to use
> syntax/parse. Between that and the "Examples" section, I found I could
> handle many of the cases I wanted to without needing to dive into the
> more intimidating parts of the documentation for quite a while.
> 

Thanks, I shall take a look.

-- 
Paulo Matos

-- 
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] Generating automatic testsuites using a macro

2018-02-23 Thread Philip McGrath
The "Introduction" from the syntax/parse docs (
http://docs.racket-lang.org/syntax/stxparse-intro.html), is very good in
the spirit of the Racket Guide and also explains why you want to use
syntax/parse. Between that and the "Examples" section, I found I could
handle many of the cases I wanted to without needing to dive into the more
intimidating parts of the documentation for quite a while.

-Philip

On Fri, Feb 23, 2018 at 8:13 AM, Paulo Matos  wrote:

>
>
> On 23/02/18 15:07, Philip McGrath wrote:
> >
> > I also used syntax-parse to conveniently check that n really is a
> > nonnegative integer literal, though of course you could write such a
> > check with syntax-case if you really wanted to.
> >
>
> Thanks for the code snippet which goes in the same direction as
> Matthews, except it uses syntax-parser, which I have never looked at
> before. Should probably look for a good intro to it.
>
> > Note that this generates quite a lot of code. I'm assuming there's a
> > good reason you want to do this with a macro and not a function (perhaps
> > using with-check-infoto enhance failure reporting), but that's certainly
> > something you'd want to consider if you haven't.
> >
>
> That's true, thanks for pointing it out. I only just noticed you could
> generate test-suites and test-cases at runtime with make-testcase and
> make-testsuite. Therefore I will actually be doing this without a macro.
> However, it's always very useful to attempt this macro katas. :)
>
> Thanks,
>
> > -Philip
> >
> > On Fri, Feb 23, 2018 at 7:11 AM, 'Paulo Matos' via Racket Users
> > >
> > wrote:
> >
> > Hi,
> >
> > I am trying to get a macro working to generate an automatic
> testsuite. I
> > have shrank my example to:
> > #lang racket
> >
> > (define-syntax (gen-testsuite stx)
> >   (syntax-case stx ()
> > [(_ n)
> >  #`(test-suite
> > "Automated suite"
> > #,@(for/list ([i (syntax->datum #'n)])
> >  #`(test-case
> > (format "Test number ~a" i)
> > (check = i i]))
> >
> > (require rackunit
> >  rackunit/text-ui)
> >
> > (run-tests
> >  (gen-testsuite 100))
> >
> > This should generate a test-suite that can then be wrapped in
> run-tests.
> > It should example to something like:
> > (testsuite
> >"Automated suite"
> >(test-case "Test number 1" (check = 1 1))
> >(test-case "Test number 2" (check = 2 2))
> >(test-case "Test number 3" (check = 3 3))
> >...)
> >
> > This fails because the i in the body of the test case does not exist
> at
> > run-time. I understand why this is failing. However if I try to
> replace
> > the i by #,(syntax->datum #'i) it also fails. My feeling is that I
> need
> > to introduce a new template variable, which I would generally do with
> > with-syntax however I am not sure how to integrate this with the
> > for/list expression.
> >
> > Regards,
> > --
> > Paulo Matos
> >
> > --
> > 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.
>
> --
> Paulo Matos
>

-- 
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] Generating automatic testsuites using a macro

2018-02-23 Thread 'Paulo Matos' via Racket Users


On 23/02/18 15:07, Philip McGrath wrote:
> 
> I also used syntax-parse to conveniently check that n really is a
> nonnegative integer literal, though of course you could write such a
> check with syntax-case if you really wanted to.
> 

Thanks for the code snippet which goes in the same direction as
Matthews, except it uses syntax-parser, which I have never looked at
before. Should probably look for a good intro to it.

> Note that this generates quite a lot of code. I'm assuming there's a
> good reason you want to do this with a macro and not a function (perhaps
> using with-check-infoto enhance failure reporting), but that's certainly
> something you'd want to consider if you haven't.
> 

That's true, thanks for pointing it out. I only just noticed you could
generate test-suites and test-cases at runtime with make-testcase and
make-testsuite. Therefore I will actually be doing this without a macro.
However, it's always very useful to attempt this macro katas. :)

Thanks,

> -Philip
> 
> On Fri, Feb 23, 2018 at 7:11 AM, 'Paulo Matos' via Racket Users
> >
> wrote:
> 
> Hi,
> 
> I am trying to get a macro working to generate an automatic testsuite. I
> have shrank my example to:
> #lang racket
> 
> (define-syntax (gen-testsuite stx)
>   (syntax-case stx ()
>     [(_ n)
>      #`(test-suite
>         "Automated suite"
>         #,@(for/list ([i (syntax->datum #'n)])
>              #`(test-case
>                 (format "Test number ~a" i)
>                 (check = i i]))
> 
> (require rackunit
>          rackunit/text-ui)
> 
> (run-tests
>  (gen-testsuite 100))
> 
> This should generate a test-suite that can then be wrapped in run-tests.
> It should example to something like:
> (testsuite
>    "Automated suite"
>    (test-case "Test number 1" (check = 1 1))
>    (test-case "Test number 2" (check = 2 2))
>    (test-case "Test number 3" (check = 3 3))
>    ...)
> 
> This fails because the i in the body of the test case does not exist at
> run-time. I understand why this is failing. However if I try to replace
> the i by #,(syntax->datum #'i) it also fails. My feeling is that I need
> to introduce a new template variable, which I would generally do with
> with-syntax however I am not sure how to integrate this with the
> for/list expression.
> 
> Regards,
> --
> Paulo Matos
> 
> --
> 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.

-- 
Paulo Matos

-- 
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] Generating automatic testsuites using a macro

2018-02-23 Thread 'Paulo Matos' via Racket Users


On 23/02/18 14:56, Matthew Butterick wrote:
> 
>> On Feb 23, 2018, at 5:11 AM, 'Paulo Matos' via Racket Users 
>>  wrote:
>>
>> This fails because the i in the body of the test case does not exist at
>> run-time. I understand why this is failing. However if I try to replace
>> the i by #,(syntax->datum #'i) it also fails. My feeling is that I need
>> to introduce a new template variable, which I would generally do with
>> with-syntax however I am not sure how to integrate this with the
>> for/list expression.
> 
> `i` is a compile-time value that you need to convert into a piece of syntax, 
> so `syntax->datum` goes the wrong direction. You could use `datum->syntax`, 
> or even just this:
> 
> #lang racket
> 
> (define-syntax (gen-testsuite stx)
>   (syntax-case stx ()
> [(_ n)
>  #`(test-suite
> "Automated suite"
> #,@(for/list ([i (syntax->datum #'n)])
>  (with-syntax ([i i])

Argh, of course. I missed something completely obvious and
embarrassingly short. Thanks.

-- 
Paulo Matos

-- 
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] Generating automatic testsuites using a macro

2018-02-23 Thread Philip McGrath
Here is a version that works, with explanation following:

#lang racket

(require rackunit
 rackunit/text-ui
 (for-syntax syntax/parse))

(define-syntax gen-testsuite
  (syntax-parser
[(_ n:exact-nonnegative-integer)
 #`(test-suite
"Automated suite"
#,@(for/list ([i-num (syntax->datum #'n)])
 (with-syntax ([i (datum->syntax #'n i-num)])
   #`(test-case
  (format "Test number ~a" i)
  (check = i i)]))

(run-tests
 (gen-testsuite 100))

Your original code converted #'n the syntax object to a compile-time
integer just fine. Here I've called the integer loop variable i-num for
clarity. The step you're missing, as you recognize, is that you need to
introduce i as a pattern variable bound to a syntax object: with-syntax
does the binding, and datum->syntax turns the compile-time integer back
into a syntax object. (I gave it the context from the original #'n, which I
think handles some cases about #%datum transformers and other strange
things nicely.)

I also used syntax-parse to conveniently check that n really is a
nonnegative integer literal, though of course you could write such a check
with syntax-case if you really wanted to.

Note that this generates quite a lot of code. I'm assuming there's a good
reason you want to do this with a macro and not a function (perhaps using
with-check-info to enhance failure reporting), but that's certainly
something you'd want to consider if you haven't.

-Philip

On Fri, Feb 23, 2018 at 7:11 AM, 'Paulo Matos' via Racket Users <
racket-users@googlegroups.com> wrote:

> Hi,
>
> I am trying to get a macro working to generate an automatic testsuite. I
> have shrank my example to:
> #lang racket
>
> (define-syntax (gen-testsuite stx)
>   (syntax-case stx ()
> [(_ n)
>  #`(test-suite
> "Automated suite"
> #,@(for/list ([i (syntax->datum #'n)])
>  #`(test-case
> (format "Test number ~a" i)
> (check = i i]))
>
> (require rackunit
>  rackunit/text-ui)
>
> (run-tests
>  (gen-testsuite 100))
>
> This should generate a test-suite that can then be wrapped in run-tests.
> It should example to something like:
> (testsuite
>"Automated suite"
>(test-case "Test number 1" (check = 1 1))
>(test-case "Test number 2" (check = 2 2))
>(test-case "Test number 3" (check = 3 3))
>...)
>
> This fails because the i in the body of the test case does not exist at
> run-time. I understand why this is failing. However if I try to replace
> the i by #,(syntax->datum #'i) it also fails. My feeling is that I need
> to introduce a new template variable, which I would generally do with
> with-syntax however I am not sure how to integrate this with the
> for/list expression.
>
> Regards,
> --
> Paulo Matos
>
> --
> 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] Generating automatic testsuites using a macro

2018-02-23 Thread Matthew Butterick

> On Feb 23, 2018, at 5:11 AM, 'Paulo Matos' via Racket Users 
>  wrote:
> 
> This fails because the i in the body of the test case does not exist at
> run-time. I understand why this is failing. However if I try to replace
> the i by #,(syntax->datum #'i) it also fails. My feeling is that I need
> to introduce a new template variable, which I would generally do with
> with-syntax however I am not sure how to integrate this with the
> for/list expression.

`i` is a compile-time value that you need to convert into a piece of syntax, so 
`syntax->datum` goes the wrong direction. You could use `datum->syntax`, or 
even just this:

#lang racket

(define-syntax (gen-testsuite stx)
  (syntax-case stx ()
[(_ n)
 #`(test-suite
"Automated suite"
#,@(for/list ([i (syntax->datum #'n)])
 (with-syntax ([i i])
   #`(test-case
  (format "Test number ~a" i)
  (check = i i)]))

-- 
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] Building full racket 6.10 and up fails on Nix/MacOS

2018-02-23 Thread Claes Wallin
On Friday, February 23, 2018 at 8:50:22 PM UTC+8, Claes Wallin wrote:
>
> On Friday, February 23, 2018 at 8:37:17 PM UTC+8, Matthew Flatt wrote:
>>
>>
>>  (define convert (bytes-open-converter "UTF-8" "UTF-16")) 
>>  (bytes-convert convert (bytes 65 66 67 68)) 
>>
>> which will fail if the iconv installation doesn't recognize "UTF-8" or 
>> "UTF-16".
>>
>> Ok, so (bytes-open-converter) will return #f if it receives an unknown 
>> encoding?
>>
>> I guess I'll have to look at what kind of iconv library racket is being 
>> built with.
>>
>
I can confirm that my (bytes-open-converter) doesn't understand "UTF-16" 
and returns #f. Thanks for the lead!

-- 
   /c 

-- 
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] Generating automatic testsuites using a macro

2018-02-23 Thread 'Paulo Matos' via Racket Users
Hi,

I am trying to get a macro working to generate an automatic testsuite. I
have shrank my example to:
#lang racket

(define-syntax (gen-testsuite stx)
  (syntax-case stx ()
[(_ n)
 #`(test-suite
"Automated suite"
#,@(for/list ([i (syntax->datum #'n)])
 #`(test-case
(format "Test number ~a" i)
(check = i i]))

(require rackunit
 rackunit/text-ui)

(run-tests
 (gen-testsuite 100))

This should generate a test-suite that can then be wrapped in run-tests.
It should example to something like:
(testsuite
   "Automated suite"
   (test-case "Test number 1" (check = 1 1))
   (test-case "Test number 2" (check = 2 2))
   (test-case "Test number 3" (check = 3 3))
   ...)

This fails because the i in the body of the test case does not exist at
run-time. I understand why this is failing. However if I try to replace
the i by #,(syntax->datum #'i) it also fails. My feeling is that I need
to introduce a new template variable, which I would generally do with
with-syntax however I am not sure how to integrate this with the
for/list expression.

Regards,
-- 
Paulo Matos

-- 
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] Building full racket 6.10 and up fails on Nix/MacOS

2018-02-23 Thread Claes Wallin
On Friday, February 23, 2018 at 8:37:17 PM UTC+8, Matthew Flatt wrote:
>
> At Thu, 22 Feb 2018 19:55:17 -0800 (PST), Claes Wallin wrote:  

> raco setup: --- summary of errors --- 
> > raco setup: error: during building docs for 
> > /racket-doc/scribblings/reference/reference.scrbl 
> > raco setup:   examples: exception raised in example 
> > raco setup: error: "bytes-convert: contract violation\n  expected: 
> > bytes-converter?\n  given: #f\n  argument position: 1st\n  other 
> > arguments...:\n   #\"ABCD\"" 
>
> Maybe you already know this, but it's probably related to iconv. That 
> part of the documentation is trying to run an example 
>

No, I don't know this. Thank you!

 (define convert (bytes-open-converter "UTF-8" "UTF-16")) 
>  (bytes-convert convert (bytes 65 66 67 68)) 
>
> which will fail if the iconv installation doesn't recognize "UTF-8" or 
> "UTF-16".
>

Ok, so (bytes-open-converter) will return #f if it receives an unknown 
encoding?

I guess I'll have to look at what kind of iconv library racket is being 
built with.

-- 
   /c

-- 
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] Building full racket 6.10 and up fails on Nix/MacOS

2018-02-23 Thread Matthew Flatt
At Thu, 22 Feb 2018 19:55:17 -0800 (PST), Claes Wallin wrote:
> I have got racket-minimal 6.12 into Nix, and it builds properly on 
> aarch64-linux and on x86_64-darwin (MacOS). AArch64 probably hasn't had a 
> racket before (I haven't checked), and Nix/MacOS has been without a working 
> racket since it was bumped to 6.10 last August (which broke it because 6.10 
> needed some previously unnecessary MacOS frameworks and nobody fixed that).
> 
> However, I can't get the full racket to build, because I'm getting errors 
> when it's parsing a scribble file:
> 
> raco setup: --- summary of errors ---
> raco setup: error: during building docs for 
> /racket-doc/scribblings/reference/reference.scrbl
> raco setup:   examples: exception raised in example
> raco setup: error: "bytes-convert: contract violation\n  expected: 
> bytes-converter?\n  given: #f\n  argument position: 1st\n  other 
> arguments...:\n   #\"ABCD\""

Maybe you already know this, but it's probably related to iconv. That
part of the documentation is trying to run an example

 (define convert (bytes-open-converter "UTF-8" "UTF-16"))
 (bytes-convert convert (bytes 65 66 67 68))

which will fail if the iconv installation doesn't recognize "UTF-8" or
"UTF-16".

-- 
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.