Re: [racket-users] Re: Autocomplete from a list

2019-02-17 Thread James Platt
On Feb 14, 2019, at 9:22 PM, Alex Harsanyi wrote:

> There are two solutions I can think of:
> 
> (1) derive combo-field% and override the on-popup method to construct the 
> choice menu dynamically based on what is selected in the combo box field.  
> This has a few disadvantages, namely (a) you have to produce the menu 
> immediately, so if you have to query a database for the list of items, there 
> might be a long delay for the menu to show up and (b) the menu will not 
> update when the user types more text in the field, instead it will have to be 
> closed and reopened.
> 
> (2) you can use a combination of text-field% and a list-box%, where the 
> callback on the text field will populate the list box with the filtered 
> contents.  The user would have to select an item from the list box, but this 
> can be populated in a separate thread to prevent the GUI from freezing up 
> during a database query.  It does not look as nice as GUI widgets from other 
> applications though...
> 
> Here is some example code for both options, including an animation of what it 
> looks like:
> 
> https://gist.github.com/alex-hhh/20f03dcf2f7f340d20b95cb36da39f61
> 
> Alex.

Thanks.  This is really helpful.  I will probably go with option (2) because 
it's more practical and this is a part of the application which will not be 
used frequently.

-- 
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] Racket 7.2 and racket2nix: when-to-compile logic

2019-02-17 Thread 韋嘉誠
I tried to bump the pinned Racket version in racket2nix from 7.1 to
7.2, and I ran into issues:

raco setup: 3 making: /nix
open-output-file: cannot open output file
  path: 
/nix/store/qal0s2mf9m1fdrpd1azpm5aiq6fwfdw1-racket-minimal-7.2-rackunit-lib-env/share/racket/pkgs/rackunit-lib/rackunit/private/compiled/tmp15504632011550463201383
  system error: Permission denied; errno=13
  compilation context...:
   
/nix/store/dzyn6syybdccglpdc8c4lh0j2abd37ar-racket2nix-stage0-env/share/racket/pkgs/nix/racket2nix-test.rkt
  context...:
   
/nix/store/pmg2cn7c7xc9kkg994m8b94zcf89ykmq-racket-minimal-7.2/share/racket/collects/racket/private/more-scheme.rkt:261:28
   
/nix/store/pmg2cn7c7xc9kkg994m8b94zcf89ykmq-racket-minimal-7.2/share/racket/collects/racket/file.rkt:236:0:
call-with-atomic-output-file22
   
/nix/store/pmg2cn7c7xc9kkg994m8b94zcf89ykmq-racket-minimal-7.2/share/racket/collects/compiler/private/cm-minimal.rkt:414:0:
compile-zo*58
   
/nix/store/pmg2cn7c7xc9kkg994m8b94zcf89ykmq-racket-minimal-7.2/share/racket/collects/compiler/private/cm-minimal.rkt:705:15
   
/nix/store/pmg2cn7c7xc9kkg994m8b94zcf89ykmq-racket-minimal-7.2/share/racket/collects/compiler/private/cm-minimal.rkt:677:0:
maybe-compile-zo77
   
/nix/store/pmg2cn7c7xc9kkg994m8b94zcf89ykmq-racket-minimal-7.2/share/racket/collects/compiler/private/cm-minimal.rkt:926:0:
compile-root89

What's happening here is that rackunit-lib is already installed and
compiled, and stored in the read-only Nix store. When racket2nix-test
dynamic-requires rackunit, compile-root decides that it needs to
compile it again, and tries to write to the read-only store.

The .rkt and .zo both have the timestamp 1, as in one second into the
Unix epoch, as do all the files in the store, for reproducibility.

I'm guessing there is some logic in cm-minimal.rkt that accidentally
changed from <= or > to < or >=, but I find the code a bit hard to
untangle at a glance, and I'm hoping that someone who actually touched
it will just go "Oh, that's right, that's this frob over here".

-- 
   /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] Spritely Golem: Secure, p2p distributable content for the fediverse

2019-02-17 Thread Christopher Lemmer Webber
The "fediverse" means the federated (decentralized) social web.
And Spritely, as I've said here recently, is a series of demos
and writeups which show how to "level up" the fediverse with
some new ideas to make it more powerful and resilient.

I just finished writing the documentation for Spritely Golem, the first
major of these demos:

  https://gitlab.com/spritely/golem/blob/master/README.org

A major problem on the federated social web (and actually web in
general) is that servers go down, and all the associated content goes
down with them.

There is also corresponding code, which I have tried to keep relatively
lean, approximately 500 lines for a proof of concept demo application.
And it's all in Racket!

  https://gitlab.com/spritely/golem/blob/master/golem.rkt

There's more of these to come.  I'm fairly happy with how the first one
has gone, however!

 - Chris

PS: In the future I will probably convert the documentation from
  org-mode to Scribble, but I have a bit of an easier time knocking out
  thoughts quickly in org-mode, and didn't want the demo to be held
  up by me having an internal debate of how to organize it all.

-- 
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] test user-interact function dont work

2019-02-17 Thread Joao Pedro Abreu De Souza
WOW.   I finish read the doc about #:final

That is so beatiful thing. Thank you to you three

Em dom, 17 de fev de 2019 às 22:18, Joao Pedro Abreu De Souza <
jp_ab...@id.uff.br> escreveu:

> Thanks for the feedback!
> I will study this code and make more functional
>
> Em dom, 17 de fev de 2019 22:13, Philip McGrath  escreveu:
>
>> Well, if you call `(exit 0)`, your Racket program really will exit with
>> code 0 without doing anything else: the function `exit` never returns, so,
>> in your case, `execute` never returns, `refine-main` never returns, and
>> Rackunit never gets a chance to look at any output it may or may not have
>> written.
>>
>> In my opinion, the best thing to do is not really to call `(exit 0)` from
>> `execute`. Here's one way to do it:
>> #lang racket
>>
>> (module+ test
>>   (require rackunit))
>>
>> ;; execute : string? -> (or/c #f (integer-in 0 255))
>> ;; Interprets the given string, perhaps causing side-effects.
>> ;; Returns either:
>> ;;   - an integer between 0 and 255, inclusive,
>> ;;   meaning the program should exit immediately with that code
>> ;;   - #f, meaning the program can accept more commands
>> (define (execute command)
>>   (match command
>> [(pregexp #px"^exit\\s+(\\d+)$"
>>   (list _ (app string->number code)))
>>  code]
>> [command
>>  (printf "command: ~v\n" command)
>>  #f]))
>>
>> ;; refine-main : -> (integer-in 0 255)
>> ;; Interprets commands from (current-input-port),
>> ;;   perhaps causing side-effects.
>> ;; Returns an exit code.
>> (define (refine-main)
>>   (for/last ([command (in-lines)])
>> (define code
>>   (execute command))
>> #:final code
>> (or code 0)))
>>
>> (module+ test
>>   (check-equal?
>>(with-output-to-string
>>  (λ ()
>>(with-input-from-string "exit 0"
>>  refine-main)))
>>""
>>"Consigo sair antes de comecar o tutorial"))
>>
>> When you really do want to exit as soon as `refine-main` returns, you can
>> do that by just writing `(exit (refine-main))`.
>>
>> Technically this is not your only option. In fact, you may be wondering,
>> if `exit` does what I say it does, why does your program not quit DrRacket?
>> In fact, `exit` really calls the current exit handler
>> , and DrRacket sets
>> the exit handler, among other things, to prevent the programs it runs from
>> interfering with each other or itself. You could likewise parameterize the
>> exit handler around your call to define-main for testing purposes.
>>
>> However, I think this is a good example of why side-effects (like
>> exiting) are less good for testing than returning values.
>>
>> -Philip
>>
>>
>> On Sun, Feb 17, 2019 at 6:44 PM Joao Pedro Abreu De Souza <
>> jp_ab...@id.uff.br> wrote:
>>
>>> (define (refine-main)
>>> (display next-string) ;;feito
>>> (set! next-command (shell-parser (my-read-line))) ;;TODO my-read-line
>>> (execute next-command) ;;TODO execute
>>> (refine-main)) ;;feito
>>>
>>> This is refine-main
>>>
>>> "shell-parser" is just a PEG-based parser, that return a struct
>>>
>>> "execute" in the case of reading a "exit 0" just call (exit 0)
>>>
>>>
>>> Em dom, 17 de fev de 2019 às 16:07, Joao Pedro Abreu De Souza <
>>> jp_ab...@id.uff.br> escreveu:
>>>
 Well, there's no imediate return, i need to type exit 0 to finally the
 test works

 I am using read-line to read input. Today later I will post more
 code(of refine-main).

 Thanks

 Em dom, 17 de fev de 2019 10:37, Greg Hendershott <
 greghendersh...@gmail.com escreveu:

> What does it do? Does `check-equal?` show a failure message? If so,
> what does it say?
>
>
> I don't know what `refine-main` does, but this simple version works
> for me:
>
> #lang racket
>
> (require rackunit)
>
> (define (refine-main)
>   (display (read-line))) ;echo
>
> (check-equal?
>  (with-output-to-string
>(lambda ()
>  (with-input-from-string "input"
>(lambda ()
>  (refine-main)
>  "input")
>
> On Sun, Feb 17, 2019 at 12:35 AM Joao Pedro Abreu De Souza
>  wrote:
> >
> > Hi everyone. I have a test of a user-related function that I don't
> can see why don't work :
> >
> > #lang racket
> >
> > (require rackunit)
> > (require "../../main.rkt")
> >
> >
> >
> >
> > (check-equal?
> > (with-output-to-string (lambda ()
> > (with-input-from-string
> > "exit 0"
> > (lambda () (refine-main)
> > ""
> > "Consigo sair antes de comecar o tutorial")
> >
> >
> >
> >
> > I think that this will call refine-main and, when refine-main do a
> readline, will receive "exit 0" as string, and when display something, 
> will
> appear as return of with-output-to-string, but this code don't work :(
> >
> > --
> > You 

Re: [racket-users] test user-interact function dont work

2019-02-17 Thread Joao Pedro Abreu De Souza
Thanks for the feedback!
I will study this code and make more functional

Em dom, 17 de fev de 2019 22:13, Philip McGrath  Well, if you call `(exit 0)`, your Racket program really will exit with
> code 0 without doing anything else: the function `exit` never returns, so,
> in your case, `execute` never returns, `refine-main` never returns, and
> Rackunit never gets a chance to look at any output it may or may not have
> written.
>
> In my opinion, the best thing to do is not really to call `(exit 0)` from
> `execute`. Here's one way to do it:
> #lang racket
>
> (module+ test
>   (require rackunit))
>
> ;; execute : string? -> (or/c #f (integer-in 0 255))
> ;; Interprets the given string, perhaps causing side-effects.
> ;; Returns either:
> ;;   - an integer between 0 and 255, inclusive,
> ;;   meaning the program should exit immediately with that code
> ;;   - #f, meaning the program can accept more commands
> (define (execute command)
>   (match command
> [(pregexp #px"^exit\\s+(\\d+)$"
>   (list _ (app string->number code)))
>  code]
> [command
>  (printf "command: ~v\n" command)
>  #f]))
>
> ;; refine-main : -> (integer-in 0 255)
> ;; Interprets commands from (current-input-port),
> ;;   perhaps causing side-effects.
> ;; Returns an exit code.
> (define (refine-main)
>   (for/last ([command (in-lines)])
> (define code
>   (execute command))
> #:final code
> (or code 0)))
>
> (module+ test
>   (check-equal?
>(with-output-to-string
>  (λ ()
>(with-input-from-string "exit 0"
>  refine-main)))
>""
>"Consigo sair antes de comecar o tutorial"))
>
> When you really do want to exit as soon as `refine-main` returns, you can
> do that by just writing `(exit (refine-main))`.
>
> Technically this is not your only option. In fact, you may be wondering,
> if `exit` does what I say it does, why does your program not quit DrRacket?
> In fact, `exit` really calls the current exit handler
> , and DrRacket sets
> the exit handler, among other things, to prevent the programs it runs from
> interfering with each other or itself. You could likewise parameterize the
> exit handler around your call to define-main for testing purposes.
>
> However, I think this is a good example of why side-effects (like exiting)
> are less good for testing than returning values.
>
> -Philip
>
>
> On Sun, Feb 17, 2019 at 6:44 PM Joao Pedro Abreu De Souza <
> jp_ab...@id.uff.br> wrote:
>
>> (define (refine-main)
>>  (display next-string) ;;feito
>>  (set! next-command (shell-parser (my-read-line))) ;;TODO my-read-line
>>  (execute next-command) ;;TODO execute
>>  (refine-main)) ;;feito
>>
>> This is refine-main
>>
>> "shell-parser" is just a PEG-based parser, that return a struct
>>
>> "execute" in the case of reading a "exit 0" just call (exit 0)
>>
>>
>> Em dom, 17 de fev de 2019 às 16:07, Joao Pedro Abreu De Souza <
>> jp_ab...@id.uff.br> escreveu:
>>
>>> Well, there's no imediate return, i need to type exit 0 to finally the
>>> test works
>>>
>>> I am using read-line to read input. Today later I will post more code(of
>>> refine-main).
>>>
>>> Thanks
>>>
>>> Em dom, 17 de fev de 2019 10:37, Greg Hendershott <
>>> greghendersh...@gmail.com escreveu:
>>>
 What does it do? Does `check-equal?` show a failure message? If so,
 what does it say?


 I don't know what `refine-main` does, but this simple version works for
 me:

 #lang racket

 (require rackunit)

 (define (refine-main)
   (display (read-line))) ;echo

 (check-equal?
  (with-output-to-string
(lambda ()
  (with-input-from-string "input"
(lambda ()
  (refine-main)
  "input")

 On Sun, Feb 17, 2019 at 12:35 AM Joao Pedro Abreu De Souza
  wrote:
 >
 > Hi everyone. I have a test of a user-related function that I don't
 can see why don't work :
 >
 > #lang racket
 >
 > (require rackunit)
 > (require "../../main.rkt")
 >
 >
 >
 >
 > (check-equal?
 > (with-output-to-string (lambda ()
 > (with-input-from-string
 > "exit 0"
 > (lambda () (refine-main)
 > ""
 > "Consigo sair antes de comecar o tutorial")
 >
 >
 >
 >
 > I think that this will call refine-main and, when refine-main do a
 readline, will receive "exit 0" as string, and when display something, will
 appear as return of with-output-to-string, but this code don't work :(
 >
 > --
 > 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 

Re: [racket-users] test user-interact function dont work

2019-02-17 Thread Philip McGrath
Well, if you call `(exit 0)`, your Racket program really will exit with
code 0 without doing anything else: the function `exit` never returns, so,
in your case, `execute` never returns, `refine-main` never returns, and
Rackunit never gets a chance to look at any output it may or may not have
written.

In my opinion, the best thing to do is not really to call `(exit 0)` from
`execute`. Here's one way to do it:
#lang racket

(module+ test
  (require rackunit))

;; execute : string? -> (or/c #f (integer-in 0 255))
;; Interprets the given string, perhaps causing side-effects.
;; Returns either:
;;   - an integer between 0 and 255, inclusive,
;;   meaning the program should exit immediately with that code
;;   - #f, meaning the program can accept more commands
(define (execute command)
  (match command
[(pregexp #px"^exit\\s+(\\d+)$"
  (list _ (app string->number code)))
 code]
[command
 (printf "command: ~v\n" command)
 #f]))

;; refine-main : -> (integer-in 0 255)
;; Interprets commands from (current-input-port),
;;   perhaps causing side-effects.
;; Returns an exit code.
(define (refine-main)
  (for/last ([command (in-lines)])
(define code
  (execute command))
#:final code
(or code 0)))

(module+ test
  (check-equal?
   (with-output-to-string
 (λ ()
   (with-input-from-string "exit 0"
 refine-main)))
   ""
   "Consigo sair antes de comecar o tutorial"))

When you really do want to exit as soon as `refine-main` returns, you can
do that by just writing `(exit (refine-main))`.

Technically this is not your only option. In fact, you may be wondering, if
`exit` does what I say it does, why does your program not quit DrRacket? In
fact, `exit` really calls the current exit handler
, and DrRacket sets
the exit handler, among other things, to prevent the programs it runs from
interfering with each other or itself. You could likewise parameterize the
exit handler around your call to define-main for testing purposes.

However, I think this is a good example of why side-effects (like exiting)
are less good for testing than returning values.

-Philip


On Sun, Feb 17, 2019 at 6:44 PM Joao Pedro Abreu De Souza <
jp_ab...@id.uff.br> wrote:

> (define (refine-main)
>   (display next-string) ;;feito
>   (set! next-command (shell-parser (my-read-line))) ;;TODO my-read-line
>   (execute next-command) ;;TODO execute
>   (refine-main)) ;;feito
>
> This is refine-main
>
> "shell-parser" is just a PEG-based parser, that return a struct
>
> "execute" in the case of reading a "exit 0" just call (exit 0)
>
>
> Em dom, 17 de fev de 2019 às 16:07, Joao Pedro Abreu De Souza <
> jp_ab...@id.uff.br> escreveu:
>
>> Well, there's no imediate return, i need to type exit 0 to finally the
>> test works
>>
>> I am using read-line to read input. Today later I will post more code(of
>> refine-main).
>>
>> Thanks
>>
>> Em dom, 17 de fev de 2019 10:37, Greg Hendershott <
>> greghendersh...@gmail.com escreveu:
>>
>>> What does it do? Does `check-equal?` show a failure message? If so,
>>> what does it say?
>>>
>>>
>>> I don't know what `refine-main` does, but this simple version works for
>>> me:
>>>
>>> #lang racket
>>>
>>> (require rackunit)
>>>
>>> (define (refine-main)
>>>   (display (read-line))) ;echo
>>>
>>> (check-equal?
>>>  (with-output-to-string
>>>(lambda ()
>>>  (with-input-from-string "input"
>>>(lambda ()
>>>  (refine-main)
>>>  "input")
>>>
>>> On Sun, Feb 17, 2019 at 12:35 AM Joao Pedro Abreu De Souza
>>>  wrote:
>>> >
>>> > Hi everyone. I have a test of a user-related function that I don't can
>>> see why don't work :
>>> >
>>> > #lang racket
>>> >
>>> > (require rackunit)
>>> > (require "../../main.rkt")
>>> >
>>> >
>>> >
>>> >
>>> > (check-equal?
>>> > (with-output-to-string (lambda ()
>>> > (with-input-from-string
>>> > "exit 0"
>>> > (lambda () (refine-main)
>>> > ""
>>> > "Consigo sair antes de comecar o tutorial")
>>> >
>>> >
>>> >
>>> >
>>> > I think that this will call refine-main and, when refine-main do a
>>> readline, will receive "exit 0" as string, and when display something, will
>>> appear as return of with-output-to-string, but this code don't work :(
>>> >
>>> > --
>>> > 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 

Re: [racket-users] test user-interact function dont work

2019-02-17 Thread Joao Pedro Abreu De Souza
Thanks a lot.

Sorry about the simple error.



Em dom, 17 de fev de 2019 22:06, Matthias Felleisen 
>
> On Feb 17, 2019, at 6:44 PM, Joao Pedro Abreu De Souza 
> wrote:
>
> (check-equal?
>  (with-output-to-string
>(lambda ()
>  (with-input-from-string "input"
>(lambda ()
>  (refine-main)
>
>
>
>
> Your mistake is in the above line. You want to write refine-main not
> (refine-main).
>
>
>  "input")
>
>
>

-- 
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] test user-interact function dont work

2019-02-17 Thread Matthias Felleisen


> On Feb 17, 2019, at 6:44 PM, Joao Pedro Abreu De Souza  
> wrote:
> 
> (check-equal?
>  (with-output-to-string
>(lambda ()
>  (with-input-from-string "input"
>(lambda ()
>  (refine-main)



Your mistake is in the above line. You want to write refine-main not 
(refine-main). 


>  "input")

-- 
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] test user-interact function dont work

2019-02-17 Thread Joao Pedro Abreu De Souza
(define (refine-main)
(display next-string) ;;feito
(set! next-command (shell-parser (my-read-line))) ;;TODO my-read-line
(execute next-command) ;;TODO execute
(refine-main)) ;;feito

This is refine-main

"shell-parser" is just a PEG-based parser, that return a struct

"execute" in the case of reading a "exit 0" just call (exit 0)


Em dom, 17 de fev de 2019 às 16:07, Joao Pedro Abreu De Souza <
jp_ab...@id.uff.br> escreveu:

> Well, there's no imediate return, i need to type exit 0 to finally the
> test works
>
> I am using read-line to read input. Today later I will post more code(of
> refine-main).
>
> Thanks
>
> Em dom, 17 de fev de 2019 10:37, Greg Hendershott <
> greghendersh...@gmail.com escreveu:
>
>> What does it do? Does `check-equal?` show a failure message? If so,
>> what does it say?
>>
>>
>> I don't know what `refine-main` does, but this simple version works for
>> me:
>>
>> #lang racket
>>
>> (require rackunit)
>>
>> (define (refine-main)
>>   (display (read-line))) ;echo
>>
>> (check-equal?
>>  (with-output-to-string
>>(lambda ()
>>  (with-input-from-string "input"
>>(lambda ()
>>  (refine-main)
>>  "input")
>>
>> On Sun, Feb 17, 2019 at 12:35 AM Joao Pedro Abreu De Souza
>>  wrote:
>> >
>> > Hi everyone. I have a test of a user-related function that I don't can
>> see why don't work :
>> >
>> > #lang racket
>> >
>> > (require rackunit)
>> > (require "../../main.rkt")
>> >
>> >
>> >
>> >
>> > (check-equal?
>> > (with-output-to-string (lambda ()
>> > (with-input-from-string
>> > "exit 0"
>> > (lambda () (refine-main)
>> > ""
>> > "Consigo sair antes de comecar o tutorial")
>> >
>> >
>> >
>> >
>> > I think that this will call refine-main and, when refine-main do a
>> readline, will receive "exit 0" as string, and when display something, will
>> appear as return of with-output-to-string, but this code don't work :(
>> >
>> > --
>> > 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] Python's append vs Racket's append and helping novices understand the implications

2019-02-17 Thread Will Jukes
I went ahead and added some info on the difference between Racket and
Python appends to https://github.com/racket/racket/wiki/Python-to-Racket .
Sorry to whoever for the salvo of poorly documented revisions.

On Sun, Feb 17, 2019 at 12:21 AM David Van Horn  wrote:

> I've updated the docs to get to the point faster with some early examples.
>
> http://dvanhorn.github.io/ralist/
>
> David
>
>
> On Sat, Feb 16, 2019 at 5:21 PM John Clements 
> wrote:
>
>> I struggled with whether to send that message… I saw the name, “random
>> access lists”, thought, “hmm, I wonder what that would like”, and clicked
>> on the link. I wound up reading a bit about whether I should use (first
>> impresssion) superficial or in-depth contracts, and ran out of steam pretty
>> quickly. Ultimately, of course, the real issue is that your documentation
>> wasn’t designed to help python programmers jump into their first experience
>> with Racket, but a link to your documentation has essentially just made you
>> an involuntary ambassador.
>>
>>
>> John
>>
>> > On Feb 16, 2019, at 14:00, David Van Horn  wrote:
>> >
>> > There are several examples for every function provided by the ralist
>> library.  (And it's almost verbatim what's in the Racket reference for
>> pairs and lists.)
>> >
>> > But... I can add some early examples.  No problem.
>> >
>> > David
>> >
>> > On Sat, Feb 16, 2019, 4:00 PM John Clements 
>> wrote:
>> > The pointer to RaLists would be much more enticing if we could convince
>> David Van Horn to begin his documentation with a couple of small examples….
>> >
>> > John
>> >
>> > > On Feb 13, 2019, at 14:35, Stephen De Gabrielle <
>> spdegabrie...@gmail.com> wrote:
>> > >
>> > > Thanks
>> > >
>> > > I should note that anyone with a GitHub account can edit
>> https://github.com/racket/racket/wiki/Python-to-Racket
>> > >
>> > > S.
>> > >
>> > > On Wed, 13 Feb 2019 at 21:26, Matthias Felleisen <
>> matth...@felleisen.org> wrote:
>> > >
>> > > Not until there’s demand. I think we do see demand for Python
>> transfers.
>> > >
>> > >
>> > >
>> > > > On Feb 13, 2019, at 3:11 PM, Stephen De Gabrielle <
>> spdegabrie...@gmail.com> wrote:
>> > > >
>> > > > Should there be similar pages for Javascript, Java,C#, C/C++, Ruby,
>> PHP, Visual Basic, Scratch and Haskell?
>> > > >
>> > > > S.
>> > > >
>> > > > On Wed, Feb 13, 2019 at 8:03 PM Stephen De Gabrielle <
>> spdegabrie...@gmail.com> wrote:
>> > > > I created a DRAFT page on the Racket GitHub wiki:
>> > > >   https://github.com/racket/racket/wiki/Python-to-Racket
>> > > > It links to a 'Choosing a data structure' page
>> https://github.com/racket/racket/wiki/Choosing-a-data-structure
>> > > > - this just as copy of the table created by Jens Axel Søgaard at:
>> https://stackoverflow.com/questions/27584416/in-racket-what-is-the-advantage-of-lists-over-vectors/27589146#27589146
>> )
>> > > >
>> > > > Please edit/delete as you see fit
>> > > >
>> > > > Kind regards
>> > > > Stephen
>> > > >
>> > > >
>> > > > On Tue, Feb 12, 2019 at 5:20 PM Matthias Felleisen <
>> matth...@felleisen.org> wrote:
>> > > >
>> > > > This is perfect! Thanks — Matthias
>> > > >
>> > > >
>> > > >
>> > > >
>> > > > > On Feb 11, 2019, at 11:04 PM, Claes Wallin (韋嘉誠) <
>> cla...@gmail.com> wrote:
>> > > > >
>> > > > > For anyone creating such a web page for Python to Racket
>> specifically,
>> > > > > there is probably a great deal of inspiration, and reminders of
>> > > > > stumbling blocks, to be found in Arne Babenhauserheide's
>> > > > > https://www.draketo.de/py2guile book (available online for free)
>> about
>> > > > > going from Python to Guile Scheme.
>> > > > >
>> > > > > --
>> > > > >   /c
>> > > > >
>> > > > > On Sun, Feb 3, 2019 at 7:00 AM Matthias Felleisen
>> > > > >  wrote:
>> > > > >> Racket needs *you*. Please.
>> > > > >>
>> > > > >> The proper approach is to have short pages for different
>> language immigration groups: Python and R come to mind as obvious examples
>> but I am sure there are others.
>> > > > >>
>> > > > >> What I mean is we need help and *you* can help. Let me explain
>> it with the Python example:
>> > > > >>
>> > > > >> 1. Set up a page (wiki?) called “From Python to Racket”
>> > > > >>
>> > > > >> 2. Create two sections that are immediately visible from the top:
>> > > > >>
>> > > > >>— idioms
>> > > > >>— performance pitfalls
>> > > > >>
>> > > > >> 3. In the specific case of Python, the second subsection needs
>> to start with a subsection on
>> > > > >>
>> > > > >>— Python Lists aren’t Racket Lists
>> > > > >>— then point to data/ralis and show how to transliterate
>> the loop/append example like this
>> > > > >>— optionally also show the more native Racket idiom
>> > > > >>
>> > > > >> 4. When anyone observers another blog/social media/whatever post
>> on Racket is slow because I come from Python,
>> > > > >>
>> > > > >>(a) point the posters to the page  or
>> > > > >>(b) if it is a new case, write a 

Re: [racket-users] Running raco setup from within DrRacket?

2019-02-17 Thread Philip McGrath
I've written and use a `find-executable-path*` inspired by Emacs'
`exec-path-from-shell` (which I'm pretty sure I learned about from Greg on
this list) that gives the same API as `find-executable-path`, but with a
special case for Mac OS:
https://docs.racket-lang.org/adjutor/Experimental.html#%28part._.Extensions_to_find-executable-path%29

I've documented it as "experimental" because I continue to revise the
implementation to be more robust and handle more odd cases, but I rely on
the basic functionality of a `find-executable-path` work-alike that works
for Mac OS GUI apps, and that part isn't going to change.

(Though in this case I think a PR to update the implementation and/or docs
of `setup/setup` to support the full functionality of `raco setup` would be
the best thing to do.)

-Philip


On Sat, Feb 16, 2019 at 10:14 PM Greg Hendershott 
wrote:

> p.s. If you wanted to do a general thing, for DrRacket, this is what I
> was referring to. The README is probably enough of a hint, you don't
> need to read the Emacs Lisp. :)
>
> https://github.com/purcell/exec-path-from-shell
>
> On Sat, Feb 16, 2019 at 10:07 PM Greg Hendershott
>  wrote:
> >
> > From unsophisticated searching the source, it looks like the code to
> > implement deps checking is in setup/private/pkg-deps.rkt -- "private"
> > meaning you're not supposed to use it directly.
> >
> > It seems to be called from the `setup-core` function provided by
> > (non-private) setup/setup-core.rkt. That seems to be controlled by a
> > variety of parameters, including `check-dependencies`. You could
> > probably figure out which ones to set, to approximate `raco setup
> > ` as opposed to `raco setup` everything.
> >
> > Or...  system* raco is sounding nicer. But how to find its path.
> >
> > Are you on macOS?  If so, that's probably why raco isn't on the PATH.
> > Every OS has odd things. Windows has it's share. macOS has one, which
> > is that GUI apps' PATH doesn't inherit what you see in bash. (That's
> > why emacs has exec-path-from-shell.)
> >
> > I'd suggest (find-system-path 'exec-file), which would be great in
> > command-line racket. But in DrR that's something like
> > "/Applications/Racket 7.0/DrRacket.app/Contents/MacOS/DrRacket".  Well
> > I suppose you could do something like:
> >
> >(build-path (find-system-path 'exec-file) 'up 'up 'up 'up "racket"
> > "bin" "raco")
> >
> > On Sat, Feb 16, 2019 at 12:34 AM  wrote:
> > >
> > > Using setup/setup works partially, but it doesn't seem to support
> package dependency checking (and the #:pkgs keyword argument isn't
> documented). I can't seem to find any programmatic alternative to the
> --check-pkg-deps and --unused-pkg-deps flags.
> > >
> > > On Friday, February 15, 2019 at 8:35:17 PM UTC-8, Matthias Felleisen
> wrote:
> > >>
> > >> See
> https://docs.racket-lang.org/raco/setup-plt-plt.html?q=setup#%28def._%28%28lib._setup%2Fsetup..rkt%29._setup%29%29
> > >>
> > >> (require setup/setup)
> > >>
> > >> I think that’s what you want — Matthias
> > >
> > > --
> > > 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] test user-interact function dont work

2019-02-17 Thread Joao Pedro Abreu De Souza
Well, there's no imediate return, i need to type exit 0 to finally the test
works

I am using read-line to read input. Today later I will post more code(of
refine-main).

Thanks

Em dom, 17 de fev de 2019 10:37, Greg Hendershott  What does it do? Does `check-equal?` show a failure message? If so,
> what does it say?
>
>
> I don't know what `refine-main` does, but this simple version works for me:
>
> #lang racket
>
> (require rackunit)
>
> (define (refine-main)
>   (display (read-line))) ;echo
>
> (check-equal?
>  (with-output-to-string
>(lambda ()
>  (with-input-from-string "input"
>(lambda ()
>  (refine-main)
>  "input")
>
> On Sun, Feb 17, 2019 at 12:35 AM Joao Pedro Abreu De Souza
>  wrote:
> >
> > Hi everyone. I have a test of a user-related function that I don't can
> see why don't work :
> >
> > #lang racket
> >
> > (require rackunit)
> > (require "../../main.rkt")
> >
> >
> >
> >
> > (check-equal?
> > (with-output-to-string (lambda ()
> > (with-input-from-string
> > "exit 0"
> > (lambda () (refine-main)
> > ""
> > "Consigo sair antes de comecar o tutorial")
> >
> >
> >
> >
> > I think that this will call refine-main and, when refine-main do a
> readline, will receive "exit 0" as string, and when display something, will
> appear as return of with-output-to-string, but this code don't work :(
> >
> > --
> > 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] test user-interact function dont work

2019-02-17 Thread Greg Hendershott
What does it do? Does `check-equal?` show a failure message? If so,
what does it say?


I don't know what `refine-main` does, but this simple version works for me:

#lang racket

(require rackunit)

(define (refine-main)
  (display (read-line))) ;echo

(check-equal?
 (with-output-to-string
   (lambda ()
 (with-input-from-string "input"
   (lambda ()
 (refine-main)
 "input")

On Sun, Feb 17, 2019 at 12:35 AM Joao Pedro Abreu De Souza
 wrote:
>
> Hi everyone. I have a test of a user-related function that I don't can see 
> why don't work :
>
> #lang racket
>
> (require rackunit)
> (require "../../main.rkt")
>
>
>
>
> (check-equal?
> (with-output-to-string (lambda ()
> (with-input-from-string
> "exit 0"
> (lambda () (refine-main)
> ""
> "Consigo sair antes de comecar o tutorial")
>
>
>
>
> I think that this will call refine-main and, when refine-main do a readline, 
> will receive "exit 0" as string, and when display something, will appear as 
> return of with-output-to-string, but this code don't work :(
>
> --
> 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.