Re: [racket-users] Why are these @defthing blocks typeset incorrectly?

2020-09-23 Thread Sorawee Porncharoenwase
Caution: I haven’t tried your code yet.

I think Scribble uses source location equipped with syntax objects to
figure out spacing. Since you generate stuff on the fly, there’s no source
location, so the rendered text is screwed up.

An idea I have (which might not work) is to use write / pretty-write on the
generated code to a string port, and then read-syntax it back. That way,
you get the source locations correctly.

On Wed, Sep 23, 2020 at 4:17 PM Sage Gerard  wrote:

> I attached an image showing the rendered output of
> https://github.com/zyrolasting/xiden/blob/master/docs/reference/settings.scrbl#L48
>
> I create an application to `(defthing)` as a datum due to circumstances
> in the surrounding code. The hacky part being `get-contract-datum`, which
> tries to produce a datum usable as a contract expression. I'm assuming that
> this leaves no whitespace to preserve, so how do I modify a syntax object
> to include space in desired spots?
>
> *~slg*
>
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/ulye9ZNaZmcspsE7fqy6ctobuGcF21jQvGQ4-PG2Eynt09KBU9AbF_kP9UZ_OgouhcvBOF8JLbaCJpVbnve-6RF_E752tVqp-xR9Va3oRsE%3D%40sagegerard.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegt9o08A1PV_f%3DKg2G_%3DAVYor5M%2BWm5pRJXA0Zdi_%2BMqHQ%40mail.gmail.com.


Re: [racket-users] package manager woes on Windows 10?

2020-09-14 Thread Sorawee Porncharoenwase
Can you explain why you are not sure? Under what circumstances do you think
the current 'single style behavior is useful?

We can add 'single-no-return (though I dislike it because 'single means no
return already!) and change existing places that use 'single. However,
without switching the default style from 'single to 'single-no-return,
people will make mistakes again in the future. But if we will change the
default style to 'single-no-return too, why don't we simply directly change
the behavior 'single?

On Sun, Sep 13, 2020 at 1:36 PM Robby Findler 
wrote:

> I'm not sure. I would probably add a 'single-no-return style and then grep
> the codebase for places that use 'single and change them (as appropriate).
>
> Robby
>
>
> On Sun, Sep 13, 2020 at 3:15 PM Sorawee Porncharoenwase <
> sorawee.pw...@gmail.com> wrote:
>
>> I meant, wouldn’t it be better to fix text-field% itself, instead of
>> only some instances of it? Sorry if that was confusing.
>>
>> On Sun, Sep 13, 2020 at 1:12 PM Sorawee Porncharoenwase <
>> sorawee.pw...@gmail.com> wrote:
>>
>>> Should the fix apply to all 'single styled text-field%
>>> <https://docs.racket-lang.org/gui/text-field_.html> too?
>>>
>>> On Sun, Sep 13, 2020 at 7:50 AM Robby Findler 
>>> wrote:
>>>
>>>> Yea, I agree. I'd made that change locally but hadn't pushed because I
>>>> couldn't make the bad behavior happen reliably. Perhaps that lack shouldn't
>>>> stop us! Pushed now.
>>>>
>>>> Robby
>>>>
>>>>
>>>> On Sat, Sep 12, 2020 at 11:15 PM jackh...@gmail.com <
>>>> jackhfi...@gmail.com> wrote:
>>>>
>>>>> Could we make the "do what I mean" box just automatically strip any
>>>>> newlines pasted into it? It seems sensible to me to require that it only 
>>>>> be
>>>>> a single line input.
>>>>>
>>>>> On Friday, September 11, 2020 at 6:22:59 AM UTC-7
>>>>> hen...@topoi.pooq.com wrote:
>>>>>
>>>>>> On Thu, Sep 10, 2020 at 10:27:39AM -0400, George Neuner wrote:
>>>>>> >
>>>>>> >
>>>>>> > On 9/10/2020 10:06 AM, Philip McGrath wrote:
>>>>>> > > Also, this is happening over encrypted HTTPS: no one is sniffing
>>>>>> the
>>>>>> > > User-Agent header.
>>>>>> >
>>>>>> > While it may not be the issue here, you need to understand that
>>>>>> appliance
>>>>>> > firewalls CAN and routinely DO examine data inside encrypted
>>>>>> connections.
>>>>>>
>>>>>> Using man-in-the-middle attacks?
>>>>>>
>>>>>> -- hendrik
>>>>>>
>>>>> --
>>>>> 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.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/racket-users/84b16cf0-7837-4d54-9423-c1286f5e2b7an%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/racket-users/84b16cf0-7837-4d54-9423-c1286f5e2b7an%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>> --
>>>> 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.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/racket-users/CAL3TdON46%3DPR6_-iyppSMLsfEvNEveq3uGu64gQ3Lu1or7QgNw%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/racket-users/CAL3TdON46%3DPR6_-iyppSMLsfEvNEveq3uGu64gQ3Lu1or7QgNw%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CADcuegtFzzeErTTqi3m9Hyr%2Bu1m8YEo0cnAEw2onhKXGnTzHOg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CADcuegtFzzeErTTqi3m9Hyr%2Bu1m8YEo0cnAEw2onhKXGnTzHOg%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsBYxxQJgjSz9ohS6fiRHaOXiO_Bx%3D_JoiiAvTQMHWH6A%40mail.gmail.com.


Re: [racket-users] package manager woes on Windows 10?

2020-09-13 Thread Sorawee Porncharoenwase
I meant, wouldn’t it be better to fix text-field% itself, instead of only
some instances of it? Sorry if that was confusing.

On Sun, Sep 13, 2020 at 1:12 PM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> Should the fix apply to all 'single styled text-field%
> <https://docs.racket-lang.org/gui/text-field_.html> too?
>
> On Sun, Sep 13, 2020 at 7:50 AM Robby Findler 
> wrote:
>
>> Yea, I agree. I'd made that change locally but hadn't pushed because I
>> couldn't make the bad behavior happen reliably. Perhaps that lack shouldn't
>> stop us! Pushed now.
>>
>> Robby
>>
>>
>> On Sat, Sep 12, 2020 at 11:15 PM jackh...@gmail.com 
>> wrote:
>>
>>> Could we make the "do what I mean" box just automatically strip any
>>> newlines pasted into it? It seems sensible to me to require that it only be
>>> a single line input.
>>>
>>> On Friday, September 11, 2020 at 6:22:59 AM UTC-7 hen...@topoi.pooq.com
>>> wrote:
>>>
>>>> On Thu, Sep 10, 2020 at 10:27:39AM -0400, George Neuner wrote:
>>>> >
>>>> >
>>>> > On 9/10/2020 10:06 AM, Philip McGrath wrote:
>>>> > > Also, this is happening over encrypted HTTPS: no one is sniffing
>>>> the
>>>> > > User-Agent header.
>>>> >
>>>> > While it may not be the issue here, you need to understand that
>>>> appliance
>>>> > firewalls CAN and routinely DO examine data inside encrypted
>>>> connections.
>>>>
>>>> Using man-in-the-middle attacks?
>>>>
>>>> -- hendrik
>>>>
>>> --
>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/84b16cf0-7837-4d54-9423-c1286f5e2b7an%40googlegroups.com
>>> <https://groups.google.com/d/msgid/racket-users/84b16cf0-7837-4d54-9423-c1286f5e2b7an%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAL3TdON46%3DPR6_-iyppSMLsfEvNEveq3uGu64gQ3Lu1or7QgNw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAL3TdON46%3DPR6_-iyppSMLsfEvNEveq3uGu64gQ3Lu1or7QgNw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtFzzeErTTqi3m9Hyr%2Bu1m8YEo0cnAEw2onhKXGnTzHOg%40mail.gmail.com.


Re: [racket-users] package manager woes on Windows 10?

2020-09-13 Thread Sorawee Porncharoenwase
Should the fix apply to all 'single styled text-field%
 too?

On Sun, Sep 13, 2020 at 7:50 AM Robby Findler 
wrote:

> Yea, I agree. I'd made that change locally but hadn't pushed because I
> couldn't make the bad behavior happen reliably. Perhaps that lack shouldn't
> stop us! Pushed now.
>
> Robby
>
>
> On Sat, Sep 12, 2020 at 11:15 PM jackh...@gmail.com 
> wrote:
>
>> Could we make the "do what I mean" box just automatically strip any
>> newlines pasted into it? It seems sensible to me to require that it only be
>> a single line input.
>>
>> On Friday, September 11, 2020 at 6:22:59 AM UTC-7 hen...@topoi.pooq.com
>> wrote:
>>
>>> On Thu, Sep 10, 2020 at 10:27:39AM -0400, George Neuner wrote:
>>> >
>>> >
>>> > On 9/10/2020 10:06 AM, Philip McGrath wrote:
>>> > > Also, this is happening over encrypted HTTPS: no one is sniffing the
>>> > > User-Agent header.
>>> >
>>> > While it may not be the issue here, you need to understand that
>>> appliance
>>> > firewalls CAN and routinely DO examine data inside encrypted
>>> connections.
>>>
>>> Using man-in-the-middle attacks?
>>>
>>> -- hendrik
>>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/84b16cf0-7837-4d54-9423-c1286f5e2b7an%40googlegroups.com
>> 
>> .
>>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAL3TdON46%3DPR6_-iyppSMLsfEvNEveq3uGu64gQ3Lu1or7QgNw%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsQOyPfir8M1GZ5VsSm_9JvCwQeLXhW3X8F78cPVOmLHQ%40mail.gmail.com.


Re: [racket-users] -i as an identifier

2020-09-10 Thread Sorawee Porncharoenwase
I think you read the doc correctly, but there are programs that use +i and
-i, so it's unclear if fixing the reader is desirable. Perhaps the
documentation should be adjusted instead.

Here’s an example of how people use +i and -i:
https://github.com/mbutterick/aoc-racket/blob/master/2019/03.rkt#L20

On Thu, Sep 10, 2020 at 3:40 PM Sage Gerard  wrote:

> It looks like -i cannot be used as an identifier because it evaluates to
> the complex number 0-1i. So in the v7.8 REPL, (define -i "foo") fails. I
> noticed this when trying to map CLI flag strings to identifiers. -i was the
> only one in the set to fall over.
>
> In the Reading Numbers section of the reference, it looks like a digit
> sequence is required before "i" for both the inexact complex and exact
> complex productions. That makes sense to me because it doesn't seem right
> to assume that an empty string corresponds to -1 like it seems to do here.
> Maybe I'm misreading the grammar?
>
> Before I open a GitHub issue, I just need to know if any part of this is
> unintentional.
>
> *~slg*
>
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/s9pqyR4hlcTjjfYYHeNqnVsDKbU138qdy-L0rIquew86_TtTNX4SlRRw2r4Yv2-0szTzJiCmyu4QDmwwfPD863HHRO6oZpT9x1V8GfCmM3E%3D%40sagegerard.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcueguL5rk5jaTsBqeuucCOuHC7NYanw-iA0CoCuBbjSC4TBA%40mail.gmail.com.


Re: [racket-users] Making expanded bindings visible in top-level

2020-09-06 Thread Sorawee Porncharoenwase
I think it’s only enough to fabricate the #%info-* identifiers. For
example, in the file you linked above, you can add:

[#%info-domain (datum->syntax stx '#%info-domain)]

to with-syntax, and provided that you provide #%top-interaction, you should
be able to use #%info-domain in the REPL.

On Sun, Sep 6, 2020 at 5:53 PM Sage Gerard  wrote:

> I'm writing a variant of setup/infotab
> 
> to allow `#%top-interaction' plus some other bindings of my choice. But
> when I create a evaluator in the context of such a module, `#%info-domain'
> and `#%info-lookup' are not bound. I'd like to use a REPL to access these
> procedures.
>
> Is there a cleaner way to make the #%info-* procedures use the same
> lexical context without forcing each through syntax->datum and
> datum->syntax?
>
> *~slg*
>
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/HXI6OiTdOS3GiXhHp6tG2xC6vTPzNPublNDjosc_vQfNDtIrU1XjmheFOPoQLGQ4rmzmgOzbkRMJ-p1FvZngtIjLU-JAfVKHS0ZE6_wUstc%3D%40sagegerard.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegv3rvqkohBNB9SRP5ZEVpyfzx8_eeRbFy694FMEB-ph7w%40mail.gmail.com.


Re: [racket-users] Re: provide-if-not-defined

2020-09-03 Thread Sorawee Porncharoenwase
I want to propose another interface:

(my-provide
  #:default + - *
  #:override
  [my-+ +])

which expands to:

(provide - *)
(provide (rename-out [my-+ +]))

and checks that + must be in the #:default section (because we are
overriding it, it’d better already exist).

More generally:

(my-provide
  #:default  ...
  #:override
  [ ] ...)

expands to:

(provide (rename-out [ ] ...))
(provide  ...)

where ids* = ids - rhs, and with a check that rhs ⊆ ids
On Thu, Sep 3, 2020 at 10:12 AM Shriram Krishnamurthi 
wrote:

> Ah, I see, that's a nice idea!
>
> One problem is have well over a dozen of these that I want to
> pass-through, but I suppose I could write a
>
> (rename-prefix   ...)
>
> that turns into a bunch of define's. I'd have to be careful to not miss
> any.
>
> Another issue is that I have to redefine some of the language-definition
> primitives (like #%app), which will definitely make the module far more
> tricky.
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAJUf2yQY-RVM%2BsH8%2BnHzFJFPwm5p5%3DGq%2BHGj42Ao7QQ0wJqnrQ%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvFaeSFFQspm8NwLsxbR3Bb-PYzwE4q0B5vwH%2B%3DVxBjxw%40mail.gmail.com.


Re: [racket-users] provide-if-not-defined

2020-09-02 Thread Sorawee Porncharoenwase
IIUC, that’s not what Shriram wants. He wants a kind of interface /
contract for a module (that it must export certain identifiers). The
solution that you posted makes the module satisfy the interface by
construction, but it creates another problem which is that he might
accidentally export a wrong identifier.

Wouldn’t create a test file suffice for detecting the original problem that
Shriram has, though? Something like this:

;; tester.rkt
#lang racket/base

(define required-ids '(+ - *))
(define files '("test-a.rkt" "test-b.rkt" "test-c.rkt"))

(define (error-handler e)
  ((error-display-handler) (exn-message e) e))

(for ([mod (in-list files)])
  (parameterize ([current-namespace (make-base-namespace)])
(with-handlers ([exn:fail:syntax? error-handler])
  (expand
   `(module test racket/base
  (require (only-in ,mod ,@required-ids)))

;; test-a.rkt
#lang racket/base
(provide + *)

;; test-b.rkt
#lang racket/base

(provide (rename-out [my-+ +]) - *)

(define (my-+ a b)
  (+ a b 1))

;; test-c.rkt
#lang racket/base
(provide + -)

which produces:

only-in: identifier `-' not included in nested require spec in: "test-a.rkt"
only-in: identifier `*' not included in nested require spec in: "test-c.rkt"



On Wed, Sep 2, 2020, 1:12 PM Michael MacLeod 
wrote:

> Does this example work: http://pasterack.org/pastes/95923?
>
> `if-not-defined` is written as a provide transformer which uses
> `syntax-local-module-defined-identifiers` to get the list of phase-0
> identifiers defined in the module.
>
> Best,
> Michael
>
> [code also pasted below]:
>
> #lang racket/base
>
> (module implementation racket/base
>   (provide (if-not-defined "^my-"
>+ ; my-+ from this module
>- ; - from racket/base
>* ; my-* from this module
>/ ; / from racket/base
>))
>
>   (require (for-syntax racket/base
>racket/provide-transform
>syntax/parse))
>
>   (define-syntax if-not-defined
> (make-provide-transformer
>  (lambda (stx modes)
>(syntax-parse stx
>  [(_ pattern:string var:id ...)
>   (define regex (regexp (syntax-e #'pattern)))
>   (define phase-0-ids
> (hash-ref (syntax-local-module-defined-identifiers) 0))
>   (define (find-id+sym v)
> (define v-string (symbol->string (syntax-e v)))
> (for/or ([id (in-list phase-0-ids)])
>   (define id-string (symbol->string (syntax-e id)))
>   (define maybe-match
> (and (string=? v-string
>(regexp-replace regex id-string ""))
>  (not (string=? id-string v-string
>   (if maybe-match
>   (cons id
> (string->symbol v-string))
>   #f)))
>   (for/fold ([exports '()])
> ([v (in-list (syntax->list #'(var ...)))])
> (define maybe-id+sym (find-id+sym v))
> (cond [maybe-id+sym
>(cons (export (car maybe-id+sym)
>  (cdr maybe-id+sym)
>  0
>  #f
>  (car maybe-id+sym))
>  exports)]
>   [else
>(cons (export v
>  (syntax-e v)
>  0
>  #f
>  v)
>  exports)]))]
>
>   (define (my-+ a b)
> (+ a b 100))
>
>   (define (my-* a b)
> (* a b 100)))
>
> (require 'implementation rackunit)
>
> (check-equal? (+ 2 3) 105)
> (check-equal? (- 2 3) -1)
> (check-equal? (* 2 3) 600)
> (check-equal? (/ 2 3) 2/3)
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CACehHmBAd%2BhNHsO3CkthY5ojuZ%2B_Rgj87rKbQrPXrAw5Fxcw7w%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtUnfR2S_-yZV%2BNHcB4AxgeLkntmi%2BV318YVWnXaw%3D0EQ%40mail.gmail.com.


Re: [racket-users] Is this running in DrRacket or as a script?

2020-09-02 Thread Sorawee Porncharoenwase
Using Laurent’s suggestion, you can also create a global variable /
parameter that will be set by the drracket submodule. That way, you can
create running-in-drracket? and use it inside functions.

On Wed, Sep 2, 2020 at 12:54 AM Laurent  wrote:

> You can use a `drracket` submodule:
>
> (module+ drracket
>  (foo)
>  (bar))
>
> but you need to configure DrRacket to recognize it: Click on the
> bottom-left button about languages, and at the bottom of "Dynamic
> Properties", click on "Submodules to run", then "Add submodule option" and
> add "drracket".
>
> After this, when you run a module from within DrRacket, it will
> automatically run the `drracket` submodule, but this submodule will *not*
> be run from the command line (by default).
>
> (I also uncheck the "main" submodule as I use this one only for the
> command line.)
>
> HTH,
> Laurent
>
>
>
>
> On Wed, Sep 2, 2020 at 8:44 AM Stefan Schmiedl 
> wrote:
>
>> Greetings,
>>
>> I find myself coding some more in DrRacket on my local Win10 PC.
>> The finished program is to be run on a remote linux server.
>>
>> I like to keep the code set up for the production environment
>> but to test it locally I need to configure some things differently.
>>
>> Currently I'm doing this manually by commenting/uncommenting a sexp
>> with the required modifications.
>>
>> Is there a function around that allows me to do something like
>>
>> (when (running-in-dr-racket?)
>>   (foo)
>>   (bar))
>>
>> Thanks,
>> s.
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/26327196.20200902094324%40gmail.com
>> .
>>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CABNTSaHRMNb8_efegWNC4x68tgo3Q96-ja7ZKHTgSi0Ap86K1g%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvH7XmiwmB3dHQ-Wec6U73C-4N3DfHYHO1HeOfUYP5peg%40mail.gmail.com.


Re: [racket-users] printing errors

2020-08-29 Thread Sorawee Porncharoenwase
Alternatively, I think you can simply supply a non-exception value to the
handler. This will suppress the red cross icon too, though.

(define (print-exn exn)
  ((error-display-handler)
   (if (exn? exn)
   (exn-message exn)
   (format "~a" exn))
   #f))


On Sat, Aug 29, 2020 at 8:17 AM Robby Findler 
wrote:

> It might make the most sense for you to extract the exn-message and print
> it yourself? It should contain only the "a: undefined" part. If you want to
> selectively access the stacktrace and decide whether or not to print that
> first stackframe, that'll probably require a change to DrRacket, tho -- at
> least if you have debugging turned on. (There may be some clever hack I'm
> not thinking of, tho, depending on what you want.)
>
> Robby
>
> On Sat, Aug 29, 2020 at 10:11 AM Shriram Krishnamurthi 
> wrote:
>
>> Thank you!
>>
>> Is there a way of further suppressing info? Right now I get output like
>>
>> [image: image.png] ../../make-semantics.rkt:37:13: a: undefined
>>
>>
>> which is a reference to the language implementation file rather than to
>> the program in the language.
>>
>> The programs here are so small that suppressing everything but the "a:
>> undefined" would be great.
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAJUf2yQgBahzMQP-rPOAXM6xWkvAiR0EstzVNLweEYo83A6mEQ%40mail.gmail.com
>> 
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvwTnfHMTA91aPTFmLqX8dx695tW3wU9XMp6zs7jG49mw%40mail.gmail.com.


Re: [racket-users] graphical debugging

2020-08-29 Thread Sorawee Porncharoenwase
I meant the REPL in DrRacket (interaction window).

On Sat, Aug 29, 2020 at 5:21 AM Catonano  wrote:

> Il giorno sab 29 ago 2020 alle ore 12:11 Sorawee Porncharoenwase <
> sorawee.pw...@gmail.com> ha scritto:
>
>> It (kinda) works for me. You should make sure that debugging is enabled
>> in the language setting (it should display something like “Language:
>> racket, with debugging [custom]” in the REPL). Then, click “Debug” and then
>> click “Step” for a couple of times (seven to be precise). The little green
>> triangular arrow should then appear at
>>
>> (remove-markup
>>  (open-input-string
>>   "Hello, world!"))
>>
>>
>>
>
>
>
> Thank you very much
>
> How do I enable debigging in the repl ?
>
> This is all my repl shows
>
> ~$ racket
> Welcome to Racket v7.7.
> >
>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegupDNEOuyT7nM_x6_PTxm1HCgAjyLM4xrM8-wx%3DeXtteg%40mail.gmail.com.


Re: [racket-users] graphical debugging

2020-08-29 Thread Sorawee Porncharoenwase
It (kinda) works for me. You should make sure that debugging is enabled in
the language setting (it should display something like “Language: racket,
with debugging [custom]” in the REPL). Then, click “Debug” and then click
“Step” for a couple of times (seven to be precise). The little green
triangular arrow should then appear at

(remove-markup
 (open-input-string
  "Hello, world!"))





On Sat, Aug 29, 2020 at 2:20 AM Catonano  wrote:

> in Drracket, I'm trying to debug this scrap of code
>
> #lang
> 
>  racket 
>
> (require
> 
>  racket/string sxml)
>
> (define
> 
>  (remove-markup xml-port)
>   (let*
> 
>  ((parser
>   (ssax:make-parser
> 
>  NEW-LEVEL-SEED remove-markup-nls
> FINISH-ELEMENT remove-markup-fe
> CHAR-DATA-HANDLER remove-markup-cdh))
>  (strings (parser xml-port null
> 
> )))
> (string-join (reverse
> 
>  strings) "")))
>
> (define
> 
>  (remove-markup-nls gi attributes namespaces expected-content
>seed)
>   seed)
>
> (define
> 
>  (remove-markup-fe gi attributes namespaces parent-seed seed)
>   seed)
>
> (define
> 
>  (remove-markup-cdh string-1 string-2 seed)
>   (let
> 
>  ((seed (cons
> 
>  string-1 seed)))
> (if
> 
>  (non-empty-string? string-2)
> (cons
> 
>  string-2 seed)
> seed)))
>
> (remove-markup
>  (open-input-string
> 
>   "Hello, world!"))
>
> it's an example copied from here
> https://docs.racket-lang.org/sxml/ssax.html
>
> Reading here
> https://docs.racket-lang.org/drracket/debugger.html
>
> I understand that a little green triangular arrow should appear on the
> left side of the line where the debugger stops and waits
>
> but that doesn't happen to me, it runs completely and produces the output
> (he "Hello World !" string)
>
> am I doing anything wrong ?
>
> Thanks
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAJ98PDxXRHuH47tUBSUe1PLeywAY0fRN1Y4w6kn8mubLUt0HWw%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvu_wEi6aCdmd_bmMgCH2eMN%2B5Nu%3D5Uukt%3DdxY47WDjkQ%40mail.gmail.com.


Re: [racket-users] printing errors

2020-08-27 Thread Sorawee Porncharoenwase
For stacktrace, use error-print-context-length to suppress it:

(define (print-exn exn)
  (parameterize ([error-print-context-length 0])
((error-display-handler)
 (if (exn? exn)
 (exn-message exn)
 (format "~a" exn))
 exn)))

I don’t see any extra newline though.

On Thu, Aug 27, 2020 at 3:11 PM Shriram Krishnamurthi 
wrote:

> This is perfect, thanks!
>
> Two follow-up questions:
>
> 1. The error printer seems to print an extra newline at the end relative
> to what the port-display-handler (for instance) shows. Is there a way to
> suppress that?
>
> 2. The stack trace seems to be extracted automatically. Is there a way to
> suppress it entirely?
>
> Shriram
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAJUf2yQyVat2Fy63hdDqRv9iaq40Zsf_6TQJsLU%3DETB30zCE0Q%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsxbKF6CZi01J0mduxo9vS5U2QDjn5M-jA12h21NB02PA%40mail.gmail.com.


[racket-users] Re: [racket-dev] Does the Guide need to mention syntax parse & does the Style guide need to provide guidance?

2020-08-23 Thread Sorawee Porncharoenwase
The guide seems to be for the Racket code base (https://github.com/racket)
rather than general Racket code, so I don't think it should say "prefer
syntax-parse over syntax-case".

I do think there should be a style guide for general Racket code (which
could very well be based on the style guide for the Racket code base), and
for this guide, it would make sense to say "prefer syntax-parse over
syntax-case".

On Sun, Aug 23, 2020 at 10:51 AM Stephen De Gabrielle <
spdegabrie...@gmail.com> wrote:

> Hi
>
> With reference to this discussion on reddit/r/racket :
>
>
> https://www.reddit.com/r/Racket/comments/ie8rlf/when_creating_macros_is_syntaxparse_preferred_to/?utm_source=share_medium=ios_app_name=iossmf
>
>
> Does
> https://github.com/racket/racket/blob/master/pkgs/racket-doc/scribblings/guide/macros.scrbl
> need to be updated to link to the syntax parse introduction
> https://docs.racket-lang.org/syntax/stxparse-intro.html ?
>
> What should it say?
>
> > Robust macros can be written with syntax-parse and syntax classes.
>
> Does the Style Guide need a section for when to use syntax-rules, -case
> or -parse?
>
> What should it look like?
>
> (in the spirt of
> https://docs.racket-lang.org/style/Choosing_the_Right_Construct.html#%28part._.Functions_vs_.Macros%29
> )
>
> Kind regards
>
> Stephen
>
> --
> 
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-dev/CAGHj7-J6XdT%3DzGtt5aVA8M6ZgJX2%3D0G-6ZnR%2BUYRBTQsLczKnw%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtrKBM3DMju1CiT-qX9%3DW9ujypPDTEn1JkFKL9TQre7zg%40mail.gmail.com.


Re: [racket-users] Deserializing snips from untrusted input

2020-08-20 Thread Sorawee Porncharoenwase
I don't know much about this specific case, but see Robby's comment about
how "DrRacket can run user (untrusted) code in certain situations" at
https://github.com/racket/gui/issues/157. A concrete problem I found is
that you can have a snip running `struct->vector` and it will successfully
extract private fields of that struct value, even though it won't be able
to if you do that in normal circumstances.

On Thu, Aug 20, 2020 at 8:34 AM Daniel Melcer  wrote:

> There are some well-known vulnerabilities that are a result of
> deserializing untrusted inputs. Are editor snips restrictive enough that
> their deserialization is safe? After all, they are already loaded when a
> file is opened in DrRacket, and a file on the disk may originate from an
> untrusted source. In particular, I would be doing something like this
> (snip-class-name, bytes, and snip-pos are from an untrusted source). The
> whole thing will be wrapped in an exception handler:
>
> (define snip-class (send (get-the-snip-class-list) find
> snip-class-name)) ; Also handle case where this returns #f
> (define bytes-base-in (make-object editor-stream-in-bytes-base%
> bytes))
> (define editor-stream-in (make-object editor-stream-in%
> bytes-base-in))
> (define new-snip (send snip-class read editor-stream-in))
> (send text insert new-snip snip-pos)
>
> Daniel
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/153d1c59-0343-4ed9-805b-2909499ec98fn%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtnpb3h_JkDFmBdhiosJkz948ypkhmoj1vZc7vq5SAR0w%40mail.gmail.com.


Re: [racket-users] Re: Application Templates!

2020-08-20 Thread Sorawee Porncharoenwase
Is this intended to be something like https://docs.racket-lang.org/scaffold/
?

On Thu, Aug 20, 2020 at 10:12 AM Stephen De Gabrielle <
spdegabrie...@gmail.com> wrote:

> Alex is right, most developers don't need this.
>
> The point of templates is a jumping off point for new developers, or
> developers trying a domain they are not familiar with.
>
> Where possible I will be linking back to any supporting materials (
> https://alex-hhh.github.io/2020/03/a-game-of-tetris.html thank you Alex)
>
> As part of the working example distributing or deploying; sometimes we
> make software for ourselves, (packages, plugins, scripts, keybindings and
> new raco commands),
> but sometimes we make software for others; in those cases the templates
> need to include instructions for that process
> - create the distributable executable
> - deploy a web app (blog post by Alexis - but might make use of the
> 'Deploy to Heroku' button)
> - Microsoft Store (help please? both x86 and ARM)
> - App Store for mac (https://defn.io/2020/01/04/remember-internals/ thank
> you Bogdan) and maybe iOS ( https://defn.io/2020/01/05/racket-on-ios/ )
> - packaged as a PPA for linux.
> - github actions
> - services or components in larger frameworks/applications/or os's (?)
>
> A recent contribution is a new command extension to raco:
> https://github.com/nixin72/from-template
> $ raco from-template  
> Philip described it 'like create-react-app, but for all sorts of Racket
> templates'
>  (It is currently only linux so it would be nice if a windows user could
> help)
>
> *A big thank you goes to Philip because it serves two purposes*
> *1. It’s a raco tool for installing templates - exactly what is needed *
> *2. It is a template for adding a command to raco!*
>
>
> PS: I would suggest that Racket is *a lot* like dotnet core in that it is
> a 'developer platform ' (not a framework)
> that consists of 'a runtime, a series of languages and a bunch of
> libraries '.
> Mirroring https://twitter.com/shanselman/status/1288698620804362240?s=20 :
>>
>> Racket = .Net (The Ecosystem)
>> bc/cs = JVM, CLR
>> racket/base, racket/gui, typed/racket, datalog & others = Languages
>> https://pkgs.racket-lang.org = npm, maven, etc raco = dotnet cli - your
>> entry point, SDK, driver, javac, go, etc raco from-template
>>  = create-react-app, dotnet
>> new - templates
>
> raco exe = dotnet run - dev time compile and run raco distribute = dotnet
>> publish - ready up for deploy
>
>
> Kind regards,
>
> Stephen
>
>
> On Thu, Aug 20, 2020 at 11:17 AM Laurent  wrote:
>
>> Stephen's work may still be quite useful, as it provides a set of really
>> minimal (almost?) working examples that explain the specifics of various
>> tools.
>>
>> I say keep it up, Stephen!
>>
>> On Thu, Aug 20, 2020 at 5:33 AM Alex Harsanyi 
>> wrote:
>>
>>> I am not sure that a template in the style of "dotnet new" is directly
>>> applicable for Racket --  the .Net framework is, well a framework. which is
>>> a library that expects the users to structure their own programs in certain
>>> ways.  The templates fill the need of setting up the boilerplate code for
>>> different kind of applications as required by the .Net framework.  Racket
>>> applications don't need large amounts of "setup code", most of the code is
>>> very specific to the application itself, so not sure what a template would
>>> contain apart from very basic things.
>>>
>>> I think Racket would benefit by a suite of applications which are small
>>> but not trivial and with a source code which is commented in more detail
>>> than a regular application.  I attempted to do this with my blog posts,
>>> some of which describe more-or-less complete applications (most of them
>>> games). The entire source code is in a single file which can be run
>>> directly and is available as a GitHub Gist linked from the blog posts.
>>>
>>> Here are some examples:
>>>
>>> * ishido game (936 lines):
>>> https://gist.github.com/alex-hhh/2e204b3a9d9d7094f65a0b585d0b7480
>>> * tetris game (893 lines):
>>> https://gist.github.com/alex-hhh/2233aee39852f4e0aead4af4cafb40d5
>>> * chess board (893 lines):
>>> https://gist.github.com/alex-hhh/4817c4d0353e40b72108e7e753c3d0da
>>> * password generator GUI (346 lines):
>>> https://gist.github.com/alex-hhh/6acbbb8ebca47c4cfaa2540499494af6
>>> * password generator, command line (142 lines):
>>> https://gist.github.com/alex-hhh/27286f4609ea0c989675e5c946ca39de
>>>
>>> These are of course not templates, but they could serve as the starting
>>> points for users who already have some experience with programming and want
>>> to try out some more complex programs.
>>>
>>> Alex.
>>>
>>> On Thursday, August 20, 2020 at 5:49:37 AM UTC+8 Stephen De Gabrielle
>>> wrote:
>>>
 I’ve started a small collection!

 https://github.com/racket-templates

 

Re: [racket-users] Re: Strange performance behavior

2020-08-07 Thread Sorawee Porncharoenwase
I even saw people doing `collect-garbage` three times, just to be safe I
guess. And yet theoretically it's not guaranteed that things will be
claimed back properly.

Honestly, there should be a function that does this `collect-garbage` until
fixpoint or something, so that we don't need to perform this ... uh 
ritual.

On Fri, Aug 7, 2020 at 9:27 PM George Neuner  wrote:

> On Fri, 7 Aug 2020 06:23:52 -0700 (PDT), "'Joel Dueck' via Racket
> Users"  wrote:
>
> >On Wednesday, August 5, 2020 at 10:44:21 AM UTC-5 Sam Tobin-Hochstadt
> wrote:
> >
> >> Here's a benchmark of your two functions that takes long enough to run
> >> that it avoids some of these issues, and also runs a GC before
> >> benchmarking: https://gist.github.com/7cb4645308d8572e2250833ef7b90b7c
> >>
> >
> >What is the reason for calling `collect-garbage` twice consecutively?
>
> It is an attempt to start with the cleanest heap possible.
>
> Objects that have a "finalizer" get collected over 2 GC cycles - the
> finalizer function gets run during the 1st collection, and then the
> object memory is reclaimed during the next collection.
>
> Running GC twice makes sure any finalized objects have been collected.
>
>
> Also, when GC can run in parallel with the mutator, it is possible to
> miss collecting objects that become garbage *while* GC is running.
> This can't happen in BC Racket, but it might be possible in RacketCS
> because Chez has a different thread model. ???
>
>
> >Also, the docs are unclear on this, but is `(collect-garbage)` equivalent
> >to `(collect-garbage 'major)` ?
>
> The docs clearly state that the default is 'major.
>
>  (collect-garbage [request]) ? void?
>request : (or/c 'major 'minor 'incremental) = 'major
>
>
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/tp8sifhd4c0cdlvk22qfsmksckv5r0ajpq%404ax.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegttXoDSiLX5O5tfWtu69BsiZdXExH8AJj-CfaFPU3gTEA%40mail.gmail.com.


Re: [racket-users] Racket v7.8

2020-08-04 Thread Sorawee Porncharoenwase
The prop:struct-field-info doc could also be accessed at
https://plt.eecs.northwestern.edu/snapshots/current/doc/reference/structinfo.html?q=prop%3Astruct-field-info#%28def._%28%28lib._racket%2Fstruct-info..rkt%29._prop~3astruct-field-info%29%29
.

On Tue, Aug 4, 2020 at 7:33 AM 'John Clements' via Racket Users <
racket-users@googlegroups.com> wrote:

> Yes, there is documentation for this feature! Here are two ways to get it:
>
> 1) On a machine with 7.8 installed, run `raco docs prop:struct-field-info`
> at the command line, or (equivalently) highlight the word in drracket and
> hit F1. Both of these open a web browser window pointed at your local
> documentation installation.
>
> 2) Wait a few days for the 7.8 docs to be installed at
> docs.racket-lang.org.
>
> Best,
>
> John
>
> > On Aug 4, 2020, at 10:28, 'Joel Dueck' via Racket Users <
> racket-users@googlegroups.com> wrote:
> >
> > I'm very interested in the prop:struct-field-info property. Is there any
> documentation on it? I notice docs.racket-lang.org still says 7.7 up at
> the top.
> >
> > Thanks to everyone for this release!
> >
> > On Monday, August 3, 2020 at 12:19:57 PM UTC-5 johnbclements wrote:
> > This release announcement mistakenly omitted two important contributors:
> Tim Brown, and Dionna Amalie Glaze. Many thanks for their help!
> >
> > John Clements
> >
> > > On Aug 3, 2020, at 09:35, John Clements 
> wrote:
> > >
> > > Racket version 7.8 is now available from
> > >
> > > https://racket-lang.org/
> > >
> > >
> > > * Racket CS may become the default Racket implementation in the next
> > > release. With the improvements in this release, Racket CS provides all
> > > of the functionality of Racket BC (the current default
> > > implementation). If, between this release and the next, no bugs are
> > > discovered in Racket CS that are more serious than those typically
> > > discovered in Racket BC, then Racket CS will become the default for
> > > the next release.
> > >
> > > * Racket CS supports AArch32 and AArch64, including places and
> > > futures. The implementation should be considered experimental in this
> > > initial release.
> > >
> > > * Racket CS supports an "incremental" garbage-collection mode that can
> > > eliminate long GC pauses for some applications, such as animations and
> > > interactive games.
> > >
> > > * Racket CS unboxes local floating-point arithmetic (like Racket BC).
> > >
> > > * DrRacket's spell check features lower overhead and has fewer bugs.
> > >
> > > * Web Server performance under high concurrency is [better by up to an
> > > order of magnitude](https://github.com/racket/web-server/pull/94/).
> > > The Web Server is also more resistant to clients attempting to use
> > > unconstrained resources.
> > >
> > > * The math library includes the Kronecker product.
> > >
> > > * Windows supports finer granularity for `sleep` when sleeping for
> short
> > > periods of time, improving performance in animation.
> > >
> > > * The new prop:struct-field-info property provides static information
> > > about field names.
> > >
> > > * Debugging context in Racket CS is limited to 64,000 frames
> > > (approximately the same as Racket BC). This reduces the time taken to
> > > handle out-of-memory failures.
> > >
> > > * In `plot`, the legend font and the plot font can be controlled
> > > independently, and error-bars have an `#:invert?` option.
> > >
> > > * The plot and math libraries have new maintainers: Alex Harsányi for
> > > plot and Pavel Pancheka and Jens Axel Søgaard for math.
> > >
> > >
> > > The following people contributed to this release:
> > >
> > > Alex Harsányi, Alex Knauth, Alexander Shopov, Alexis King, Andrew
> Kent,
> > > Andrew Mauer-Oats, Atharva Raykar, Ben Greenman, Benjamin Yeung, Bert
> De
> > > Ketelaere, Bogdan Popa, David Christiansen, David Florness, Diego
> > > Crespo, Fred Fu, Gary Baumgartner, Georges Dupéron, Gustavo
> Massaccesi,
> > > J. Ian Johnson, Jack Firth, Jay McCarthy, Jens Axel Søgaard, Jesse
> > > Alama, John Clements, Laurent Orseau, Leif Andersen, Luka Hadži-Đokić,
> > > Marc, Matthew Butterick, Matthew Flatt, Matthew Parris, Matthew
> Turland,
> > > Matthias Felleisen, Michael Ballantyne, Mike Sperber, Noah W M, Paulo
> > > Matos, Pavel Panchekha, Philip

Re: [racket-users] pictures in code?

2020-08-02 Thread Sorawee Porncharoenwase
For DrRacket, it's possible via "Insert > Insert Image". It's been used in
HtDP. See https://htdp.org/2020-8-1/Book/part_prologue.html

On Sun, Aug 2, 2020 at 7:07 PM Hendrik Boom  wrote:

> Is there any way to include pictures in Racket code?
> Perhaps as constants or as prts of identifiers?
> The idea is that when editing the program in the Racket editor,
> the pictures are visible as part of the code,
> making the code itself more visually self-evident,
> not as file names to be read from elsewhere.
>
> -- hendrik
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200803020710.d2rvz6gojluubt5t%40topoi.pooq.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvJCAHQYwO-eCcqKfqwhrd%2BGr4PELie_e0%3DO9b2PJ_QAA%40mail.gmail.com.


[racket-users] Re: with-continuation-marks in errortrace

2020-07-26 Thread Sorawee Porncharoenwase
(By "integrating" with the new strategy, I meant having two keys: one for
the new strategy and one for the old strategy. I can see that the first
entry of the old strategy is useful, and it's missing in the new strategy).

On Sun, Jul 26, 2020 at 8:21 PM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> Hi everyone,
>
> I have a question about the implementation of errortrace.
>
> Consider the classic factorial program, except that the base case is buggy:
>
> (define (fact m)
>   (let loop ([n m])
> (cond
>   [(zero? n) (/ 1 0)]
>   [else (* (loop (sub1 n)) n)])))
>
> (fact 5)
>
> Running this program with racket -l errortrace -t fact.rkt gives the
> following output:
>
> /: division by zero
>   errortrace...:
>/Users/sorawee/playground/fact.rkt:9:17: (/ 1 0)
>/Users/sorawee/playground/fact.rkt:10:12: (* (loop (sub1 n)) n)
>/Users/sorawee/playground/fact.rkt:10:12: (* (loop (sub1 n)) n)
>/Users/sorawee/playground/fact.rkt:10:12: (* (loop (sub1 n)) n)
>/Users/sorawee/playground/fact.rkt:10:12: (* (loop (sub1 n)) n)
>/Users/sorawee/playground/fact.rkt:10:12: (* (loop (sub1 n)) n)
>
> I find this result subpar: it doesn’t indicate which call at the top-level
> leads to the error. You can imagine another implementation of fact that
> errors iff m = 5. Being able to see that (fact 5) at the top-level causes
> the error, as opposed to (fact 3), would be very helpful.
>
> Not only that, (* (loop (sub1 n)) n) also looks weird. There’s nothing
> wrong with multiplication, so I don’t find this information useful.
>
> The tail-recursive factorial is similarly not helpful:
>
> (define (fact m)
>   (let loop ([n m] [acc 1])
> (cond
>   [(zero? n) (/ 1 0)]
>   [else (loop (sub1 n) (* n acc))])))
>
> (fact 5)
>
> produces:
>
> /: division by zero
>   errortrace...:
>/Users/sorawee/playground/fact.rkt:9:17: (/ 1 0)
>
> --
>
> I have been toying with another way to instrument the code. It roughly
> expands to:
>
> (define-syntax-rule (wrap f)
>   (call-with-immediate-continuation-mark
>'errortrace-k
>(λ (k)
>  (let ([ff (thunk f)])
>(if k
>(ff)
>(with-continuation-mark 'errortrace-k 'f
>  (ff)))
>
> (define (handler ex)
>   (continuation-mark-set->list (exn-continuation-marks ex) 'errortrace-k))
>
> (define (fact m)
>   (wrap (let loop ([n m])
>   (wrap (cond
>   [(wrap (zero? n)) (wrap (/ 1 0))]
>   [else (wrap (* (wrap n) (wrap (loop (wrap (sub1 
> n))])
>
> (with-handlers ([exn:fail? handler])
>   (wrap (fact 5)))
>
> which produces:
>
> '((loop (wrap (sub1 n)))
>   (loop (wrap (sub1 n)))
>   (loop (wrap (sub1 n)))
>   (loop (wrap (sub1 n)))
>   (loop (wrap (sub1 n)))
>   (fact 5))
>
> This result is more aligned with the traditional stacktrace, and gives
> useful information that I can use to trace to the error location.
>
> It is also safe-for-space:
>
> (define (fact m)
>   (wrap (let loop ([n m] [acc 1])
>   (wrap (cond
>   [(wrap (zero? n)) (wrap (/ 1 0))]
>   [else (wrap (loop (wrap (sub1 n)) (wrap (* n acc])
>
> (with-handlers ([exn:fail? handler])
>   (wrap (fact 5)))
>
> produces:
>
> '((fact 5))
>
> Now, the question: why is the current errortrace implemented in that way?
> Am I missing any downside of this new strategy? Would switching and/or
> integrating with the new strategy be better?
>
> Thanks,
> Sorawee (Oak)
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegto9%2BDtFTwAVmiReOcCwpARzBSbFhF0knyexb7UhoHQiA%40mail.gmail.com.


[racket-users] with-continuation-marks in errortrace

2020-07-26 Thread Sorawee Porncharoenwase
Hi everyone,

I have a question about the implementation of errortrace.

Consider the classic factorial program, except that the base case is buggy:

(define (fact m)
  (let loop ([n m])
(cond
  [(zero? n) (/ 1 0)]
  [else (* (loop (sub1 n)) n)])))

(fact 5)

Running this program with racket -l errortrace -t fact.rkt gives the
following output:

/: division by zero
  errortrace...:
   /Users/sorawee/playground/fact.rkt:9:17: (/ 1 0)
   /Users/sorawee/playground/fact.rkt:10:12: (* (loop (sub1 n)) n)
   /Users/sorawee/playground/fact.rkt:10:12: (* (loop (sub1 n)) n)
   /Users/sorawee/playground/fact.rkt:10:12: (* (loop (sub1 n)) n)
   /Users/sorawee/playground/fact.rkt:10:12: (* (loop (sub1 n)) n)
   /Users/sorawee/playground/fact.rkt:10:12: (* (loop (sub1 n)) n)

I find this result subpar: it doesn’t indicate which call at the top-level
leads to the error. You can imagine another implementation of fact that
errors iff m = 5. Being able to see that (fact 5) at the top-level causes
the error, as opposed to (fact 3), would be very helpful.

Not only that, (* (loop (sub1 n)) n) also looks weird. There’s nothing
wrong with multiplication, so I don’t find this information useful.

The tail-recursive factorial is similarly not helpful:

(define (fact m)
  (let loop ([n m] [acc 1])
(cond
  [(zero? n) (/ 1 0)]
  [else (loop (sub1 n) (* n acc))])))

(fact 5)

produces:

/: division by zero
  errortrace...:
   /Users/sorawee/playground/fact.rkt:9:17: (/ 1 0)

--

I have been toying with another way to instrument the code. It roughly
expands to:

(define-syntax-rule (wrap f)
  (call-with-immediate-continuation-mark
   'errortrace-k
   (λ (k)
 (let ([ff (thunk f)])
   (if k
   (ff)
   (with-continuation-mark 'errortrace-k 'f
 (ff)))

(define (handler ex)
  (continuation-mark-set->list (exn-continuation-marks ex) 'errortrace-k))

(define (fact m)
  (wrap (let loop ([n m])
  (wrap (cond
  [(wrap (zero? n)) (wrap (/ 1 0))]
  [else (wrap (* (wrap n) (wrap (loop (wrap (sub1 n))])

(with-handlers ([exn:fail? handler])
  (wrap (fact 5)))

which produces:

'((loop (wrap (sub1 n)))
  (loop (wrap (sub1 n)))
  (loop (wrap (sub1 n)))
  (loop (wrap (sub1 n)))
  (loop (wrap (sub1 n)))
  (fact 5))

This result is more aligned with the traditional stacktrace, and gives
useful information that I can use to trace to the error location.

It is also safe-for-space:

(define (fact m)
  (wrap (let loop ([n m] [acc 1])
  (wrap (cond
  [(wrap (zero? n)) (wrap (/ 1 0))]
  [else (wrap (loop (wrap (sub1 n)) (wrap (* n acc])

(with-handlers ([exn:fail? handler])
  (wrap (fact 5)))

produces:

'((fact 5))

Now, the question: why is the current errortrace implemented in that way?
Am I missing any downside of this new strategy? Would switching and/or
integrating with the new strategy be better?

Thanks,
Sorawee (Oak)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcueguwj1rK0oBAj3m2eiv_h94GGSOQP67g5Rxst%2BC4qWjwHg%40mail.gmail.com.


Re: [racket-users] catalog not working?

2020-07-23 Thread Sorawee Porncharoenwase
Though, considering that there are so many people who are misled that the
catalog is down (my past self included), it might be better if that page
displays some useful information rather than a 404.

On Thu, Jul 23, 2020 at 8:12 PM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> The catalog is functional. That path is simply not served. See also:
>
> From: Matthew Flatt 
> Date: Thu, Feb 27, 2020 at 3:00 PM
> Subject: Re: [racket-users] download catalog down?
> To: Tom Gillespie 
> Cc: Racket Users 
>
> That path isn't served, but something like
>
>   https://download.racket-lang.org/releases/7.6/catalog/pkg/racket-lib
>
> or
>
>   https://download.racket-lang.org/releases/7.6/catalog/pkgs
>
> should work (and does work for me).
>
>
> On Thu, Jul 23, 2020 at 7:50 PM Nate Griswold 
> wrote:
>
>> My raco pkg install is crashing and manual navigation to the package
>> catalog looks broken
>>
>> https://download.racket-lang.org/releases/7.7/catalog/
>>
>> [image: image.png]
>>
>> Nate
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAM-xLPpZ06bnkiyUuQipqupoaA-odsmGMuakWp02WqRDbRUAbA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAM-xLPpZ06bnkiyUuQipqupoaA-odsmGMuakWp02WqRDbRUAbA%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegty7yaJtorXxwK%2B1Jq8fE00H3jwwM00kcGumw%3DLDwMdRQ%40mail.gmail.com.


Re: [racket-users] catalog not working?

2020-07-23 Thread Sorawee Porncharoenwase
The catalog is functional. That path is simply not served. See also:

From: Matthew Flatt 
Date: Thu, Feb 27, 2020 at 3:00 PM
Subject: Re: [racket-users] download catalog down?
To: Tom Gillespie 
Cc: Racket Users 

That path isn't served, but something like

  https://download.racket-lang.org/releases/7.6/catalog/pkg/racket-lib

or

  https://download.racket-lang.org/releases/7.6/catalog/pkgs

should work (and does work for me).


On Thu, Jul 23, 2020 at 7:50 PM Nate Griswold 
wrote:

> My raco pkg install is crashing and manual navigation to the package
> catalog looks broken
>
> https://download.racket-lang.org/releases/7.7/catalog/
>
> [image: image.png]
>
> Nate
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAM-xLPpZ06bnkiyUuQipqupoaA-odsmGMuakWp02WqRDbRUAbA%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcueguZ812X%2BsrKEjCLwRogUn-uBQct-ogLtqbDzberwsFMww%40mail.gmail.com.


Re: [racket-users] Multiple stage compilation in a tower of languages

2020-07-23 Thread Sorawee Porncharoenwase
local-expand supports the stop-list argument, so I think you can put all
core forms there.

#lang racket

(require syntax/parse/define)

(define-syntax (A-core stx)
  (syntax-parse stx #:literals (b-core)
[(A-core (b-core x)) #'(printf "A-core got value ~a.~n" x)]))

(define-syntax (b-core stx) (raise-syntax-error #f "b-core out of context"))

(define-simple-macro (b-surface x) (b-core x))

(define-syntax (A-surface stx)
  (syntax-parse stx
[(A-surface expr)
 #:with sub-stx (local-expand #'expr 'expression (list #'b-core))
 #`(A-core sub-stx)]))

(A-surface (b-surface "hello"))

Note that I switch define-syntax-rule to define-simple-macro because
define-syntax-rule will use syntax-protect, resulting in errors like cannot
use identifier tainted by macro transformation.

On Thu, Jul 23, 2020 at 10:00 AM Thomas Del Vecchio <
thomas_del_vecc...@brown.edu> wrote:

> Hi all,
>
> I'm working on a family of languages in Racket, and I'm running into a
> conceptual issue with the information flow of the project. I have a
> standard core language whose syntax is s-expressions, with some macros in
> the expander. Then, there is a surface language (compiled into
> s-expressions with brag) which directly translates into the core language.
> There will also be other surface languages in the future, forming a
> tower/tree of languages that compile into simpler ones, so I want to make
> sure I get this pattern right.
>
> Conceptually, I would want the surface language to fully "compile" into
> the core language before the core language tries to do anything. As I
> develop the surface language, I don't think I should have to concern myself
> with the inner workings of the core language; I should be able to just
> produce core language code, and then have the core language handle it from
> there. I find myself running into an issue, however, where the core
> language starts to do computations before the translation is
> fully complete. This is an issue because the macros of the core language
> are taking in the syntax of the surface language which hasn't been
> translated yet, and so the core language doesn't recognize this syntax and
> breaks.
>
> As a small example, consider the following:
> core-language-expander.rkt
> (define-syntax (A-core stx)
>   (syntax-parse stx #:datum-literals (b-core)
> [(A-core (b-core x)) #'(printf "A-core got value ~a.~n" x)]))
>
> surface-language-expander.rkt
> (define-syntax-rule (b-surface x) (b-core x))
> (define-syntax (A-surface stx)
>   (syntax-parse stx
> [(A-surface expr) #'(A-core expr)]))
>
> Here, if we call `(A-surface (b-surface "hello"))`, we would want it to
> take the `A-surface`, and convert it into `A-core`, and then expand 
> `(b-surface
> "hello")`. Since `A-core` is implemented as a macro, though, it takes 
> `(b-surface
> "hello")` unexpanded, and so tries to evaluate `(A-core (b-surface
> "hello"))`, which fails.
>
> Since `b-core` isn't defined as a function/macro in the core language (it
> is just a piece of syntax used in `A-core`), we can't just evaluate 
> `(b-surface
> "hello")` as a value before passing it in. If we try using `local-expand`
> or something similar to handle the expansion as syntax, there isn't an
> obvious way to make it only expand macros defined in the surface language
> expander (and not those defined in the core language expander), which turns
> out to be an issue in my case.
>
> Do any of you recommend a resource for understanding the strategy of
> taking a stack of languages and compiling down one layer at a time? It
> seems like the notion of a tower of languages would be fairly natural, yet
> the only success I have had is with some hacks with recursive local-expand
> that feel extremely unnatural, and also require further hacks to get around
> things like syntax-tainting.
>
> Thanks so much!
> Thomas Del Vecchio
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/26f44e6d-f1f8-465e-9639-6cd6afeffa31n%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvACr%2Bs%3DHwGbmhtPqyYOC8UahK47Rf22wJkdJ6X5Yabiw%40mail.gmail.com.


Re: [racket-users] combining require, build-path, and namespaces

2020-07-21 Thread Sorawee Porncharoenwase
This is weird. I usually parameterize current-namespace when using
namespace-* functions, and in this particular case it works fine.

On Tue, Jul 21, 2020 at 11:05 AM Shriram Krishnamurthi 
wrote:

> Thank you! Would you know why I might get this error:
>
> ; require: unknown module
>
> ;   module name:
>
> ; #>
>
> (This is from inside a module.)
>
> Trying the same at the REPL, I see the same thing:
>
> > (define n (make-base-namespace))
>
> > (namespace-require `(file ,(path->string (build-path "wheats"
> "w1.rkt"
>
> [note no optional namespace]
> works fine; the name is available at the top-level; but using the same
> pathname but with the namespace parameter:
>
> > (namespace-require `(file ,(path->string (build-path "wheats"
> "w1.rkt"))) n)
>
> ; require: unknown module
>
> ;   module name:
>
> ; #>
>
> (The file in question begins with #lang racket.)
>
> Shriram
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAJUf2yQijBugL3PBo%2B5SBj-9zEKnUc2ejH52VB0AkTW%3DniRGQw%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegugFPk2KjHF%3D550%3Dv5dzs1XD74z-mfJWBwBMmC1AtxSzg%40mail.gmail.com.


Re: [racket-users] reading s-expressions from a file

2020-07-17 Thread Sorawee Porncharoenwase
(with-input-from-file "abc" (thunk (sequence->list (in-port

Note that you need to “read” in the dynamic extent of with-input-from-file.
Outside it, the port is closed.

On Fri, Jul 17, 2020 at 5:19 PM Hendrik Boom  wrote:

> Yes,  I know the functino for reading s-expressions seems to be (read
> [in]).
>
> I want a loop that reads S-expressions and does something to each one,
> until there are no more to be found in a file.
>
> Now of course that's absurdly easy to do with a tail-recursice loop.
>
> But I's like it to look like a loop, with (for ...) or (while ...) or
> (loop ...) or something like that.
>
> But I fail to fine any iterators that process a file, such as (in-file
> ...)
>
> There's a long list of iterators in
>https://docs.racket-lang.org/reference/for.html
> and in
>https://docs.racket-lang.org/guide/for.html
>
> An I just looking in the wrong place, or are there really no iterators
> for reading a stream of s-expressions from a file.
>
> -- hendrik
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200718001905.elzyuu42gje45j7t%40topoi.pooq.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvbps%3DtFJYg2UZ48s7uw1tVY8P58WnQYoZUMyShahCzhg%40mail.gmail.com.


Re: [racket-users] Are Regular Expression classes Unicode aware?

2020-07-09 Thread Sorawee Porncharoenwase
I did in fact try installing readline-gpl (raco pkg install readline-gpl),
but it didn’t change anything. Interestingly, the bug in #3223 persists for
me, too. This suggests that I didn’t install or invoke it correctly. Do you
need to run racket with any flag to make readline-gpl take its effect?

But yes, the problem is definitely due to readline. Sam suggested me
to try racket
-q which suppresses readline, and the result is that there’s no issue.

On Thu, Jul 9, 2020 at 11:43 AM Philip McGrath 
wrote:

> On Thu, Jul 9, 2020 at 10:32 AM Sorawee Porncharoenwase <
> sorawee.pw...@gmail.com> wrote:
>
>> Racket REPL doesn’t handle unicode well. If you try (regexp-match?
>> #px"^[a-zA-Z]+$" "héllo") in DrRacket, or write it as a program in a
>> file and run it, you will find that it does evaluate to #f.
>>
> See this issue for workarounds, including installing the `readline-gpl`
> package: https://github.com/racket/racket/issues/3223
>
> But you may have some other issues: for me, `(regexp-match?
> #px"^[a-zA-Z]+$" "h\U+FFC3\U+FFA9llo")` gives an error saying "read-syntax:
> no hex digit following `\U`"
>
> For the original question:
>
>
>> On Thu, Jul 9, 2020 at 7:19 AM Peter W A Wood 
>> wrote:
>>
>>> I was experimenting with regular expressions to try to emulate the
>>> Python isalpha() String method.
>>>
>>
> You'd want to benchmark, but, for this purpose, I have a hunch you might
> get better performance by using `in-string` with a `for/and` loop (which
> can use unsafe operations internally)—probably especially so if you were
> content to just test `char-alphabetic?`, which follows Unicode's definition
> of "alphabetic" rather that Python's idiosyncratic one. Here's an example:
>
> #lang racket
>>
>> (module+ test
>>   (require rackunit))
>>
>> (define (char-letter? ch)
>>   ;; not the same as `char-alphabetic?`: see
>>   ;; https://docs.python.org/3/library/stdtypes.html#str.isalpha
>>   (case (char-general-category ch)
>> [(lm lt lu ll lo) #t]
>> [else #f]))
>>
>> (define (string-is-alpha? str)
>>   (for/and ([ch (in-string str)])
>> (char-letter? ch)))
>>
>> (module+ test
>>   (check-true (string-is-alpha? "hello"))
>>   (check-false (string-is-alpha? "h1llo"))
>>   (check-true (string-is-alpha? "héllo")))
>>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsvwBVDhnjtR5Gu6itoYWQPiiQHdwcZnaMv1Qvne2dAVg%40mail.gmail.com.


Re: [racket-users] Are Regular Expression classes Unicode aware?

2020-07-09 Thread Sorawee Porncharoenwase
Racket REPL doesn’t handle unicode well. If you try (regexp-match?
#px"^[a-zA-Z]+$" "héllo") in DrRacket, or write it as a program in a file
and run it, you will find that it does evaluate to #f.

On Thu, Jul 9, 2020 at 7:19 AM Peter W A Wood  wrote:

> I was experimenting with regular expressions to try to emulate the Python
> isalpha() String method. Using a simple [a-zA-Z] character class worked for
> the English alphabet (ASCII characters):
>
> > (regexp-match? #px"^[a-zA-Z]+$" "hello")
> #t
> > (regexp-match? #px"^[a-zA-Z]+$" "h1llo")
> #f
>
> It then dawned on me that the Python is alpha() method was Unicode aware:
>
> >>> "é".isalpha()
> True
>
> I started scratching my head as how to achieve the equivalent using a
> regular expression in Python. I tried the same regular expression with a
> non-English character in the string. To my surprise, the regular expression
> recognised the non-ASCII characters.
>
> > (regexp-match? #px"^[a-zA-Z]+$" "h\U+FFC3\U+FFA9llo")
> #t
>
> Are Racket regular expression character classes Unicode aware or is there
> some other explanation why this regular expression matches?
>
> Peter
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/2197C34F-165D-4D97-97AD-F158153316F5%40gmail.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsvf-hFwofptc2ieKQmqWFzxDnD1Cn8G7bFSzBZ%2BM3EDA%40mail.gmail.com.


Re: [racket-users] Is there a way to open (and just view) a Racket file (e. g. .rkt or .scrbl extensions) from Google Drive?

2020-07-07 Thread Sorawee Porncharoenwase
A quick Google returns this site:
https://superuser.com/questions/659666/how-do-i-get-google-drive-to-open-text-files-with-arbitrary-extensions-as-text-f

So it looks like there's no way if you are not willing to rename files or
use a third-party text editor in Google Drive.

On Tue, Jul 7, 2020 at 1:12 PM E Comer  wrote:

> Dear Racket users:
>
> Is there a way to* open* (and just *view*) a Racket file (in particular,
> with extensions *.rkt *or *.scrbl*) from *Google Drive*? (in my case is
> not necessary even to edit the file, just to verify content).
>
> Thank you very much for any pointer to reach that purpose.
>
> Please Keep Safe.
> E. Comer
> (P.S. Thank you for the outstanding Racket related tools: DrRacket is
> great, particularly in conjunction with Scribble).
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/d229a4d9-96a7-4ae3-86bc-8aded49aa99co%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvw-A3-5rOb8L5pd%3DjGk_cpvt9bh-bUsqH%3Dnmu79EJYSw%40mail.gmail.com.


Re: [racket-users] Wrong result from a define-syntax with pattern maching on a hash table

2020-07-06 Thread Sorawee Porncharoenwase
#lang scribble/manual

@(require (only-in racket ~a))

@(define persons (list (hash
'name 'name1
'e-mail 'email1
'nickname 'nickname1)
   (hash
'name 'name2
'e-mail 'email2
'nickname 'nickname2)
   (hash
'name 'name3
'e-mail 'email3
'nickname 'nickname3)))

@(define (generate-section person)
   (list @section{Here's a section for @(~a (hash-ref person 'name))}
 @subsection{My information}
 @itemlist[
   @item{Email: @(~a (hash-ref person 'e-mail))}
   @item{Nickname: @(~a (hash-ref person 'nickname))}
 ]))

@(map generate-section persons)


generates this document:

[image: Screen Shot 2020-07-06 at 05.09.08.png]

On Mon, Jul 6, 2020 at 5:01 AM Oualmakran Yassine 
wrote:

>  Sure.
>
> I would like to create a document with a repetitive structure in scribble.
>
> Let say I have something like this:
> @section{First section}
> Some text ...
> @subsection{First subsection}
> @itemlist...
>
> @section{Second section}
> Some text ...
> @subsection{Second subsection}
> @itemlist...
>
> etc.
>
> I would like to know how is it possible to have this without writing
> multiple section, subsection, etc. every time (the purpose is more to
> understand how the language works than anything else).
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/4c4194c0-ff05-4dee-9b44-53b9e2e00e0eo%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsbW5F_2vrAWp2GMr%3Dd55kxHiKYE7ADdoKPckWfZ5B1Jg%40mail.gmail.com.


Re: [racket-users] Wrong result from a define-syntax with pattern maching on a hash table

2020-07-06 Thread Sorawee Porncharoenwase
I still don't understand why you need to define a macro for that. We write
macros to manipulate _code_ by transforming a syntax object into another
syntax object. Extracting a value from a hash table or generating a text
from hash tables has nothing to do with syntax objects. And it can be done
with basic programming.

Can you tell what you are trying to do with more details, perhaps?

On Mon, Jul 6, 2020 at 4:23 AM Oualmakran Yassine 
wrote:

> In fact, I would like to have a macro that will generate some text from a
> list of hash tables for scribble. So this macro is just a first step to try
> to achieve that (it's also the first time I try a non toy program in any
> Lisp).
>
> Le lundi 6 juillet 2020 20:04:27 UTC+9, Sorawee Porncharoenwase a écrit :
>>
>> What's wrong with `match`? It seems to be what you want. Macro is not
>> going to help you here.
>>
>>
>>
>> On Mon, Jul 6, 2020 at 3:47 AM Oualmakran Yassine 
>> wrote:
>>
>>> Hello,
>>>
>>> I have some difficulties when trying to create a macro doing some
>>> pattern matching on a hash-table and was hoping finding some help.
>>> The macro is taking a hash-table as parameter and I would like to
>>> extract the value for the key 'name.
>>> I did several trials of my macro with what should be, for my
>>> understanding, the same hash-table but got always a different result.
>>> Suprisingly, when I'm trying the same partern matching in a simple
>>> "match" at runtime, I always get the answer expected.
>>>
>>>
>>> Here is my code:
>>>
>>> (define-syntax (m stx)
>>>(syntax-case stx ()
>>>  [(_ (hash-table 'name n m ...))
>>>  #'(symbol->string n)]
>>>  [(_ (hash-table x0 x1 ...))
>>>   #'"..."]
>>>  [(_ (hash-table ('name n) (k v) ...))
>>>   #'"FOO"]
>>>  [(_ (hash-table (k v) ...))
>>>   #'"BAM"]
>>>  [(_ (hash-table (k0 v0) (k1 v1) ...))
>>>   #'"BAZ"]
>>>  [(_ (hash-table x ...))
>>>   #'"COMMON"]
>>>  [x #'"WHY"]))
>>>
>>> (define (define-person . fields)
>>>(for/hash ([k '(name e-mail nickname)]
>>>   [field fields])
>>>  (values k field)))
>>>
>>> (define person (define-person 'my-name 'my-email 'my-nickname))
>>>
>>> ; gives why (why nothing before matches ?)
>>> (m person)
>>>
>>> ; my-email
>>> (m (define-person 'my-name 'my-email 'my-nickname))
>>>
>>> ; gives my-name
>>> (m (hash
>>>   'name 'my-name
>>>   'e-mail 'my-email
>>>   'nickname 'my-nickname))
>>>
>>> ; gives my-nickname
>>> (m (hash
>>>   'nickname 'my-nickname
>>>   'name 'my-name
>>>   'e-mail 'my-email))
>>>
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/82364adf-fe5d-4c6f-bf33-51852c423371o%40googlegroups.com
>>> <https://groups.google.com/d/msgid/racket-users/82364adf-fe5d-4c6f-bf33-51852c423371o%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/946b66b0-71b0-44e4-abef-2b577d564dc7o%40googlegroups.com
> <https://groups.google.com/d/msgid/racket-users/946b66b0-71b0-44e4-abef-2b577d564dc7o%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtcsBtaUVOcPoPEQkTcdvDbXQEeA_F%2BYE%2Bh8hAbArB6rw%40mail.gmail.com.


Re: [racket-users] Wrong result from a define-syntax with pattern maching on a hash table

2020-07-06 Thread Sorawee Porncharoenwase
What's wrong with `match`? It seems to be what you want. Macro is not going
to help you here.



On Mon, Jul 6, 2020 at 3:47 AM Oualmakran Yassine 
wrote:

> Hello,
>
> I have some difficulties when trying to create a macro doing some pattern
> matching on a hash-table and was hoping finding some help.
> The macro is taking a hash-table as parameter and I would like to extract
> the value for the key 'name.
> I did several trials of my macro with what should be, for my
> understanding, the same hash-table but got always a different result.
> Suprisingly, when I'm trying the same partern matching in a simple "match"
> at runtime, I always get the answer expected.
>
>
> Here is my code:
>
> (define-syntax (m stx)
>(syntax-case stx ()
>  [(_ (hash-table 'name n m ...))
>  #'(symbol->string n)]
>  [(_ (hash-table x0 x1 ...))
>   #'"..."]
>  [(_ (hash-table ('name n) (k v) ...))
>   #'"FOO"]
>  [(_ (hash-table (k v) ...))
>   #'"BAM"]
>  [(_ (hash-table (k0 v0) (k1 v1) ...))
>   #'"BAZ"]
>  [(_ (hash-table x ...))
>   #'"COMMON"]
>  [x #'"WHY"]))
>
> (define (define-person . fields)
>(for/hash ([k '(name e-mail nickname)]
>   [field fields])
>  (values k field)))
>
> (define person (define-person 'my-name 'my-email 'my-nickname))
>
> ; gives why (why nothing before matches ?)
> (m person)
>
> ; my-email
> (m (define-person 'my-name 'my-email 'my-nickname))
>
> ; gives my-name
> (m (hash
>   'name 'my-name
>   'e-mail 'my-email
>   'nickname 'my-nickname))
>
> ; gives my-nickname
> (m (hash
>   'nickname 'my-nickname
>   'name 'my-name
>   'e-mail 'my-email))
>
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/82364adf-fe5d-4c6f-bf33-51852c423371o%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegt1-aR-Bi-Reb-gGouj8sCo%2B7Zun60R3HgUUh0YxKx%2BmA%40mail.gmail.com.


Re: [racket-users] Wills, plumbers, and checking if a port is closed

2020-06-30 Thread Sorawee Porncharoenwase
It doesn't look like will executor will do what you want, since it has to
do with garbage collection rather than port closing.

This could be overkill, but it's possible to construct a custom port (
https://docs.racket-lang.org/reference/customport.html). Is it possible to
construct a new port that wraps your target port inside, and specify the
`close` argument to do whatever you want to do?

On Tue, Jun 30, 2020 at 3:37 PM David Storrs  wrote:

> I have a port that (my current theory says) is being closed when it
> shouldn't, but I'm having trouble isolating exactly where and when.  I
> thought maybe I could do something Rackety to say "as soon as this port
> gets closed, run this function".  I went digging through Wills and Plumbers
> but I'm having trouble grokking it.  Am I headed in the right direction, or
> is there a better way?
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKofeSmxqSs7RUL-PT0my-JcuW9atP2%2BDdj6o1o_hJVrsmw%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegueQkjYUq1NTcyEUv-XMhdAYrbh4o0PVtxqs9BEWOgUoA%40mail.gmail.com.


Re: [racket-users] Re: identifier used out of context

2020-06-07 Thread Sorawee Porncharoenwase
Wow, so block is currently buggy?!

On Sun, Jun 7, 2020 at 3:31 PM Michael Ballantyne <
michael.ballant...@gmail.com> wrote:

> Hah! You're right. The arrow points to the inner definition. But it's even
> worse than that---the value comes from the outer definition! At least for
> `block`, which is what I'm testing with as I haven't copied down your code.
> Try this:
>
> #lang racket
>
> (require racket/block)
>
> (define-syntax-rule (m) (displayln 'old))
>
> (let ()
>   (block (m))
>   (define-syntax-rule (m) 'new)
>   (void))
>
> (and with your macro rather than block)
>
> On Sunday, June 7, 2020 at 4:27:24 PM UTC-6, Sorawee Porncharoenwase wrote:
>>
>> Perhaps I missed something, but the error in the first example is because
>> there’s no expression at the end of let. If I use this code instead, it
>> seems to work fine, with the arrow of m pointing to the “new” one.
>>
>> (define-syntax-rule (m) 'old)
>>
>> (let ()
>>   (list+ (m))
>>   (define-syntax-rule (m) 'new)
>>   (void))
>>
>> The second example perfectly shows why I need
>> internal-definition-context-track, however. Thank you very much.
>>
>> On Sun, Jun 7, 2020 at 7:51 AM Michael Ballantyne 
>> wrote:
>>
>>> >  I am unable to come up with a program where this difference is
>>> significant though
>>>
>>> Here's an example:
>>>
>>> (define-syntax-rule (m) 'old)
>>>
>>> (let ()
>>>   ($list
>>>(m))
>>>   (define-syntax-rule (m) 'new))
>>>
>>>
>>> > So I am curious why internal-definition-context-track is needed.
>>>
>>> A similar example shows the need here:
>>>
>>> ($list
>>>   (define-syntax-rule (m) 5)
>>>   (m))
>>>
>>> Without `internal-definition-context-track` you'll miss the arrow for
>>> `m`. While `m` does indeed get rebound in the `letrec-syntaxes+values`,
>>> that binding has an extra scope, so the reference to `m` (recorded in an
>>> `'origin` property on `5`) doesn't match.
>>>
>>>
>>>
>>> On Sunday, June 7, 2020 at 12:18:26 AM UTC-6, Sorawee Porncharoenwase
>>> wrote:
>>>>
>>>> Thank you so much, Michael! This is very helpful.
>>>>
>>>> I can see that when this form is used within another internal
>>>> definition context, then my version and your version will expand in
>>>> different order, and I agree that yours makes more sense. I am unable to
>>>> come up with a program where this difference is significant though (e.g.,
>>>> one fails while the other doesn’t). “so that names bound by later
>>>> definitions are available” seems to suggest that things like this is not
>>>> supposed to work on my version:
>>>>
>>>> (let ()
>>>>   ($list (define (f x) (g x))
>>>>  (println f))
>>>>   (define (g x) x)
>>>>   (void))
>>>>
>>>> but it actually does…
>>>>
>>>> I also have another question. When should I use
>>>> internal-definition-context-track? Normally, internal definitions are
>>>> expanded into letrec-syntaxes+values, so the bindings don’t actually
>>>> disappear. So I am curious why internal-definition-context-track is
>>>> needed.
>>>>
>>>> Thanks again.
>>>>
>>>> On Sat, Jun 6, 2020 at 8:21 AM Michael Ballantyne <
>>>> michael@gmail.com> wrote:
>>>>
>>>>> Explicitly expanding `e` would ensure that the expansion work only has
>>>>> to happen once, rather than twice. Even so, the fully-expanded syntax will
>>>>> be expanded again in `syntax-local-bind-syntaxes` and in the expansion.
>>>>>
>>>>> As far as I've seen, the only thing that liberal define contexts
>>>>> control is whether definitions of functions that accept keyword arguments
>>>>> expand to a normal `define-values` with runtime handling of keywords, or
>>>>> expand to a collection of macros and function definitions that allow a 
>>>>> more
>>>>> efficient calling convention for first-order calls. The latter expansion
>>>>> doesn't work for contexts like `class` where function definitions are
>>>>> re-interpreted in a way that adds indirection, so it is only enabled in
>>>>> contexts that opt-in.
>>>>>
>>>>> I see more bug in your m

Re: [racket-users] Re: identifier used out of context

2020-06-07 Thread Sorawee Porncharoenwase
Perhaps I missed something, but the error in the first example is because
there’s no expression at the end of let. If I use this code instead, it
seems to work fine, with the arrow of m pointing to the “new” one.

(define-syntax-rule (m) 'old)

(let ()
  (list+ (m))
  (define-syntax-rule (m) 'new)
  (void))

The second example perfectly shows why I need
internal-definition-context-track, however. Thank you very much.

On Sun, Jun 7, 2020 at 7:51 AM Michael Ballantyne <
michael.ballant...@gmail.com> wrote:

> >  I am unable to come up with a program where this difference is
> significant though
>
> Here's an example:
>
> (define-syntax-rule (m) 'old)
>
> (let ()
>   ($list
>(m))
>   (define-syntax-rule (m) 'new))
>
>
> > So I am curious why internal-definition-context-track is needed.
>
> A similar example shows the need here:
>
> ($list
>   (define-syntax-rule (m) 5)
>   (m))
>
> Without `internal-definition-context-track` you'll miss the arrow for `m`.
> While `m` does indeed get rebound in the `letrec-syntaxes+values`, that
> binding has an extra scope, so the reference to `m` (recorded in an
> `'origin` property on `5`) doesn't match.
>
>
>
> On Sunday, June 7, 2020 at 12:18:26 AM UTC-6, Sorawee Porncharoenwase
> wrote:
>>
>> Thank you so much, Michael! This is very helpful.
>>
>> I can see that when this form is used within another internal definition
>> context, then my version and your version will expand in different order,
>> and I agree that yours makes more sense. I am unable to come up with a
>> program where this difference is significant though (e.g., one fails while
>> the other doesn’t). “so that names bound by later definitions are
>> available” seems to suggest that things like this is not supposed to work
>> on my version:
>>
>> (let ()
>>   ($list (define (f x) (g x))
>>  (println f))
>>   (define (g x) x)
>>   (void))
>>
>> but it actually does…
>>
>> I also have another question. When should I use
>> internal-definition-context-track? Normally, internal definitions are
>> expanded into letrec-syntaxes+values, so the bindings don’t actually
>> disappear. So I am curious why internal-definition-context-track is
>> needed.
>>
>> Thanks again.
>>
>> On Sat, Jun 6, 2020 at 8:21 AM Michael Ballantyne 
>> wrote:
>>
>>> Explicitly expanding `e` would ensure that the expansion work only has
>>> to happen once, rather than twice. Even so, the fully-expanded syntax will
>>> be expanded again in `syntax-local-bind-syntaxes` and in the expansion.
>>>
>>> As far as I've seen, the only thing that liberal define contexts control
>>> is whether definitions of functions that accept keyword arguments expand to
>>> a normal `define-values` with runtime handling of keywords, or expand to a
>>> collection of macros and function definitions that allow a more efficient
>>> calling convention for first-order calls. The latter expansion doesn't work
>>> for contexts like `class` where function definitions are re-interpreted in
>>> a way that adds indirection, so it is only enabled in contexts that opt-in.
>>>
>>> I see more bug in your macro: as its very first task, it should check if
>>> `(syntax-local-context)` is `'expression`. If not, it should expand to
>>> `(#%expression )`. This ensures that its expansion is
>>> delayed until the second pass of the surrounding definition context so that
>>> names bound by later definitions are available.
>>>
>>> On Saturday, June 6, 2020 at 4:15:00 AM UTC-6, Sorawee Porncharoenwase
>>> wrote:
>>>>
>>>> Ah, apparently I need syntax-local-identifier-as-binding. Here’s a
>>>> revised code that passes the tests.
>>>>
>>>> (begin-for-syntax
>>>>   (define ((do-it gs ctx) e)
>>>> (let loop ([e e])
>>>>   (define e-expanded (local-expand e
>>>>(list gs)
>>>>(list #'begin
>>>>  #'define-syntaxes
>>>>  #'define-values)
>>>>ctx))
>>>>   (syntax-parse e-expanded
>>>> #:literals (begin define-syntaxes define-values)
>>>> [(begin body ...) #`(begin #,@(map loop (attribute body)))]
>>>> [(define-values (x ...) e)
>>>>  #:with (x* ...) (map syntax-local-identi

Re: [racket-users] Re: identifier used out of context

2020-06-07 Thread Sorawee Porncharoenwase
Thank you so much, Michael! This is very helpful.

I can see that when this form is used within another internal definition
context, then my version and your version will expand in different order,
and I agree that yours makes more sense. I am unable to come up with a
program where this difference is significant though (e.g., one fails while
the other doesn’t). “so that names bound by later definitions are
available” seems to suggest that things like this is not supposed to work
on my version:

(let ()
  ($list (define (f x) (g x))
 (println f))
  (define (g x) x)
  (void))

but it actually does…

I also have another question. When should I use
internal-definition-context-track? Normally, internal definitions are
expanded into letrec-syntaxes+values, so the bindings don’t actually
disappear. So I am curious why internal-definition-context-track is needed.

Thanks again.

On Sat, Jun 6, 2020 at 8:21 AM Michael Ballantyne <
michael.ballant...@gmail.com> wrote:

> Explicitly expanding `e` would ensure that the expansion work only has to
> happen once, rather than twice. Even so, the fully-expanded syntax will be
> expanded again in `syntax-local-bind-syntaxes` and in the expansion.
>
> As far as I've seen, the only thing that liberal define contexts control
> is whether definitions of functions that accept keyword arguments expand to
> a normal `define-values` with runtime handling of keywords, or expand to a
> collection of macros and function definitions that allow a more efficient
> calling convention for first-order calls. The latter expansion doesn't work
> for contexts like `class` where function definitions are re-interpreted in
> a way that adds indirection, so it is only enabled in contexts that opt-in.
>
> I see more bug in your macro: as its very first task, it should check if
> `(syntax-local-context)` is `'expression`. If not, it should expand to
> `(#%expression )`. This ensures that its expansion is
> delayed until the second pass of the surrounding definition context so that
> names bound by later definitions are available.
>
> On Saturday, June 6, 2020 at 4:15:00 AM UTC-6, Sorawee Porncharoenwase
> wrote:
>>
>> Ah, apparently I need syntax-local-identifier-as-binding. Here’s a
>> revised code that passes the tests.
>>
>> (begin-for-syntax
>>   (define ((do-it gs ctx) e)
>> (let loop ([e e])
>>   (define e-expanded (local-expand e
>>(list gs)
>>(list #'begin
>>  #'define-syntaxes
>>  #'define-values)
>>ctx))
>>   (syntax-parse e-expanded
>> #:literals (begin define-syntaxes define-values)
>> [(begin body ...) #`(begin #,@(map loop (attribute body)))]
>> [(define-values (x ...) e)
>>  #:with (x* ...) (map syntax-local-identifier-as-binding
>>   (attribute x))
>>  (syntax-local-bind-syntaxes (attribute x) #f ctx)
>>  #'(define-values (x* ...) e)]
>> [(define-syntaxes (x ...) e)
>>  #:with (x* ...) (map syntax-local-identifier-as-binding
>>   (attribute x))
>>  (syntax-local-bind-syntaxes (attribute x) #'e ctx)
>>  #'(define-syntaxes (x* ...) e)]
>> [e #'(set! acc (cons e acc))]
>>
>> Still not sure if there’s still anything wrong. In particular, do I need
>> to expand e in define-syntaxes? And do I need to use
>> prop:liberal-define-context for gs? (I don’t understand what liberal
>> expansion is even after reading the docs several times) Both of these are
>> done in the implementation of block, but without them, it seems to work
>> equally well.
>>
>> On Fri, Jun 5, 2020 at 6:30 PM Sorawee Porncharoenwase <
>> sorawe...@gmail.com> wrote:
>>
>>> Hi Racketeers,
>>>
>>> I’m creating a macro that collects values in the internal-definition
>>> context. E.g.,
>>>
>>> ($list
>>>  1
>>>  (define x 2)
>>>  x)
>>>
>>> should evaluate to '(1 2).
>>>
>>> Here’s my implementation, and it kinda works:
>>>
>>> #lang racket
>>>
>>> (begin-for-syntax
>>>   (define ((do-it gs ctx) e)
>>> (let loop ([e e])
>>>   (define e-expanded (local-expand e (list gs) #f ctx))
>>>   (syntax-case e-expanded (begin define-syntaxes define-values)
>>> [(begin body ...)
>>>  #`(begin #,@(map loop (syntax->list #'(body

[racket-users] Re: identifier used out of context

2020-06-06 Thread Sorawee Porncharoenwase
Ah, apparently I need syntax-local-identifier-as-binding. Here’s a revised
code that passes the tests.

(begin-for-syntax
  (define ((do-it gs ctx) e)
(let loop ([e e])
  (define e-expanded (local-expand e
   (list gs)
   (list #'begin
 #'define-syntaxes
 #'define-values)
   ctx))
  (syntax-parse e-expanded
#:literals (begin define-syntaxes define-values)
[(begin body ...) #`(begin #,@(map loop (attribute body)))]
[(define-values (x ...) e)
 #:with (x* ...) (map syntax-local-identifier-as-binding
  (attribute x))
 (syntax-local-bind-syntaxes (attribute x) #f ctx)
 #'(define-values (x* ...) e)]
[(define-syntaxes (x ...) e)
 #:with (x* ...) (map syntax-local-identifier-as-binding
  (attribute x))
 (syntax-local-bind-syntaxes (attribute x) #'e ctx)
 #'(define-syntaxes (x* ...) e)]
[e #'(set! acc (cons e acc))]

Still not sure if there’s still anything wrong. In particular, do I need to
expand e in define-syntaxes? And do I need to use
prop:liberal-define-context for gs? (I don’t understand what liberal
expansion is even after reading the docs several times) Both of these are
done in the implementation of block, but without them, it seems to work
equally well.

On Fri, Jun 5, 2020 at 6:30 PM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> Hi Racketeers,
>
> I’m creating a macro that collects values in the internal-definition
> context. E.g.,
>
> ($list
>  1
>  (define x 2)
>  x)
>
> should evaluate to '(1 2).
>
> Here’s my implementation, and it kinda works:
>
> #lang racket
>
> (begin-for-syntax
>   (define ((do-it gs ctx) e)
> (let loop ([e e])
>   (define e-expanded (local-expand e (list gs) #f ctx))
>   (syntax-case e-expanded (begin define-syntaxes define-values)
> [(begin body ...)
>  #`(begin #,@(map loop (syntax->list #'(body ...]
> [(define-values ids e)
>  (begin
>(syntax-local-bind-syntaxes (syntax->list #'ids) #f ctx)
>e-expanded)]
> [(define-syntaxes ids e)
>  (begin
>(syntax-local-bind-syntaxes (syntax->list #'ids) #'e ctx)
>#'(begin))]
> [e #'(set! acc (cons e acc))]
>
> (define-syntax ($list stx)
>   (define gs (gensym))
>   (define ctx (syntax-local-make-definition-context))
>   (syntax-case stx ()
> [(_ body ...)
>  #`(let ([acc '()])
>  #,@(map (do-it gs ctx) (syntax->list #'(body ...)))
>  (reverse acc))]))
>
> ($list 1
>(define x 2)
>x)
>
> There are problems though. If I change define to define2 as follows:
>
> (define-syntax-rule (define2 x y)
>   (define-values (x) y))
>
> ($list 1
>(define2 x 2)
>x)
>
> Then I get the “identifier used out of context” error. This doesn’t make
> sense to me at all. My define2 should be very similar to define…
>
> There’s also another weird problem:
>
> ($list 1
>(define-syntax (x stx) #'2)
>x)
>
> The above works perfectly, but by wrapping x with #%expression, I get the
> “identifier used out of context” error again.
>
> ($list 1
>(define-syntax (x stx) #'2)
>(#%expression x))
>
> What did I do wrong?
>
> Thanks!
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtN-s79H1sLV0qo93Dq5uzD3tR6-ZRT1UCLNF7VAqfM0Q%40mail.gmail.com.


[racket-users] identifier used out of context

2020-06-05 Thread Sorawee Porncharoenwase
Hi Racketeers,

I’m creating a macro that collects values in the internal-definition
context. E.g.,

($list
 1
 (define x 2)
 x)

should evaluate to '(1 2).

Here’s my implementation, and it kinda works:

#lang racket

(begin-for-syntax
  (define ((do-it gs ctx) e)
(let loop ([e e])
  (define e-expanded (local-expand e (list gs) #f ctx))
  (syntax-case e-expanded (begin define-syntaxes define-values)
[(begin body ...)
 #`(begin #,@(map loop (syntax->list #'(body ...]
[(define-values ids e)
 (begin
   (syntax-local-bind-syntaxes (syntax->list #'ids) #f ctx)
   e-expanded)]
[(define-syntaxes ids e)
 (begin
   (syntax-local-bind-syntaxes (syntax->list #'ids) #'e ctx)
   #'(begin))]
[e #'(set! acc (cons e acc))]

(define-syntax ($list stx)
  (define gs (gensym))
  (define ctx (syntax-local-make-definition-context))
  (syntax-case stx ()
[(_ body ...)
 #`(let ([acc '()])
 #,@(map (do-it gs ctx) (syntax->list #'(body ...)))
 (reverse acc))]))

($list 1
   (define x 2)
   x)

There are problems though. If I change define to define2 as follows:

(define-syntax-rule (define2 x y)
  (define-values (x) y))

($list 1
   (define2 x 2)
   x)

Then I get the “identifier used out of context” error. This doesn’t make
sense to me at all. My define2 should be very similar to define…

There’s also another weird problem:

($list 1
   (define-syntax (x stx) #'2)
   x)

The above works perfectly, but by wrapping x with #%expression, I get the
“identifier used out of context” error again.

($list 1
   (define-syntax (x stx) #'2)
   (#%expression x))

What did I do wrong?

Thanks!

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtJKvcG0kMFp1k2yn8HfGTo5s7z2U2uW2fHF2qa1FQ5_g%40mail.gmail.com.


Re: [racket-users] Re: Practical HTTP requests?

2020-05-17 Thread Sorawee Porncharoenwase
I did a web scraping in Racket a couple of months ago, and I agree that it
is painful. On the bright side, Bogdan seems to start working on a practical
requests-like library  due to
this thread, so we should have a good practical HTTP request library soon
:)

On Sun, May 17, 2020 at 2:09 PM Brian Adkins  wrote:

> Sorry - missed the fact that you already found the cookie library :)
>
> On Sunday, May 17, 2020 at 5:08:32 PM UTC-4, Brian Adkins wrote:
>>
>> I spent many years developing in Ruby before switching to Racket, so I
>> understand the appeal of a "batteries included" language. Python excels in
>> this area. If you're weighting the "batteries included" aspect very high,
>> then Racket may not be suitable for you at this time, but in that case, I
>> expect you'd just stick with Python.
>>
>> If you're patient, I think you may find many compelling reasons to
>> consider Racket. I won't list them here (other than the fact that the
>> community alone is compelling enough to invest more time learning the
>> language), or advocate for the language in general, but if you decide to
>> check it out more thoroughly later, another library that may be of interest
>> is:
>>
>> https://docs.racket-lang.org/cookies/index.html
>>
>> I've been developing web applications in Racket for the last year and a
>> half, or so, but I've been focused on server-side functionality, and I've
>> either found a Racket package that does what I need directly, or I've found
>> a set of them that allow me to easily layer the extra code on top that I
>> need. I was used to the Rails framework, so I thought it would be tough
>> switching to Racket, but in hindsight, it was trivial.
>>
>> I will be doing more web scraping soon for some data science
>> applications, and given what Racket provides currently, it will be easy to
>> write something that fulfills the requirements you listed in your first
>> post, although I have no need for proxy servers personally.
>>
>> Brian
>>
>> On Sunday, May 17, 2020 at 4:02:59 PM UTC-4, fixpoint wrote:
>>>
>>> Thanks, but that library does not support proxies. Oh well, my Racket
>>> adventures have come to an end as I’ll be unable to convince others at work
>>> to try it without a practical, batteries included http library.
>>>
>>> On Sunday, May 17, 2020 at 2:14:19 PM UTC-5, Jens Axel Søgaard wrote:

 Take a look at the `http` package.

 https://docs.racket-lang.org/http/index.html

 I believe it can be used to receive and send cookies (and other
 headers), but
 I don't know how much is automatic.

 /Jens Axel

 Racket Stories
 https://racket-stories.com



 Den søn. 17. maj 2020 kl. 17.51 skrev fixpoint :

> I was under the incorrect impression that net/url did not support
> HTTP 1.1. I suspect I stumbled upon some out of date information on
> stackoverflow. Thanks for pointing me in the right direction. Using
> net/url, net/cookies, and json, I hacked the following code (please
> be gentle, it is literally the first lines of Racket I've ever written).
> There are two key problems with this code:
>
>1. Because cookies handling is not part of net/url, my use of
>get-pure-port/headers is not able to see cookies, and thus save
>them, in any of the 3xx redirect responses.
>2. I need a post-pure-port/headers equivalent, so I can post data
>and reuse the connection. It looks like you can only reuse connections 
> in
>net/url with only get-pure-port/headers.
>
> Am I missing any other libraries out there?
>
> #lang racket
>
> (require json
>  net/head
>  net/url
>  net/cookies/user-agent)
>
>
> (define (get-json-request url #:connection conn)
>   (define req-headers
> (let ([cookies (cookie-header url)])
>   (cond [(false? cookies) '()]
> [else (list (format "Cookie: ~a" cookies))])))
>   (display (format "Headers sent were:\n ~a\n" req-headers))
>   (define-values
> (in-port resp-headers)
> (get-pure-port/headers url req-headers #:connection conn
> #:redirections 1))
>   (extract-and-save-cookies! (map string->bytes/utf-8 (string-split
> resp-headers "\r\n")) url)
>   (display (format "\nReceived headers were:\n ~a" resp-headers))
>   (read-json in-port))
>
>
> ;; Start a session
> (define conn (make-http-connection))
>
> ;; Make a request that will force server to set cookies
> (displayln (jsexpr->string
> (get-json-request
>  (string->url "
> https://postman-echo.com/cookies/set?foo1=bar1=bar2;)
>  #:connection conn)))
>
> ;; Make another request to see what cookies we sent server
> (displayln "\n--\n")
> (displayln 

Re: [racket-users] Make your computer talk in Racket on Windows in 5 lines

2020-05-16 Thread Sorawee Porncharoenwase
On Mac, there’s a say command, so this would do it.

(system "say \"hello world\"")

When I had a Linux machine, I recalled using a command named espeak, which
is similar to say on Mac.

On Sat, May 16, 2020 at 11:15 AM Sam Phillips 
wrote:

> Stephen De Gabrielle and I are wondering if any Mac or Linux users
> have similar short programs to make their computer talk.
>
>
> https://www.reddit.com/r/Racket/comments/gkz3yi/make_your_computer_talk_in_racket_on_windows_in_5/
>
> Cheers,
> Sam
>
> ->8->8-
> #lang racket/base
>
> (require ffi/com)
>
> (define voice
>   (com-create-instance "SAPI.SPVoice"))
>
> (com-invoke voice "Speak" "hello world")
>   ->8->8-
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAHsjV0zG4mFbryy4uYWHS-%3DvP%3D10_bCjFxBR5wS%2BUkaFuLkx5Q%40mail.gmail.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvCXTUCVBqA2WcViWC1AjbMvdbJuE_NbF0y5%2BHUzKjc2g%40mail.gmail.com.


Re: [racket-users] at sign in scribble

2020-05-15 Thread Sorawee Porncharoenwase
See
https://docs.racket-lang.org/scribble/reader.html?q=escape#%28part._.The_.Scribble_.Syntax_at_a_.Glance%29

Either of this works:
- @bold{a@"@"b}
- @bold|{a@b}|



On Fri, May 15, 2020 at 5:04 AM Hendrik Boom  wrote:

> I hae not been able to figure out from the scribble documentation how to
> produce a document containing an at sign.
>
> Just putting the desired at sign into the source file of course doesn't
> work, since the at-reader intercepts it.
>
> -- hendrik
>
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200515120418.yunluqvjoshcf4lj%40topoi.pooq.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcueguGREyxJAqGnP5YfwZow7QwojmmVsGNoMGAa%2BDKLsDKQQ%40mail.gmail.com.


Re: [racket-users] Re: Racket Program doesn't save

2020-05-11 Thread Sorawee Porncharoenwase
Does tst.rkt get created? I use racket-7.7-x86_64-macosx and run macOS
Catalina too, but could not reproduce the problem.

On Mon, May 11, 2020 at 2:56 PM Sai Ganesh Buchireddy 
wrote:

> After I save the file and try to close Dr. Racket, I get the msg saying
> the file is not saved as shown in the 2nd image.
>
> On Tuesday, May 12, 2020 at 3:23:40 AM UTC+5:30, Sai Ganesh Buchireddy
> wrote:
>>
>> I'm trying to save a program in Dr. Racket but it doesn't seem to work
>> for some reason. I'm using version racket-7.7-x86_64-macosx & running macOS
>> Catalina Version 10.15.3
>>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/342be18c-653b-4b3c-a157-7201cf698da7%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcueguBVN0KTaL%2BJimv%2B%3DX7-ctB8Jyr_Xy6qnYH_eU%2BF9ZM_g%40mail.gmail.com.


Re: [racket-users] for/set

2020-05-08 Thread Sorawee Porncharoenwase
There’s a search bar in the top left of every doc page. Typing for/set and
enter will show you this search result page
. Here, the first
result

is what you want.

On Fri, May 8, 2020 at 4:07 PM Hendrik Boom  wrote:

> Where is for/set documented?  What does it do?
>
> It is mentioned in the typed Racket menual, but oly to say it has
> the same meaning as the unannotated version.
>
> -- hendrik
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200508230711.llav2273e2ntzegz%40topoi.pooq.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvGez14Nxs9XhgoM_3tNViqWLtbhvikLnN%3D0zH4GEKY%2Bg%40mail.gmail.com.


Re: [racket-users] for/stream and values

2020-05-03 Thread Sorawee Porncharoenwase
>
> Thank you for the package! So, do I understand correcty that it is
> impossible to produce multi-valued streams with for/stream? If so, maybe
> it's worth adding a note about it to the documentation of for/stream?
>

That is correct. Feel free to submit a PR to improve the documentation. You
will need to edit this file:
https://github.com/racket/racket/blob/master/pkgs/racket-doc/scribblings/reference/sequences.scrbl#L1186


> Also, I notice in the manual of your package that you mention that
> generators are inefficient in the default implementation of
> Racket. Since I'm using generators too, I'm curious about the
> performance implications - where can I read more about it?
>

I don't think it's written anywhere explicitly, but you can take a look at
https://blog.racket-lang.org/2020/02/racket-on-chez-status.html in the
section "Run-Time Performance Redux", which compares the performance of
generators in Racket 3m vs Racket CS.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsWKs4eBLGXWpOggGtrnJBfy6SfCQnT%2BMP3XePmZVdiBg%40mail.gmail.com.


Re: [racket-users] for/stream and values

2020-05-02 Thread Sorawee Porncharoenwase
I just created a package that helps creating a stream of multiple values a
couple of weeks ago. You might find it useful:
https://docs.racket-lang.org/stream-values/

On Sat, May 2, 2020 at 3:38 PM Yury Bulka 
wrote:

> (sorry for the typos - obviously, it should be racket/stream)
>
> --
> Yury Bulka
> https://mamot.fr/@setthemfree
> #NotOnFacebook
>
>
>
> Yury Bulka  writes:
>
> > Hello everyone,
> >
> > I have a question about creating a steam that yields multiple values on
> > each iteration. Given something like:
> >
> > (require racket/strema)
> >
> > (define my-stream (for/stream ([i (in-range 1 10)])
> > (values "hi" i)))
> >
> > When I'm trying to:
> >
> > (let-values ([(a b) (stream-ref my-stream 0)])
> > (printf "~v: ~v" a b))
> >
> > I'm getting:
> >
> > ; result arity mismatch;
> > ;  expected number of values not received
> > ;   expected: 1
> > ;   received: 2
> > ;   values...:
> > ;"hi"
> > ;2
> > ; Context:
> > ;
> /nix/store/z4mpvw1p6whq454lmjshbdr6472sdbr3-racket-7.6/share/racket/collects/racket/repl.rkt:11:26
> >
> > Similarly:
> >
> > (for ([(a b) my-stream])
> > (printf "~v: ~v" a b))
> >
> > leads to:
> >
> > ; result arity mismatch;
> > ;  expected number of values not received
> > ;   expected: 1
> > ;   received: 2
> > ;   values...:
> > ;"hi"
> > ;1
> > ; Context:
> > ;  tcp-accepted:1:1 for-loop
> > ;  top-level:1:1 [running body]
> > ;
> /nix/store/z4mpvw1p6whq454lmjshbdr6472sdbr3-racket-7.6/share/racket/collects/racket/repl.rkt:11:26
> >
> > Documentation on stream-ref specifically mentions that it can have
> > multiple values:
> >
> https://docs.racket-lang.org/reference/streams.html?q=stream-ref#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-ref%29%29
> >
> > What am I doing wrong here?
> >
> > P.S. The context is that I'm trying to create a function that would
> > return results from an API as a stream that can be iterated with the for
> > family of forms, and would yield multiple values per iteration.
> >
> > --
> > Yury Bulka
> > https://mamot.fr/@setthemfree
> > #NotOnFacebook
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/87ees2nerz.fsf%40privacyrequired.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvfgFo1SPQq6Dh7ncrgCpHDWFBArCSf99WHkOcY5Jjv1A%40mail.gmail.com.


Re: [racket-users] Questions about working on DrRacket and gui

2020-05-01 Thread Sorawee Porncharoenwase
Sam just suggested me in the other email thread that a much easier way to
do things is to download and install Minimal Racket, then install DrRacket
from source.

On Fri, May 1, 2020 at 7:59 AM Dexter Lagan  wrote:

> Hi,
>
>   I apologize in advance if my questions are naïve or have been asked
> previously. I read the 'Building Racket from Source' guide and couldn't
> find answers to some specific questions. I'm new to Git.
>
>   I'd like to download DrRacket's source and profile it, say to improve
> scrolling performance or track this post-startup lock-up :
> - Do I need to download the entire Racket tree in order to build DrRacket?
> - Is the DrRacket's built-in profiler solid enough to handle profiling
> DrRacket itself?
> - Modules in DrRacket's repo don't always have very telling names. Is
> there a document describing what each module does?
> - If I make a change to a source file on my system, yet somebody else
> modifies the same file on their local system. Say both of our changes are
> accepted by whoever manages commits, how will accepted changes to the code
> merged?
>
>   Also, say I have a suggestion regarding how DrRacket handles compiling
> standalone executables, do I still need to create an issue on its Github?
> For work I compile to standalone all day long, and I really wish DrRacket
> didn't zip the resulting file (it would be better to have the .exe file in
> an automatically created /bin or /output folder). Zipping the file takes
> time, and I have to unzip it each time, which takes more time, this piles
> up when done every few minutes, all day long. I could use raco exe, but I'd
> rather stay in DrRacket, and I'm sure many people would rather have the
> default behavior to not zip, just to have single responsibility on the
> compile function.
>
>  One last questions: I have encountered differences in the behavior of
> macros between the REPL, a launcher and a standalone executable for
> distribution. Is there a document outlining the deeper differences between
> these three ways of executing Racket code?
>
> Have a great weekend, wherever you're confined,
>
> Dexter
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CACUENr%2B%3Drr87rehZHQyDX%2BusXBZHdCY_46-pkKTuotj6HRwffg%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsm%2BiZV10KtB46jG%2B2-jAj4Hktotd%3DuXT9zO9bQ_5p78A%40mail.gmail.com.


Re: [racket-users] Reducing parentheses without language damage.

2020-04-30 Thread Sorawee Porncharoenwase
>
> I hate being at the mercy of whatever editor I'm stuck using.


I agree with this in principle, but in practice, it's really a matter of
what mainstream editors support. Editors in the past don't universally
support automatic indentation, and I could imagine a criticism like
"Indentation sucks, because I hate being at the mercy of whatever editor
I'm stuck using." But now, automatic indentation is universal, and the
criticism goes away.


> I stongly recommend that we get a language with less of a
> parenthesis problem so that code is readable without having to haul
> it into a specialised editor.
>

Personally, I don't find parenthesis makes code unreadable by itself. The
rightward drift, in my opinion, is the real problem. I believe that
`define*` that I proposed at
https://github.com/racket/rhombus-brainstorming/issues/46 will somewhat
mitigate the problem.

In an old List I used '/' for this, so i got expressions like
>(if a b / if c d / let s t /if s foo bar)
>

Using `/` to reduce parentheses looks nice once it's written down, but my
concern is that it might not be easily editable. In fact, it ironically
looks like this notation needs an extra support from editors to consider
`/` as a delimiter.

To clarify what I mean: non S-exp languages usually have a line as a unit
of code, so editors need to support "jump to the beginning/end of line"  to
make editing pleasant. S-exp languages in contrast has a parenthesized
expression as a unit of code, so editors need to support "jump to a
matching parenthesis" to make editing pleasant. In your notation, it looks
like editors need to also support "jump to closest /" to make editing
pleasant.

Also, does it actually make code more readable? I guess I'm not accustomed
to it, and might find it easier to read it once I am.


> There must be some # code we could use for this (I believe one
> has already been mentioned on this list sometime in the past year
> os so) but this symbol tends to become *so* prevalent that it
> should ideally feel like a single character with a dostinctieve
> apearance.
>

This is Nia's parendown: https://docs.racket-lang.org/parendown/index.html

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsYr6KKeZg5sV1ocgcywnCTbi8rf_gB5_MiQG9%3D_W_cFQ%40mail.gmail.com.


Re: [racket-users] on reducing barriers in the Racket community

2020-04-30 Thread Sorawee Porncharoenwase
I have debugging disabled, but my parenthesis highlighting is NOT disabled.
Are we talking about the same parenthesis highlighting? Can you attach the
screenshot of this "parenthesis highlighting is also disabled" to the
mailing list?

On Thu, Apr 30, 2020 at 12:36 AM Dexter Lagan  wrote:

>   There’s one thing I noticed: if debugging is disabled, then parenthesis
> highlighting is also disabled (as well as other visual aids, if I remember
> well?). The editor also feels faster because of this, but navigating
> parentheses becomes slightly more tedious without it.
>
> Dex
>
> On Apr 25, 2020, at 3:25 PM, sleepnova  wrote:
>
> 
> That may help to reduce misimpression. And plus, maybe append some message
> to error message to inform user that they can turn on errortrace if they
> need more detailed debugging information, when errortrace doesn't enabled.
>
> To be clarify, what you mentioned is "Preserve errortrace" option, what
> about "Debugging" option, is it a must enabled option in a non-debugging
> run?
>
> <截圖 2020-04-25 下午9.22.20.png>
>
>
> Sorawee Porncharoenwase  於 2020年4月25日 週六
> 下午8:17寫道:
>
>> It could go either way, no? I've also heard a lot of people complaining
>> that debugging Racket programs is difficult because the stack trace is not
>> useful, and this is because they use the command-line version which doesn't
>> have errortrace enabled (by default).
>>
>> Perhaps what you really are complaining is that the option to
>> enable/disable errortrace is not easily discoverable. Would it help if at:
>>
>> 
>>
>>
>> the text is changed from `racket, with debugging` to `racket, with
>> debugging (slower)`. And the texts are linkified so that when `racket` is
>> clicked, it leads you to the non-detailed language setting, and when `with
>> debugging (slower)` is clicked, it leads you to the detailed language
>> setting?
>>
>> On Sat, Apr 25, 2020 at 3:51 AM Liwei Chou  wrote:
>>
>>> Thanks Dexter,
>>>
>>> Yes, now I know it’s due to the debugging and tracing configuration.
>>> After turn off debugging and profiling, it becomes.
>>>
>>> cpu time: 20 real time: 20 gc time: 0
>>>
>>> If disable Preserve stacktrace also, I got.
>>>
>>> cpu time: 7 real time: 7 gc time: 0
>>>
>>> Which is pretty decent, 16x acceleration.
>>>
>>> It's not a problem for me now. However, this behavior may give some new
>>> users the wrong impression that the language may not be very efficient,
>>> which may make some people choose not to continue trying it.
>>>
>>> From the perspective of increasing adoption and reducing barriers, it's
>>> not a good thing.
>>>
>>> If Racket team can consider making normal run and debug run using
>>> different default settings, which conventional development environments
>>> usually do, that can easily solve this problem.
>>>
>>> Dexter Lagan於 2020年4月25日星期六 UTC+8下午5時17分31秒寫道:
>>>>
>>>> Hi Liwei,
>>>>
>>>>   I believe disabling debugging and tracing does accelerate the
>>>> evaluation quite a bit from inside DrRacket. On my system, it seems to be
>>>> running my code at the same speed as the main racket binary.
>>>>
>>>> Dex
>>>>
>>> --
>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/cb5e4fa5-2766-4242-aff5-8933bee637c6%40googlegroups.com
>>> <https://groups.google.com/d/msgid/racket-users/cb5e4fa5-2766-4242-aff5-8933bee637c6%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
>
> --
> - sleepnova
> 呼叫小黃創辦人 & CEO
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CABa2-7O1cv_sOrGRWxoHetdwDLiKLSOpZdt8T3YPj4yQQome7w%40mail.gmail.com
> <https://groups.google.com/d/msgid/racket-users/CABa2-7O1cv_sOrGRWxoHetdwDLiKLSOpZdt8T3YPj4yQQome7w%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvn3vdkPLqh1fF_UXD1tiuqdytp_cFLhLqmroTo%3DobZqA%40mail.gmail.com.


Re: [racket-users] Rhombus project plan

2020-04-29 Thread Sorawee Porncharoenwase
(Not directly related to Rhombus) Speaking of “how to contribute”, I find
that it is not friendly at all to setup stuff in order to contribute to
Racket core and main distribution. According to
https://blog.racket-lang.org/2017/09/tutorial-contributing-to-racket.html,
if I want to make a change to, say, https://github.com/racket/math, I
should start with:

$ raco pkg update --no-setup --catalog https://pkgs.racket-lang.org math
$ raco pkg update --clone math

The estimated time to run the above two commands is ONE HOUR! The second
command in particular seems to compile every Racket packages (why does it
need to do that?!?) which takes a lot of time.

I really feel turned off by the thought of having to wait for one hour
(with my laptop becoming very hot from CPU usage at 100%, and I can’t
really do other work that has heavy computation during this period). So I
usually skip this step, but that also means I can’t test my PR locally.
Instead, I need to rely on CI to catch any mistake that I made. The obvious
drawback is that it generates a lot of noises to people watching the repo
and some repos don’t even have CI setup…

(In some cases, I can test locally by isolating the changes to a new Racket
program, but that’s not always possible.)

Is it possible to improve this somehow?







On Wed, Apr 29, 2020 at 2:48 PM Matthew Flatt  wrote:

> At Wed, 29 Apr 2020 12:46:50 -0400, David Storrs wrote:
> > In related news, a question for the list:  Once I have a handle on this,
> I
> > would like to write a "How to Contribute to Racket Documentation" guide.
> > Where would be the right place for this?  Should it be an expansion to an
> > existing document (if so, which), an entirely new one, or...?
>
> I suggest making it part of "Building, Distributing, and Contributing
> to Racket":
>
>  https://docs.racket-lang.org/racket-build-guide/index.html
>
> which is also rendered as
>
>  https://github.com/racket/racket/blob/master/build.md
>
>
> The source is
>
>  https://github.com/racket/racket/tree/master/pkgs/racket-build-guide
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/5ea9f62b.1c69fb81.d0413.1033SMTPIN_ADDED_MISSING%40gmr-mx.google.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsVu9Je%3D_7Md3aD1nC5DEyKV__7_i3oHadZk5168nX87A%40mail.gmail.com.


Re: [racket-users] on reducing barriers in the Racket community

2020-04-25 Thread Sorawee Porncharoenwase
>
> I like the idea of adding a "with debugging" to the banner when a program
> is run in DrRacket, but I´m not sure it is possible.
>

It current exists already! The screenshot I attached above is from the
actual DrRacket when debugging is enabled.


> (It would be even better if the user can click it and go to the help page
> about the configuration of the language). But I'm not sure it is possible.
>

Right, and that's my proposal. Make it a link, put the word "slow" there to
draw attention. I think it would be nice if the language configuration
control is self-explanatory so that we don't need the help page.


> Another possibility is to have two "Run" buttons, a normal "Run" button
> and a "Run fast" button. The problem is that too many buttons make the UI
> confusing for beginners.
>

I considered this possibility too and reached the same conclusion. Also,
I'm not sure if multiple "Run" buttons make sense for every language 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegunm5ThVbZgHnbEY1pDjoh8ne-f0HH0vEPvCiYwMQGMBQ%40mail.gmail.com.


Re: [racket-users] on reducing barriers in the Racket community

2020-04-25 Thread Sorawee Porncharoenwase
It could go either way, no? I've also heard a lot of people complaining
that debugging Racket programs is difficult because the stack trace is not
useful, and this is because they use the command-line version which doesn't
have errortrace enabled (by default).

Perhaps what you really are complaining is that the option to
enable/disable errortrace is not easily discoverable. Would it help if at:

[image: Screen Shot 2020-04-25 at 05.11.29.png]

the text is changed from `racket, with debugging` to `racket, with
debugging (slower)`. And the texts are linkified so that when `racket` is
clicked, it leads you to the non-detailed language setting, and when `with
debugging (slower)` is clicked, it leads you to the detailed language
setting?

On Sat, Apr 25, 2020 at 3:51 AM Liwei Chou  wrote:

> Thanks Dexter,
>
> Yes, now I know it’s due to the debugging and tracing configuration. After
> turn off debugging and profiling, it becomes.
>
> cpu time: 20 real time: 20 gc time: 0
>
> If disable Preserve stacktrace also, I got.
>
> cpu time: 7 real time: 7 gc time: 0
>
> Which is pretty decent, 16x acceleration.
>
> It's not a problem for me now. However, this behavior may give some new
> users the wrong impression that the language may not be very efficient,
> which may make some people choose not to continue trying it.
>
> From the perspective of increasing adoption and reducing barriers, it's
> not a good thing.
>
> If Racket team can consider making normal run and debug run using
> different default settings, which conventional development environments
> usually do, that can easily solve this problem.
>
> Dexter Lagan於 2020年4月25日星期六 UTC+8下午5時17分31秒寫道:
>>
>> Hi Liwei,
>>
>>   I believe disabling debugging and tracing does accelerate the
>> evaluation quite a bit from inside DrRacket. On my system, it seems to be
>> running my code at the same speed as the main racket binary.
>>
>> Dex
>>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/cb5e4fa5-2766-4242-aff5-8933bee637c6%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvJUgbWvYFbtxYv2HUYCZaJwWtp5HdmUR7N-Nh_bp4UOg%40mail.gmail.com.


[racket-users] DrRacket's dark mode: anyone familiar with Windows internals?

2020-04-25 Thread Sorawee Porncharoenwase
Hi everyone,

DrRacket's dark mode currently doesn't work on Windows. If you know Windows
internals and would like to help, you can participate at
https://github.com/racket/drracket/issues/235.

-- Forwarded message -
From: Robby Findler 
Date: Fri, Apr 24, 2020 at 7:32 PM
Subject: Re: [racket/drracket] Visibility issues with Dr Racket and dark
themes (#235)
To: racket/drracket 
Cc: sorawee , Mention 


Yeah, the windows situation isn't great. I think that basically all of the
problems there can be traced to not knowing how to implement this function
under windows:

https://docs.racket-lang.org/mrlib/White_on_Black_Panel_Predicate.html

If you have knowledge of windows internals or the strength to dig through
the various google results on the topic and come up with something, that
would be huge!

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegs%2B0r2wTL7bz0%3DL4avxSNiE%3DnbMtp3At4798GDc62tucA%40mail.gmail.com.


Re: [racket-users] Gradual Typed Racket?

2020-04-17 Thread Sorawee Porncharoenwase
>
> My understanding is that contract-out only provides protection against
> inappropriate calls from clients *outside* the module, whereas
> define/contract enforces the contract against everyone, including things
> inside the module.  Do I have that right?
>

I think that's correct. Note though that the implication is that
define/contract could produce a much more expensive code, especially for
recursive function, since it will need to check against the contract for
every iteration.


> On a related topic, I don't understand the concept of positive and
> negative blame.  Can someone fill me in?
>

I always forget which is positive and negative, so I won't use the terms
here (and too lazy to lookup). But roughly, suppose you attach a function
contract (-> number? string?) to a function value, then there are mainly
two ways things could go wrong.

1. Client uses the function incorrectly by calling it with non-number.
2. The function itself returns a non-string.

A blame would indicate whose party is at fault when a contract is
violated--caller or the function itself.


>
>
>> Here's an example to play with. Submod A provides two functions: f0 is
>> made with define/contract and f1 with contract-out.
>>
>> ```
>>   #lang racket
>>
>>   (module A racket
>> (define/contract (f0 x)
>>   (-> natural? natural?)
>>   x)
>>
>> (define (f1 x)
>>   x)
>>
>> (provide f0)
>> (provide (contract-out [f1 (-> natural? natural?)])))
>>
>>   (module B racket
>> (require (submod ".." A))
>> (f0 'hello)
>> #;(f1 'hello))
>>
>>   (require 'B)
>> ```
>>
>> If B makes a mistake with f0, the error blames submod A.
>> But if B makes a mistake with f1, the error blames B.
>>
>>
>> The contract library makes these blame errors internally. I don't
>> think there's any way to customize short of using `contract` directly.
>>
>> > Is it related to this part of the documentation of `contract-out`
>> > (
>> https://docs.racket-lang.org/reference/attaching-contracts-to-values.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._contract-out%29%29
>> )
>> > - which I admittedly don't understand:
>> >
>> > "The implementation of contract-out
>> > <
>> https://docs.racket-lang.org/reference/attaching-contracts-to-values.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._contract-out%29%29
>> >
>> > uses syntax-property
>> > <
>> https://docs.racket-lang.org/reference/stxprops.html#%28def._%28%28quote._~23~25kernel%29._syntax-property%29%29
>> >
>> > to attach properties to the code it generates that records the syntax of
>> > the contracts in the fully expanded program. Specifically, the symbol '
>> > provide/contract-original-contract is bound to vectors of two elements,
>> the
>> > exported identifier and a syntax object for the expression that produces
>> > the contract controlling the export."
>>
>> I was only thinking of the "blaming: " part of error messages.
>>
>> Both define/contract and contract-out can print the whole contract; I
>> don't think this syntax-property gives contract-out any advantage
>>
>> (Sadly, the whole contract is sometimes too big to help me find a
>> problem.)
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAFUu9R5BMG5ZFVrddrJ-6uceV%2B3936ZudE-8ESObycw9B%2BRjcg%40mail.gmail.com
>> .
>>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKof2M%2BHuCf%2B2hfTKbVxCxGEb1Vtx%2BaXehYNZXhttpgMNPA%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegskOV0cOQ8xYjTmbED2XA8dvZj9OkY_aFP0_7d28Lho3g%40mail.gmail.com.


Re: [racket-users] rename-in issue

2020-04-09 Thread Sorawee Porncharoenwase
There are two colliding names. make and interface-version. As shown in the
error message, you fixed one but not the other.

(require net/url
 web-server/dispatchers/filesystem-map
 web-server/dispatchers/dispatch-files
 (rename-in web-server/dispatchers/dispatch-sequencer
[make make*]
[interface-version interface-version*]))

works for me.

On Thu, Apr 9, 2020 at 2:04 AM Lucas Liendo  wrote:

> Hi everyone! I've a very dumb question (as still not very experienced
> Racket programmer), I'm doing the following:
>
> (require net/url
>  web-server/dispatchers/filesystem-map
>  (rename-in web-server/dispatchers/dispatch-files
> (make dispatch-files))
>  (rename-in web-server/dispatchers/dispatch-sequencer
> (make dispatch-sequencer)))
>
> As you can see `make` is defined both in
> `web-server/dispatchers/dispatch-files` and
> `web-server/dispatchers/dispatch-sequencer` and I think that's the
> reason for this error:
>
> /tmp/rename-example.rkt:7:20: module: identifier already required
>   at: interface-version
>   in: web-server/dispatchers/dispatch-sequencer
>   location...:
>/tmp/rename-example.rkt:7:20
>
> Traceback continues but I think that's enough. So is there a
> workaround to this? I'd really like to do a rename instead of using
> `prefix-in`. Shouldn't this error not happen as it defeats `rename-in`
> purpose at all?
>
> --
> Cheers,
> Lucas.
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CABCAxXuZmGguei3gsfeVOcWUHZP52JR0ciULo%3DeFKGraNqADAA%40mail.gmail.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsuAgWqQ5NJX94NastjC%2BJSo6MS2-NydTSc56dC__6wvg%40mail.gmail.com.


Re: [racket-users] Suggestions for "The Racket Guide"

2020-04-08 Thread Sorawee Porncharoenwase
Thoughts:

- I take a look at the compiled HTML document. It doesn't seem suffice to
only change JavaScript because the information about "what is the input" is
pretty much lost at the HTML level.
- IIUC, Scribble targets older version of HTML (HTML4?), so it doesn't
really care about the semantics of tags -- only the appearance is
considered. It might be possible to add an ad-hoc hack to make this feature
work, but it would be even better to follow the modern HTML practice in the
first place, which would make these kind of customization trivial.

On Wed, Apr 8, 2020 at 10:09 AM Ben Greenman 
wrote:

> On 4/8/20, Stephen De Gabrielle  wrote:
> > That’s a good suggestion! Do you know the relevant JavaScript we can try
> it
> > out with. Might be an easy PR.
> >
>
> Beware that snippets are not always self-contained.
>
> A button should grab any requires and earlier code needed to make the
> example run. That'd be very very useful --- but maybe not so easy.
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAFUu9R5QLaMvnMh4krLZJTBHz%3Dbo1aLv%3DYkS1amF-2yJU55-aw%40mail.gmail.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsRAXZ8jOTY0Mt52i6X_BD5N%3DjCO8ypyCYrAjBDZomfRQ%40mail.gmail.com.


Re: [racket-users] Best way to handle different versions of Racket?

2020-03-30 Thread Sorawee Porncharoenwase
The problem with shadowing is more than that. Suppose you somehow want to
shadow add1 by making it add 2 instead.

(define add1 (compose add1 add1))

However, this will not work, resulting in the following error:

add1: undefined;
 cannot reference an identifier before its definition

because blue add1 refers to red add1, not Racket’s add1.

So you really need to either rename Racket’s add1 to something else, or
define your add1 with another name. The first approach would be something
like:

(require (only-in racket [add1 @add1]))
(define add1 (compose @add1 @add1))

and the second approach would be something like:

(define @add1 (compose add1 add1))



On Mon, Mar 30, 2020 at 12:17 PM Siddhartha Kasivajhula 
wrote:

> That looks great, thanks! Re: shadowing, I don't plan to re-provide
> string-append-immutable -- only use it internally within the module, so
> shadowing should be OK, right?
> Re: reason to use it - performance. I'm applying the string-append
> operation in a pairwise way over input sequences, and re-converting to
> immutable at each step appears to have a measurable cost.
>
>
> On Mon, Mar 30, 2020 at 12:11 PM Sorawee Porncharoenwase <
> sorawee.pw...@gmail.com> wrote:
>
>> Is there any reason to use Racket’s string-append-immutable though? It
>> might be simpler to just:
>>
>> (define string-append-immutable
>>   (compose string->immutable-string string-append))
>>
>> (provide string-append-immutable)
>>
>> since you need to define it anyway for the versions prior 7.5.0.14.
>>
>> On Mon, Mar 30, 2020 at 12:00 PM Sorawee Porncharoenwase <
>> sorawee.pw...@gmail.com> wrote:
>>
>>> Your code would not work because prior 7.5.0.14, there’s no
>>> string-append-immutable, so the use of string-append-immutable in the
>>> else branch will result in an unbound id error.
>>>
>>> Instead, use https://docs.racket-lang.org/version-case/index.html which
>>> will run the “if” at compile-time, making the "unbound id" go away at
>>> compile-time.
>>>
>>> Another problem is that when you define string-append (or even
>>> string-append-immutable), it will shadow Racket’s string-append (or
>>> string-append-immutable). You might want to do something like this
>>> instead:
>>>
>>> (define @string-append-immutable ... now you can use 
>>> string-append-immutable here ...)
>>> (provide (rename-out [@string-append-immutable string-append-immutable]))
>>>
>>>
>>>
>>> On Mon, Mar 30, 2020 at 11:49 AM Siddhartha Kasivajhula <
>>> skasi...@gmail.com> wrote:
>>>
>>>> Hi there,
>>>> Is there a standard/recommended way to handle multiple versions of
>>>> Racket in library code?
>>>>
>>>> For instance, this handy utility was added in a recent version of
>>>> Racket:
>>>>
>>>>
>>>> https://docs.racket-lang.org/reference/strings.html?q=strings#%28def._%28%28quote._~23~25kernel%29._string-append-immutable%29%29
>>>>
>>>> I'd like to use it in my library code but that would probably mean that
>>>> users with an older version of Racket wouldn't be able to use the library,
>>>> is that right? I'm tempted to add something like:
>>>>
>>>> (require version/utils)
>>>> (define string-append
>>>>   (if (version>>>   (compose string->immutable-string string-append)
>>>>   string-append-immutable))
>>>>
>>>> ... at the top of the module. Is this advisable? Or is there a better,
>>>> maybe more raco-friendly way?
>>>>
>>>> Thanks,
>>>> -Sid
>>>>
>>>>
>>>> --
>>>> 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.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/racket-users/CACQBWFkRahhtoXKUbpcJ%2BHpYwq5FBU85Ze_NGkEntXX3kTD01g%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/racket-users/CACQBWFkRahhtoXKUbpcJ%2BHpYwq5FBU85Ze_NGkEntXX3kTD01g%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcueguF6iJkHaYSEBprZjwVxNOxRU3RWV6TuGPPAzHniO6M9g%40mail.gmail.com.


Re: [racket-users] Best way to handle different versions of Racket?

2020-03-30 Thread Sorawee Porncharoenwase
Is there any reason to use Racket’s string-append-immutable though? It
might be simpler to just:

(define string-append-immutable
  (compose string->immutable-string string-append))

(provide string-append-immutable)

since you need to define it anyway for the versions prior 7.5.0.14.

On Mon, Mar 30, 2020 at 12:00 PM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> Your code would not work because prior 7.5.0.14, there’s no
> string-append-immutable, so the use of string-append-immutable in the
> else branch will result in an unbound id error.
>
> Instead, use https://docs.racket-lang.org/version-case/index.html which
> will run the “if” at compile-time, making the "unbound id" go away at
> compile-time.
>
> Another problem is that when you define string-append (or even
> string-append-immutable), it will shadow Racket’s string-append (or
> string-append-immutable). You might want to do something like this
> instead:
>
> (define @string-append-immutable ... now you can use string-append-immutable 
> here ...)
> (provide (rename-out [@string-append-immutable string-append-immutable]))
>
>
>
> On Mon, Mar 30, 2020 at 11:49 AM Siddhartha Kasivajhula <
> skasi...@gmail.com> wrote:
>
>> Hi there,
>> Is there a standard/recommended way to handle multiple versions of Racket
>> in library code?
>>
>> For instance, this handy utility was added in a recent version of Racket:
>>
>>
>> https://docs.racket-lang.org/reference/strings.html?q=strings#%28def._%28%28quote._~23~25kernel%29._string-append-immutable%29%29
>>
>> I'd like to use it in my library code but that would probably mean that
>> users with an older version of Racket wouldn't be able to use the library,
>> is that right? I'm tempted to add something like:
>>
>> (require version/utils)
>> (define string-append
>>   (if (version>   (compose string->immutable-string string-append)
>>   string-append-immutable))
>>
>> ... at the top of the module. Is this advisable? Or is there a better,
>> maybe more raco-friendly way?
>>
>> Thanks,
>> -Sid
>>
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CACQBWFkRahhtoXKUbpcJ%2BHpYwq5FBU85Ze_NGkEntXX3kTD01g%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CACQBWFkRahhtoXKUbpcJ%2BHpYwq5FBU85Ze_NGkEntXX3kTD01g%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsPsYRE7JZa6vrAoV2fHKPLM9O9-8ghhTiR5TexyHeRSA%40mail.gmail.com.


Re: [racket-users] Best way to handle different versions of Racket?

2020-03-30 Thread Sorawee Porncharoenwase
Your code would not work because prior 7.5.0.14, there’s no
string-append-immutable, so the use of string-append-immutable in the else
branch will result in an unbound id error.

Instead, use https://docs.racket-lang.org/version-case/index.html which
will run the “if” at compile-time, making the "unbound id" go away at
compile-time.

Another problem is that when you define string-append (or even
string-append-immutable), it will shadow Racket’s string-append (or
string-append-immutable). You might want to do something like this instead:

(define @string-append-immutable ... now you can use
string-append-immutable here ...)
(provide (rename-out [@string-append-immutable string-append-immutable]))



On Mon, Mar 30, 2020 at 11:49 AM Siddhartha Kasivajhula 
wrote:

> Hi there,
> Is there a standard/recommended way to handle multiple versions of Racket
> in library code?
>
> For instance, this handy utility was added in a recent version of Racket:
>
>
> https://docs.racket-lang.org/reference/strings.html?q=strings#%28def._%28%28quote._~23~25kernel%29._string-append-immutable%29%29
>
> I'd like to use it in my library code but that would probably mean that
> users with an older version of Racket wouldn't be able to use the library,
> is that right? I'm tempted to add something like:
>
> (require version/utils)
> (define string-append
>   (if (version   (compose string->immutable-string string-append)
>   string-append-immutable))
>
> ... at the top of the module. Is this advisable? Or is there a better,
> maybe more raco-friendly way?
>
> Thanks,
> -Sid
>
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CACQBWFkRahhtoXKUbpcJ%2BHpYwq5FBU85Ze_NGkEntXX3kTD01g%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegu%2BKY5UNeOXY1WrmVDb1N715ncP49ASOY1SdZPCznKxsw%40mail.gmail.com.


Re: [racket-users] Code Jam

2020-03-30 Thread Sorawee Porncharoenwase
It’s a programming competition by Google.
https://codingcompetitions.withgoogle.com/codejam

Code Jam used to allow participants to use any languages, but they changed
that a couple of years ago. To quote its website:

With the new platform, we have aimed to support the most popular
programming languages used in past Code Jam contests. We currently support
the following, which represent over 97.5% of the submissions in last year’s
Qualification Round: Bash, C, C++, C# (mono), Go, Haskell (ghc), Java 8,
Javascript (nodejs), Python 2, Python 3, PHP, and Ruby.

I don’t think there’s anything anyone (besides Google) can do about it.

On Mon, Mar 30, 2020 at 7:29 AM Andrew Gwozdziewycz 
wrote:

> I am surely not the only one asking “What is code jam?”
>
> On Mar 30, 2020, at 06:52, Gustavo Massaccesi  wrote:
>
> 
> Code Jam is in a few days, but Racket is not available :(.
>
> Anyone know how difficult is to add a new language to the list? (Probably
> for 2021.)
>
> Gustavo
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAPaha9Pg0A1AP5-tc0pWHjHhqkwO-k2U%2BfGMtS57-NKx0P7S7Q%40mail.gmail.com
> 
> .
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/F87F32C9-4913-425B-BEDB-919B627AF4C2%40gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsRe9EqLBqh%3Dc8jU6iMJZYTijTCuB4sOdixwCzvmyMwZQ%40mail.gmail.com.


Re: [racket-users] Understanding P. Ragde's Proust

2020-03-15 Thread Sorawee Porncharoenwase
You need to add a case in parse-expr to deal with annotations, which is in
the form ( : ).

E.g.,

[`(,e : ,t) (TA (parse-expr e) (parse-type t))]


On Sun, Mar 15, 2020 at 7:21 AM Adrian Manea 
wrote:

> Hi Matt,
>
> Thank you very much for the details! What you're saying makes sense and is
> in accordance with my intuition. But the code doesn't work as it is.
>
> I created a Gist for it here:
>
> https://gist.github.com/adimanea/7aa7921c913e70fb9a8b1524b5bd2d3c
>
> Everything is from the article, except for the (struct TA (type var))
> which I created instead of the Ann ("type annotation") and the examples I
> used for tests.
>
> Regards,
> Adrian
>
> On Sunday, March 15, 2020 at 2:10:55 PM UTC, Matt Jadud wrote:
>>
>> Hi Adrian,
>>
>> The article seems to be missing a type definition for Ann.
>>
>> Perhaps some of this you already know...
>>
>> (match expr ...)
>>
>> is a pattern matcher, working to find a pattern that 'expr' fits.
>>
>> [(Lam _ _) ...]
>>
>> is attempting to match a pattern where a 'expr' is a struct called Lam,
>> and that structure has two fields. In this case, the value of those fields
>> is ignored, so the variable '_' is used to (by convention, not by syntax)
>> tell the programmer that these values do not matter. (At least, I'm
>> reasonably confident this is by convention and not by syntax.)
>>
>> The form
>>
>> [(Ann e t) ...] is matching the structure 'Ann', and binding the value in
>> the first field to the identifier 'e', and the second value to 't'. Then,
>> the expression following is executed (assuming the pattern matched).
>>
>> In the article, there is no struct definition for 'Ann'. I suspect it is
>> a typo/oversight. This would work:
>>
>> (struct Ann (e t))
>>
>> would be a reasonable definition. It says "Ann" is a data structure with
>> two fields, called "e" and "t".
>>
>> I haven't read the article, so "better" names for those fields is not
>> something I am going to come up with right now. The name in the definition
>> matters (to you, the programmer), but the identifier used to bind in the
>> pattern is not critical. (Or, it is again something that should be
>> important to you, but it does not need to match the names of the fields in
>> the struct definition.)
>>
>> Hopefully that helps, and helps you move forward a bit. Ask more
>> questions if that didn't help. And, perhaps putting your code as-is in a
>> Github Gist or similar, so that others can look at exactly what you're
>> working with would be useful.
>>
>> (I have no idea how complete or incomplete the code in the article is,
>> which is why I suggest you put it in a pastebin/gist to share... there
>> might be other things that were glossed in the article? I don't know.)
>>
>> Cheers,
>> Matt
>>
>>
>> On Sun, Mar 15, 2020 at 10:01 AM Adrian Manea 
>> wrote:
>>
>>> Hi all,
>>>
>>> I'm a mathematician delving into type theory and proof assistants and
>>> with special interests in Racket.
>>>
>>> I'm now trying to understand and implement P. Ragde's Proust
>>>  "nano proof assistant" and work
>>> through the examples in his article. However, I'm pretty much a beginner in
>>> Racket and I'm getting some errors. Particularly in the type-infer
>>> function, that's also used in the type-check function.
>>>
>>> Here is the code in the article:
>>>
>>> (define (type-check ctx expr type)
>>>   (match expr
>>> [(Lam x t)   ; lambda expression
>>> (match type
>>>[(Arrow tt tw) (type-check (cons `(,x ,tt) ctx) t tw)] ;
>>> arrow type
>>>[else (cannot-check ctx expr type)])]
>>> [else (if (equal? (type-infer ctx expr) type) true (cannot-check ctx
>>> expr type))]))
>>>
>>> (define (type-infer ctx expr)
>>>   (match expr
>>> [(Lam _ _) (cannot-infer ctx expr)]
>>> [(Ann e t)  (type-check ctx e t) t]
>>> [(App f a); function application
>>>   (define tf (type-infer ctx f))
>>>  (match tf
>>> [(Arrow tt tw) #:when (type-check ctx a tt) tw]
>>> [else (cannot-infer ctx expr)])]
>>> [(? symbol? x)
>>>  (cond
>>>  [(assoc x ctx) => second]
>>>  [else (cannot-infer ctx expr)])]))
>>>
>>> The first question I have is: what's the (Ann e t) supposed to mean,
>>> because I'm getting a syntax error? Is it a type annotation? If so,
>>> shouldn't everything be inside the #lang typed/racket module and type
>>> annotations everywhere?
>>>
>>> Secondly, the functions don't seem to work like this, as I'm getting
>>> failed matches for everything that's not a lambda expression. Can you
>>> please help me clarify the code there or maybe it's already available
>>> somewhere? Because just typing in the examples in the article simply
>>> doesn't work. I can understand what they are supposed to do, but I lack
>>> the skills to fix things myself.
>>>
>>> Thank you!
>>>
>>>
>>> --
>>> You received this message because you are 

Re: [racket-users] why is glCreateVertexArrays absent?

2020-03-08 Thread Sorawee Porncharoenwase
Have you tried this? https://github.com/dbenoit17/dynamic-ffi

On Sun, Mar 8, 2020 at 5:52 AM Hendrik Boom  wrote:

> On Sat, Mar 07, 2020 at 07:32:01AM -0800, Sorawee Porncharoenwase wrote:
> > I know nothing about OpenGL, but the autogeneration
> > <https://github.com/stephanh42/RacketGL/blob/master/opengl/readspec.rkt>
> > seems to read the information from this directory
> > <https://github.com/stephanh42/RacketGL/tree/master/opengl/specfiles>,
> > which was last updated 7 years ago (2013). OpenGL 4.5 was released in
> 2014
> > <https://www.khronos.org/opengl/wiki/History_of_OpenGL>.
> >
> > I’d suggest you to contact the maintainer <https://github.com/stephanh42
> >
> > of the package to update it. Note, though, that the maintainer doesn’t
> seem
> > to be active in GitHub for almost two years now. In case you can't
> contact
> > the maintainer, you might need to fork the package to update it.
>
> I woildn't mind forking it, even just locally, but I haave not been able
> to find current versions of the specfiles it uses.  The README says they
> originated at http://www.opengl.org/registry/ , but I've been unable to
> find them there.  For all I know Khronos might no longer be using that
> form of definition.  Everything serious there appears to be a
> human-readable pdf now.  Or a C .h file.
>
> So far it looks as if I may have to reverse-engineer the specfiles from
> the .h files.
>
> Or maybe I'm just not good at searching.  Google has found me some even
> more obsolete versions.  I guess I'll keep looking.
>
> I suppose I could try patching in the particular function specs I need
> until I manage to get world from the maintainer.
>
> -- hendrik
>
> >
> > On Sat, Mar 7, 2020 at 6:57 AM Hendrik Boom 
> wrote:
> >
> > > Is there any technical reason why glCreateVertexArrays is missing from
> > > the Racket OpenGL package?
> > >
> > > The documentation at https://docs.racket-lang.org/opengl/index.html
> > > says that "Being automatically-generated means that it is quite
> complete."
> > >
> > > So I would have expected it to be present.
> > >
> > > But it is not present either in the implemetation or in the
> > > documentation ( https://docs.racket-lang.org/opengl/glC___.html )
> > >
> > > I do have openGL 4.5 on my system, so it's not because the opengl
> > > library is too old (which did happen on an older computer).
> > >
> > > Would bringing it up-to-date perhaps interfere with the operation of
> > > other packages?
> > >
> > > -- hendrik
> > >
> > > --
> > > 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.
> > > To view this discussion on the web visit
> > >
> https://groups.google.com/d/msgid/racket-users/20200307145657.gq7xgysyvkz5yn7y%40topoi.pooq.com
> > > .
> > >
> >
> > --
> > 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.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CADcuegsktFyB2iRV0-nV018mFOeO8Fhqe6mbp_4_ksesXX%3DZtQ%40mail.gmail.com
> .
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200308125229.gn37sgshwijpuaqq%40topoi.pooq.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtcB6wuk%3DcaBZn%2BMHSAYNmT8EUrNQO3HRg3uFeKyFUekw%40mail.gmail.com.


Re: [racket-users] why is glCreateVertexArrays absent?

2020-03-07 Thread Sorawee Porncharoenwase
I know nothing about OpenGL, but the autogeneration

seems to read the information from this directory
,
which was last updated 7 years ago (2013). OpenGL 4.5 was released in 2014
.

I’d suggest you to contact the maintainer 
of the package to update it. Note, though, that the maintainer doesn’t seem
to be active in GitHub for almost two years now. In case you can't contact
the maintainer, you might need to fork the package to update it.

On Sat, Mar 7, 2020 at 6:57 AM Hendrik Boom  wrote:

> Is there any technical reason why glCreateVertexArrays is missing from
> the Racket OpenGL package?
>
> The documentation at https://docs.racket-lang.org/opengl/index.html
> says that "Being automatically-generated means that it is quite complete."
>
> So I would have expected it to be present.
>
> But it is not present either in the implemetation or in the
> documentation ( https://docs.racket-lang.org/opengl/glC___.html )
>
> I do have openGL 4.5 on my system, so it's not because the opengl
> library is too old (which did happen on an older computer).
>
> Would bringing it up-to-date perhaps interfere with the operation of
> other packages?
>
> -- hendrik
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200307145657.gq7xgysyvkz5yn7y%40topoi.pooq.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsktFyB2iRV0-nV018mFOeO8Fhqe6mbp_4_ksesXX%3DZtQ%40mail.gmail.com.


Re: [racket-users] xexpr cond failing

2020-03-01 Thread Sorawee Porncharoenwase
Actually you might want to use (list (let () body ...)) rather than (list
(begin body ...)) so that you can use define inside when/splice, just like
how you can do that in when.

On Sun, Mar 1, 2020 at 3:26 AM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> Well, you can always use macro!
>
> (define-syntax-rule (when/splice test body ...)
>   (if test (list (begin body ...) '(
>
> `(body
>   (form ((action "") (method "post"))
> (label ((for "username")) "Username:")
> (input ((type "text") (name "username") (maxlength "64")))
> (label ((for "password")) "Password:")
> (input ((type "password") (name "password") (maxlength "64")))
> (button ((type "submit") (value "Login")) "Login"))
>   ,@(when/splice (not (eq? login-error ""))
>   `(p ,login-error)))
>
>
>
> On Sun, Mar 1, 2020 at 12:50 AM liendolucas84 
> wrote:
>
>> Thank you very much for your reply Sorawee. I'll go with your proposed
>> solution for the time being. However it feels like I'm adding unnecessary
>> code to make the xexpr valid which can be really annoying if having nested
>> cases or other more complex situations. Thanks again for your fast reply!
>>
>> On Sunday, March 1, 2020 at 7:43:20 PM UTC+11, Sorawee Porncharoenwase
>> wrote:
>>>
>>> One possible way is to have the first case returns a list of one
>>> element, and the else case returns an empty list. You then splice this list
>>> into body via ,@.
>>>
>>> `(body
>>>   (form ((action "") (method "post"))
>>> (label ((for "username")) "Username:")
>>> (input ((type "text") (name "username") (maxlength "64")))
>>> (label ((for "password")) "Password:")
>>> (input ((type "password") (name "password") (maxlength "64")))
>>> (button ((type "submit") (value "Login")) "Login"))
>>>   ,@(cond
>>>   [(not (eq? login-error "")) `((p ,login-error))]
>>>   [else '()]))
>>>
>>> If the then branch is taken, the value will be:
>>>
>>> `(body
>>>   (form ((action "") (method "post"))
>>> (label ((for "username")) "Username:")
>>> (input ((type "text") (name "username") (maxlength "64")))
>>> (label ((for "password")) "Password:")
>>> (input ((type "password") (name "password") (maxlength "64")))
>>> (button ((type "submit") (value "Login")) "Login"))
>>>   (p ,login-error))
>>>
>>> On the other hand, if the else branch is taken, the value will be:
>>>
>>> `(body
>>>   (form ((action "") (method "post"))
>>> (label ((for "username")) "Username:")
>>> (input ((type "text") (name "username") (maxlength "64")))
>>> (label ((for "password")) "Password:")
>>> (input ((type "password") (name "password") (maxlength "64")))
>>> (button ((type "submit") (value "Login")) "Login")))
>>>
>>>
>>> On Sun, Mar 1, 2020 at 12:31 AM liendolucas84 
>>> wrote:
>>>
>>>> Hi everyone! Just joined the Racket User's group. I'm trying to
>>>> conditionally render a paragraph element using a cond and an xexpr but I
>>>> can't make the "xexpr?" function return a #t value and of course the
>>>> response/xexpr function call fails as well. I've kind of fix this by always
>>>> returning a paragraph element regardless is needed or not (of course this
>>>> is not what I want). Here's the working code:
>>>>
>>>> (define (login-template (login-error ""))
>>>>   `(html
>>>>  (head
>>>>(link ((rel "icon") (href "data:,")))
>>>>(title "Please login"))
>>>>  (body
>>>>(form ((action "") (method "post"))
>>>>  (label ((for "username")) "Username:")
>>>> 

Re: [racket-users] xexpr cond failing

2020-03-01 Thread Sorawee Porncharoenwase
Well, you can always use macro!

(define-syntax-rule (when/splice test body ...)
  (if test (list (begin body ...) '(

`(body
  (form ((action "") (method "post"))
(label ((for "username")) "Username:")
(input ((type "text") (name "username") (maxlength "64")))
(label ((for "password")) "Password:")
(input ((type "password") (name "password") (maxlength "64")))
(button ((type "submit") (value "Login")) "Login"))
  ,@(when/splice (not (eq? login-error ""))
  `(p ,login-error)))



On Sun, Mar 1, 2020 at 12:50 AM liendolucas84 
wrote:

> Thank you very much for your reply Sorawee. I'll go with your proposed
> solution for the time being. However it feels like I'm adding unnecessary
> code to make the xexpr valid which can be really annoying if having nested
> cases or other more complex situations. Thanks again for your fast reply!
>
> On Sunday, March 1, 2020 at 7:43:20 PM UTC+11, Sorawee Porncharoenwase
> wrote:
>>
>> One possible way is to have the first case returns a list of one element,
>> and the else case returns an empty list. You then splice this list into
>> body via ,@.
>>
>> `(body
>>   (form ((action "") (method "post"))
>> (label ((for "username")) "Username:")
>> (input ((type "text") (name "username") (maxlength "64")))
>> (label ((for "password")) "Password:")
>> (input ((type "password") (name "password") (maxlength "64")))
>> (button ((type "submit") (value "Login")) "Login"))
>>   ,@(cond
>>   [(not (eq? login-error "")) `((p ,login-error))]
>>   [else '()]))
>>
>> If the then branch is taken, the value will be:
>>
>> `(body
>>   (form ((action "") (method "post"))
>> (label ((for "username")) "Username:")
>> (input ((type "text") (name "username") (maxlength "64")))
>> (label ((for "password")) "Password:")
>> (input ((type "password") (name "password") (maxlength "64")))
>> (button ((type "submit") (value "Login")) "Login"))
>>   (p ,login-error))
>>
>> On the other hand, if the else branch is taken, the value will be:
>>
>> `(body
>>   (form ((action "") (method "post"))
>> (label ((for "username")) "Username:")
>> (input ((type "text") (name "username") (maxlength "64")))
>> (label ((for "password")) "Password:")
>> (input ((type "password") (name "password") (maxlength "64")))
>> (button ((type "submit") (value "Login")) "Login")))
>>
>>
>> On Sun, Mar 1, 2020 at 12:31 AM liendolucas84 
>> wrote:
>>
>>> Hi everyone! Just joined the Racket User's group. I'm trying to
>>> conditionally render a paragraph element using a cond and an xexpr but I
>>> can't make the "xexpr?" function return a #t value and of course the
>>> response/xexpr function call fails as well. I've kind of fix this by always
>>> returning a paragraph element regardless is needed or not (of course this
>>> is not what I want). Here's the working code:
>>>
>>> (define (login-template (login-error ""))
>>>   `(html
>>>  (head
>>>(link ((rel "icon") (href "data:,")))
>>>(title "Please login"))
>>>  (body
>>>(form ((action "") (method "post"))
>>>  (label ((for "username")) "Username:")
>>>  (input ((type "text") (name "username") (maxlength "64")))
>>>  (label ((for "password")) "Password:")
>>>  (input ((type "password") (name "password") (maxlength
>>> "64")))
>>>  (button ((type "submit") (value "Login")) "Login"))
>>>,(cond
>>>   ((not (eq? login-error "")) `(p, login-error))
>>>   (else '(p "Enter your username/password."))
>>

Re: [racket-users] xexpr cond failing

2020-03-01 Thread Sorawee Porncharoenwase
One possible way is to have the first case returns a list of one element,
and the else case returns an empty list. You then splice this list
into body via
,@.

`(body
  (form ((action "") (method "post"))
(label ((for "username")) "Username:")
(input ((type "text") (name "username") (maxlength "64")))
(label ((for "password")) "Password:")
(input ((type "password") (name "password") (maxlength "64")))
(button ((type "submit") (value "Login")) "Login"))
  ,@(cond
  [(not (eq? login-error "")) `((p ,login-error))]
  [else '()]))

If the then branch is taken, the value will be:

`(body
  (form ((action "") (method "post"))
(label ((for "username")) "Username:")
(input ((type "text") (name "username") (maxlength "64")))
(label ((for "password")) "Password:")
(input ((type "password") (name "password") (maxlength "64")))
(button ((type "submit") (value "Login")) "Login"))
  (p ,login-error))

On the other hand, if the else branch is taken, the value will be:

`(body
  (form ((action "") (method "post"))
(label ((for "username")) "Username:")
(input ((type "text") (name "username") (maxlength "64")))
(label ((for "password")) "Password:")
(input ((type "password") (name "password") (maxlength "64")))
(button ((type "submit") (value "Login")) "Login")))


On Sun, Mar 1, 2020 at 12:31 AM liendolucas84 
wrote:

> Hi everyone! Just joined the Racket User's group. I'm trying to
> conditionally render a paragraph element using a cond and an xexpr but I
> can't make the "xexpr?" function return a #t value and of course the
> response/xexpr function call fails as well. I've kind of fix this by always
> returning a paragraph element regardless is needed or not (of course this
> is not what I want). Here's the working code:
>
> (define (login-template (login-error ""))
>   `(html
>  (head
>(link ((rel "icon") (href "data:,")))
>(title "Please login"))
>  (body
>(form ((action "") (method "post"))
>  (label ((for "username")) "Username:")
>  (input ((type "text") (name "username") (maxlength "64")))
>  (label ((for "password")) "Password:")
>  (input ((type "password") (name "password") (maxlength "64")))
>  (button ((type "submit") (value "Login")) "Login"))
>,(cond
>   ((not (eq? login-error "")) `(p, login-error))
>   (else '(p "Enter your username/password."))
>
> However I don't want to display at all the "else" clause as is not needed
> at all, here's the failing code:
>
> (define (login-template (login-error ""))
>   `(html
>  (head
>(link ((rel "icon") (href "data:,")))
>(title "Please login"))
>  (body
>(form ((action "") (method "post"))
>  (label ((for "username")) "Username:")
>  (input ((type "text") (name "username") (maxlength "64")))
>  (label ((for "password")) "Password:")
>  (input ((type "password") (name "password") (maxlength "64")))
>  (button ((type "submit") (value "Login")) "Login"))
>,(cond
>   ((not (eq? login-error "")) `(p, login-error))
>
> The last example fails if the login-error is indeed "" (an empty string).
> Am I missing something like a "null xexpr" usage for the "else" clause or
> something different that needs to be used in these situations? Of the all
> examples out there that I could find and read none of them shows how to do
> something like this. Is there a doc page where can I read about caveats
> using xexprs (if any) or situations like the one I've described?
>
> Thanks for your time,
> Lucas.
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/48f5b3c7-3ec2-43cc-8f01-60e36acb1e74%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtDVCicm_FJwypt%2BVTMA_YvtaYMBK2ot4RVPDKnihjBWg%40mail.gmail.com.


Re: [racket-users] Starting syntax highlighter project

2020-02-19 Thread Sorawee Porncharoenwase
On Wed, Feb 19, 2020 at 11:55 PM Sage Gerard  wrote:

> I'm very much in favor of interoperability and am happy to work in that
> direction. Does this imply that we need a #lang for each highlighting
> target?


With my approach, yes, but note that technically, the #lang doesn't need to
be functional. The whole module could just expand into a raising of a
runtime exception "not implemented". I'm not sure that in practice this is
a good idea though.


> What happens if you want to highlight code mixtures? Some snippets of
> interest to me can include Javascript, Markdown, CSS, HTML and Racket all
> within 20 lines.
>

Then the color lexer would need to be context-sensitive and knows when to
switch its lexing mode. Note that this is not a problem due to this
approach. Any other approaches would have the same problem.

It would be cool if there's a way to annotate code with `#reader` at the
meta level, which would make this problem much easier...

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegs-76-meLv7Lmr7enGy47fUqGeJChwq%2B%2B9Xbk7b%2Bz6GgQ%40mail.gmail.com.


Re: [racket-users] Starting syntax highlighter project

2020-02-19 Thread Sorawee Porncharoenwase
In my opinion, it would be very cool if the project is based on DrRacket’s
color-lexer ecosystem. So instead of writing an ad-hoc lexer for, say,
Python, we instead help improving the existing #lang python‘s color-lexer.

Pro:

   - The result will look just like what DrRacket displays.
   - Integrate well with #lang. Potentially useful for Scribble, since
   right now Scribble really only displays Racket code well.
   - Push the community to improve/write more color-lexer

Con:

   - Token styles are pretty limited (only 8 categories), but then again,
   perhaps this will push DrRacket to support more than 8 categories.

It looks like we can programmatically extract information from color-lexer
via module-lexer
.
See this file

for its usage.

And since we use DrRacket’s ecosystem, we can go further than just syntax
highlighting. E.g., showing a binding arrow interactively when hovering
mouse over an identifier. The code example at this link

shows how we can extract such information.
-

On Wed, Feb 19, 2020 at 5:19 PM Sage Gerard  wrote:

> Thank you for the reference, Martin. After looking at skylighting I ended
> up reading some XML specs in [1] after visiting Kate's.
>
> I can some potential shortcuts with the XML specs, but I'm seeing a lot of
> data-entry that won't *really* know how to highlight things like "->" in
> Racket or "X Y(Z);" in C++. I'm hoping parsack can handle these nuances.
> Still, the implementation burden is high and writing parsers means not
> having a syntax-highlighting data format.
>
> I'm thinking about writing the package such that a pre-installer builds an
> isolated Docker instance and runs a container for an existing
> highlighter--The goal being to provide what feels like a pure Racket
> package with no extra install steps. From there I can add parsack
> implementations over time. No clue how that will go.
>
> [1]: https://github.com/KDE/syntax-highlighting/tree/master/data/syntax
>
> *~slg*
>
>
> ‐‐‐ Original Message ‐‐‐
> On Wednesday, February 19, 2020 4:11 PM, Martin DeMello <
> martindeme...@gmail.com> wrote:
>
> Nice, I'll be following this with interest! What are the pros and cons of
> developing a new syntax highlighting format from scratch, versus e.g.
> parsing and reusing the kate style files? For the latter route this haskell
> package is a good source of inspiration:
> https://hackage.haskell.org/package/skylighting
>
> martin
>
> On Tue, Feb 18, 2020 at 10:27 AM Sage Gerard  wrote:
>
>> Hi folks,
>>
>> I'm starting a syntax highlighter project here:
>> https://github.com/zyrolasting/syntax-highlighting
>>
>> There seems to be a precedent for using an existing highlighter from
>> another ecosystem. I understand the pragmatism behind that, but a syntax
>> highlighter seems to me a missing battery in Racket.
>>
>> Without funding I am unable to compete with the implementations with 200+
>> languages supported. So I merely intend to provide two renderers (Terminal
>> and HTML [XML syntax]), some palettes, and a sensible extension to parsack
>> that classifies characters using Pygments' token classes. This should
>> provide a strong, familiar core on which to add features according to
>> community interest.
>>
>> That being said, I invite feedback and collaboration to add support for
>> languages once the core mechanisms are established.
>>
>> *~slg*
>>
>>
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/GC9QAolNyNFBE-KrDXfvA0q0P5_7jBWs7DEger3xGw5sYRmKg0rowpzyLIlyb1hrDOg_2xxTLn74TR5pCDIPhOzqIN5baGHoO7TU4GuaLDI%3D%40sagegerard.com
>> 
>> .
>>
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/LKOhymlNe9MueHZQB8ErdJH7ySw_pTxDtsbZvNuXKWqEmGrFoOJl7SewhmwcS__qZunT6M6tzaMn_a-CjRFWEwfHhdrS2jfoKIBQkhkAzjM%3D%40sagegerard.com
> 

Re: [racket-users] Re: How to convert String to Integer

2020-02-11 Thread Sorawee Porncharoenwase
You can convert a string to a list of characters by using string->list. The
code snippet that you presented in your very first post also uses this
function.

> (string->list "abc")
- : (Listof Char)
'(#\a #\b #\c)

What I want to ask you though is what is wrong with the code that Phillip
suggested? The code is the most standard way to write a function to convert
a string to an integer. Have you tried it?

(: myconversion (-> String Integer))
(define (myconversion str)
  (define rslt (string->number str))
  (cond
[(exact-integer? rslt)
 rslt]
[else
 (raise-argument-error 'myconversion
   "a string representing an integer"
   str)]))

On Tue, Feb 11, 2020 at 12:28 PM Alain De Vos 
wrote:

> In C I would would do some very simple pointer arithmetic, but racket
> leaves me into the blue.
> Documentation, which is fine, compared to other lisps, fyi chez, leaves me
> into the blue.
> 0) Given a string,
> 1) convert to  a list of characters,
> 2) allow me to iterate,
> 3) convert a character to an int ,
> 4) subtract corresponding value of zero,
> 5) allow me to some positional stuff and addition.
> But first i need a list of characters. :)
> Does the language has a conversion operator ?
>
> On Tuesday, February 11, 2020 at 8:50:33 PM UTC+1, Alain De Vos wrote:
>>
>> Very basic question, first step first, how do i convert a string astring
>> to a list of characters,
>> #lang typed/racket
>> (require typed/racket/gui)
>> (: astring String)
>> (define astring "1234567890")
>>
>>
>> On Tuesday, February 11, 2020 at 11:34:16 AM UTC+1, Alain De Vos wrote:
>>>
>>> I tried the following function to conver a String to an Integer.
>>>
>>> #lang typed/racket
>>> (: myconversion (-> String Integer))
>>> (define (myconversion str)
>>>   (string->number str))
>>>
>>> The error given is :
>>> Type Checker: type mismatch
>>>   expected: Integer
>>>   given: (U Complex False) in: (string->number str)
>>>
>>> I guess this is because a number is not an Integer.
>>>
>>> How to proceed?
>>>
>>> I found the following code on internet , but this looks like a real
>>> overkill for this simple problem ,
>>>
>>> (: numerical-char->integer (-> Char
>>>Integer))(define (numerical-char->integer 
>>> char)
>>>   (let ([num (- (char->integer char) 48)]) ; 48 = (char->integer #\0)
>>> (if
>>>  (or (< num 0) (> num 9))
>>>  (raise 'non-numerical-char #t)
>>>  num)))
>>> (: string->integer (-> String
>>>Integer))(define (string->integer str)
>>>   (let ([char-list (string->list str)])
>>> (if (null? char-list)
>>> (raise 'empty-string #t)
>>> (foldl
>>>  (λ([x : Integer] [y : Integer])
>>>(+ (* y 10) x))
>>>  0
>>>  (map numerical-char->integer char-list)
>>>
>>> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/54b2884c-6d93-44ad-b34a-d68c110b73ec%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsw%3DbgNQdodaRiJo%2BW9PmvEDyx-DfCjSHor4UoCTqC4yw%40mail.gmail.com.


Re: [racket-users] how to reinstall a broken package?

2020-01-23 Thread Sorawee Porncharoenwase
I usually do

raco setup --pkgs 

On Thu, Jan 23, 2020 at 8:34 AM Hendrik Boom  wrote:

> My installation of OpenGL Mathematics (GLM) for Racket is defective
> in that the installed manual has tha complete table of contents but does
> not
> have any content past section 2.1.1.
> This may be because of running out of disk space during installation.
>
> Asking raco pkg to install it does not work because it thinks it is already
> installed and up-to-date.
>
> Asking raco pkg to remove it just gives ma complaints that other packages
> depend on it - other packages that I don't want to uninstall.
>
> Is there a convenient way to ask raco to reinstall a package?
>
> -- hendrik
>
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200123143402.3gsduqfndq6rer3n%40topoi.pooq.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsExxWStHvqBnd0pNg7uyvXPEz9vWMK3OVL9yNAri9eBA%40mail.gmail.com.


Re: [racket-users] DrRacket Dark Mode in Windows

2020-01-17 Thread Sorawee Porncharoenwase
> Which operating system do you use? And can you share a a screenshot?
>

In my understanding, Juan Carlos Olivo and Shawn Shawn have exactly the
same problem. They use Windows 10 and switched to dark theme at the OS
level, but the DrRacket UI still has the light theme. For the screenshot,
see the one in Shawn Shawn's email above.


>
> Robby
>
> On Thu, Jan 16, 2020 at 10:13 PM Juan Carlos Olivo 
> wrote:
>
>> "As I understand, you have no problem with the customization for editors,
>> but have a problem with the customization for the general UI. Is that
>> correct?"
>>
>> You are correct. Currently I have the editor with a dark theme
>> (Spacemacs), but the DrRacket UI itself is light, even though I set it to
>> "Dark" in Windows settings.
>>
>> Thank you for seeking clarification!
>>
>> --JCO
>>
>> On Wednesday, January 15, 2020 at 11:59:51 PM UTC-6, Sorawee
>> Porncharoenwase wrote:
>>>
>>> I was reading in the release notes that DrRacket supports dark mode as
>>>> of 7.5; however, I don't see this option in the DrRacket preferences. I
>>>> also have "Dark" as the default color under the "Colors" section in
>>>> Settings > Personalization > Colors. I am using the latest Windows 10.
>>>
>>>
>>> Just to be clear. DrRacket supports theme customization *for the editor*
>>> under the "Colors" tab long ago (and this is what Robby was talking about
>>> in the above reply). If you want the editor to have a dark background, you
>>> should choose "white on black" theme, "Tol's White on Black" theme, or
>>> install any additional theme (e.g., Spacemacs Dark) via the package manager.
>>>
>>> And then there's DrRacket's general UI. Its dark theme support was added
>>> since Racket 7.5, and this depends on the customization at the OS level.
>>>
>>> Here are four possibilities:
>>>
>>> - Dark theme at the OS level and dark theme for the editor
>>>
>>> [image: Screen Shot 2020-01-15 at 21.37.05.png]
>>>
>>> - Dark theme at the OS level and light theme for the editor
>>>
>>> [image: Screen Shot 2020-01-15 at 21.45.54.png]
>>>
>>> - Light theme at the OS level and light theme for the editor
>>>
>>> [image: Screen Shot 2020-01-15 at 21.50.02.png]
>>>
>>> - Light theme at the OS level and dark theme for the editor
>>>
>>> [image: Screen Shot 2020-01-15 at 21.49.17.png]
>>>
>>> As I understand, you have no problem with the customization for editors,
>>> but have a problem with the customization for the general UI. Is that
>>> correct? I don't have Windows or Linux, so I don't know how DrRacket's
>>> general UI looks like for them. But it works reasonably well in MacOS.
>>>
>>> On Wed, Jan 15, 2020 at 9:03 PM Hendrik Boom 
>>> wrote:
>>>
>>>> On Wed, Jan 15, 2020 at 10:10:12PM -0600, Robby Findler wrote:
>>>> > Dark mode will be a lot better in the next release.
>>>>
>>>> I hope so.  I use drracket in dark mode on Linux.
>>>> The main panels have a proper black background, but some of the framing
>>>> has a white background, specifically
>>>>   the panel that says File Edit View Language, etc
>>>> and
>>>>   the panel that says Untitles ... Run Stop
>>>> on startup.
>>>>
>>>> > Probably one thing
>>>> > you have to do (in the current release) is open the preferences
>>>> > dialog, choose "colors" and then click the "white on black" button.
>>>> > The snapshot builds are here if you want to see the improvement since
>>>> > the last release: https://snapshot.racket-lang.org/
>>>> >
>>>> > Rpbby
>>>> >
>>>>
>>>> > >
>>>> > > Thank you!
>>>> > >
>>>> > > --JC
>>>> > >
>>>> > > --
>>>> > > 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...@googlegroups.com.
>>>> > > To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/racket-users/e3a39d0a-f629-4179-a668-87e87f2a0118%40googlegroups.com
>>>>

Re: [racket-users] How do I provide a name as both a match expander and contracted function?

2019-12-30 Thread Sorawee Porncharoenwase
IIUC, this is what Alex Knauth did in
https://github.com/mbutterick/txexpr/pull/8.

On Mon, Dec 30, 2019 at 7:07 PM Jack Firth  wrote:

> If I'm making my own data types, one common thing I want to do is make
> smart constructors that double as match expanders. I could use
> `define-match-expander` with two transformers, but then I can't add a
> contract to the smart constructor with `contract-out`. If I try to write
> this:
>
> (provide
>  (contract-out
>   [foo (->* (widget?) (#:name symbol?) foo?)]))
>
> (define (make-foo widget #:name [name #f])
>   ...)
>
> (define-match-expander foo
>   (syntax-parser [(_ widget) #'(? foo? (app foo-widget widget))])
>   (syntax-parser [(_ arg ...) #'(make-foo arg ...)]))
>
> ...then the use of `contract-out` hides the fact that `foo` is a match
> expander. What should I do?
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/2dac85e9-8058-437c-b5bc-a92f659c02f6%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvhNMz85CQOtXMHQjyQTym7xS9huNVikJVoXXVYhsS0AQ%40mail.gmail.com.


Re: [racket-users] DrRacket 7.5 colors a bit dark and low contrast on Mac

2019-12-06 Thread Sorawee Porncharoenwase
Confirm that I have this problem as well, even when I reset all preference
files.

On Fri, Dec 6, 2019 at 11:17 AM Daniel Prager 
wrote:

> Hi Robby
>
> > What happens if you open the preferences dialog and turn white-on-Black
> on and back off again?
>
> No change.
>
> I still have 7.2 on my system, which works fine.
>
> Here's what it looks like in black-on-white for reference.
>
> [image: image.png]
>
>>
>>> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAFKxZVWwkztEadAFEruizXZ%3DJ3pHyK7Kd%2BpU0UBzqo95Sdr%2B4A%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsoMSqnzCZG9uRy2Sv%2BOzsfcP0%3DyAVxnyzQ0ndqJ5DP4w%40mail.gmail.com.


Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Sorawee Porncharoenwase
This is super cool indeed. Now I feel stupid.

On Wed, Dec 4, 2019 at 2:56 PM Matthew Butterick  wrote:

>
> On Dec 4, 2019, at 2:39 PM, 'Joel Dueck' via Racket Users <
> racket-users@googlegroups.com> wrote:
>
> So it seems easy to match "*at least *N identical elements".
> But is there a method for matching "*no more than *N identical elements"?
>
>
> ?
>
>
> #lang racket
> (require rackunit)
>
> (define (super-cool? lst)
>   (match lst
> [(and (list* _ ... a a _)
>   (not (list* _ ... a a a _))) #t]
> [_ #f]))
>
> (check-true (super-cool? '(1 1 4)))
> (check-false (super-cool? '(1 1 1 4)))
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/1734093C-0C39-4289-9747-41CAFB35851F%40mbtype.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegu4s2bhEZNQ1fNt5JX-ENc91Ythaev7VezWk-ZY8Z2%2BcA%40mail.gmail.com.


Re: [racket-users] xml library clarification - "" symbol parsing

2019-11-22 Thread Sorawee Porncharoenwase
I’ll probably do this if I were you:

#lang racket

(require xml)

(struct data (b1 b2) #:transparent)

;; extract :: XExpr -> (Listof data?)
(define (extract xexpr)
  (match-define `(ROOT () ,xs ...) xexpr)
  (for/list ([e xs] #:when (list? e))
(match-define `(A () ,b1 ,b2) e)
(data b1 b2)))

(define raw-xml #<
  testtest qoute
  test2test qoute2

EOF
  )

(extract (string->xexpr raw-xml))

Alternatively, you can use this hacky way:

;; extract :: XExpr -> (Listof data?)
(define (extract xexpr)
  (for/list ([slice (in-slice 2 (se-path*/list '(A) xexpr))])
(apply data slice)))

If there are really 10 millions of A tags, I would suggest you use
for/stream instead of for/list, which will produce a stream instead of a
list.

On Fri, Nov 22, 2019 at 7:15 PM Kira  wrote:

> I just cannot understand how to solve XML related problems by using this
> library.
> Perhaps there is lack of examples, and no description of functions purpose.
> And from bare description I am failing to imagine practical use.
>
> For example, why (source) struct exists? And how I can use it?
>
> Why there functions (read-xml/document [in]) and (read-xml/element [in])
> And how i can use them?
> As I mentioned earlier, my guess was that I can process XML sequentially
> by using them in tandem, but it seems this guess was wrong.
>
> What is the pattern for navigating inside (element) structure? For example
> getting to ROOT->tagA->tagB ?
> And I cannot go from tagB to tagA, rigth?
>
> Lets assume such XML:
> 
>   
> test
> test qoute
>   
>   
> test2
> test qoute2
>   
> 
>
>
>
>
> I want to transform this into list of struct (data b1 b2)
>
> And perhaps do this in sequential manner if i need to parse 10 millions of
> A tags.
>
> I tried to use (se-path*/list), like this:
> (define rawmxl "testtest
> qoutetest2test
> ")
> (define xexpr (string->xexpr rawmxl))
> (se-path*/list '(A) xexpr)
>
>
>
>
> But this gives me plain list:
> '((B1 () "test") (B2 () "\"" "test qoute" "\"") (B1 () "test2") (B2 ()
> "\"" "test " "\"" "qoute2" "\"" "\""))
>
>
> Without distinction of what A tag content is where.
> So i cannot reason about it.
>
> And (se-path*/list '(A B2) xexpr) gives me:
> '("\"" "test qoute" "\"" "\"" "test " "\"" "qoute2" "\"" "\"")
>
>
> so this is even worse.
>
> And it will be great if a can get 1 list from the beginning, because I
> have 20 millions of this records.
>
> So now I am moved to (match) solution.
> For example:
> (match xexpr
>   [(list 'ROOT '()
>  (list 'A '()
>(list 'B1 '() b1)
>(list 'B2 '() b2 __1)) __1) (list b1 b2)]
>   [_ 'empty])
>
>
>
>
> Now I am getting somewhere, but I get 2 separate lists again, and I am not
> sure about memory effectiveness of match (I am assume it is effective).
> Can I get one list of structs in this scenario? (without manually looping
> over A tags) and how about nested (match) effectiveness?
> And now I begin to feel that parsing raw XML "by hand" won't be much
> harder then solution I am getting now. Perhaps this is due to intrinsic
> nature of XML itself?
>
>
>
> пятница, 22 ноября 2019 г., 17:10:19 UTC+2 пользователь Sage Gerard
> написал:
>>
>> I'm interested in this quote:
>>
>>  [...] creating a huge problems with even simple XML parsing. (I am
>> basically battling XML lib all day already to do most simple tasks)
>>
>>
>> I think that when you asked about why the xml collection behaves the way
>> it does, the conversation turned away from your experience.
>>
>> Could you elaborate on the specifics of what you are trying to do in one
>> of your projects so that we can see your pain points in context?
>>
>> *~slg*
>>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/f64331d0-374a-43ea-8a59-18c7e4457bc5%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsifbCPcVEa6q2Q0q0xtYy8rabjEEHJTVYHqdDMB9NycA%40mail.gmail.com.


Re: [racket-users] Efficient idiom for converting key-set of a hash-map into a hash-set

2019-10-25 Thread Sorawee Porncharoenwase
It also might be worth trying `(for/set ([(k v) (in-hash h)]) k)`.

On Fri, Oct 25, 2019 at 1:19 PM David Storrs  wrote:

> On Fri, Oct 25, 2019 at 10:28 AM Thomas Dickerson
>  wrote:
> >
> > For reasons that are unclear to me, hash-keys and dict-keys both return
> a list? instead of a set? (frankly, this seems like a bug in the API...).
> >
> > Is there a something I can do that's more efficient than just calling
> list->set?
>
> You could do   '(apply set list-of-keys)', although I'm not sure if
> that's more efficient or not.  You'd need to benchmark 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.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/36eb8bd7-45eb-4ebb-be30-ebdfd89023fe%40googlegroups.com
> .
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKodHgEeqffTCCSKDGP26jRt9oYmi42U0Vu%2BMyH6c2TQ5yw%40mail.gmail.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvk8wqkJsdJNqkQXSHi5FgYGZ4afRODYoZD8FnYmOcxVg%40mail.gmail.com.


Re: [racket-users] Simple macro issues

2019-09-08 Thread Sorawee Porncharoenwase
This works for me:

#lang racket

(define (hex:char x)
  (if (number? x)
  x
  (string->number (symbol->string x) 16)))

(define-syntax-rule (hex num ...) (bytes (hex:char (quote num)) ...))

(hex a b c 1 2 3) ; #"\n\v\f\1\2\3"

It’s almost always a mistake to use a function that manipulate syntax
object (syntax-e, etc.) inside syntax-rules, because syntax-rules don’t
give you an access to the syntax object. If you do want to manipulate
syntax object, use syntax-cases instead. In your case, however, the problem
is easy enough that you don’t need to directly manipulate syntax objects.

On Mon, Sep 9, 2019 at 12:12 PM Simon Haines <
simon.hai...@con-amalgamate.net> wrote:

> I'm trying to write a macro that will turn a list of hex literals into a
> byte string.
>
> (hex a b c 1 2 3) ; #"\n\v\f\1\2\3"
>
> After many hours I have finally come up with this:
>
> #lang racket
> (define-syntax hex
>   (syntax-rules ()
> [(_ num ...)
>  (bytes
>   (let ([e (syntax-e #'num)])
> (if (number? e) num
> (string->number (symbol->string e) 16))) ...)]))
>
> (hex a b c 1 2 3)
>
> Of course there are many issues with checking the parameters etc. My
> problem is this generates "a: unbound identifier in: a" because the
> arguments are evaluated? If I remove the last line it works in the REPL OK.
>
> I suspect this is a small matter of my phases being mixed up, or a
> misunderstanding of when macros can be defined and used, or just outright
> ignorance on my part. I couldn't find any clues in the many, many
> references and tutorials I have read. I want to master them but I loathe
> creating macros, they always make me feel like an idiot, and I hope Racket2
> simplifies them somehow.
>
> Thanks for any help sorting this one out.
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/6d096642-b770-4655-acc5-08b36e176554%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegveXyuSWqSts8Bk4D74aOaW-_BbJdV_q89Z5LNoG%2BGR9w%40mail.gmail.com.


Re: [racket-users] Listing All Programs

2019-09-05 Thread Sorawee Porncharoenwase
Oh, this is easy. The grammar of Racket is

#lang  *

which, as I showed above, is expressible as regular expression. Regular
languages are easily decidable :)



On Thu, Sep 5, 2019 at 9:07 PM Laurent  wrote:

> Although it's not about checking, but generating, which *may* be easier.
> (Though if one can generate all syntactically valid programs in program
> size order, then checking is just a matter of checking for membership in
> the list of all programs of size less than the program. This list can be
> huge however.)
>
> At least it's very simple to generate all 'syntactically' valid Turing
> machines ;)
>
> On Thu, Sep 5, 2019 at 2:56 PM David Van Horn  wrote:
>
>> But whether a program is syntactically valid is not an easy thing to
>> decide in a language like racket...
>>
>> On Thu, Sep 5, 2019, 9:45 AM Laurent  wrote:
>>
>>> Probably only those that output Chaitin's constant ;)
>>>
>>> But otherwise I would guess "syntactically valid", in which case it
>>> would be easier to consider only lambdas with only one argument.
>>>
>>> Though if you want to also use all of Racket's primitives (that is,
>>> including I/O), then good luck. My closest guess would be:
>>> (for/list ([i (in-naturals)])
>>>   (mflatt i))
>>>
>>> On Thu, Sep 5, 2019 at 2:31 PM David Van Horn 
>>> wrote:
>>>
 What do you mean by valid?

 On Thu, Sep 5, 2019, 9:05 AM Adam Golding 
 wrote:

> What is the shortest/smallest racket program (ithat enumerates all and
> only valid racket programs?
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/0b83b7d7-ea3e-434a-b6c4-f394a97fe4fd%40googlegroups.com
> 
> .
>
 --
 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.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/racket-users/CAFJHQkGS_%3DM9G%3DGaLXZgctO6UC_cR9VpqjXt5q211UOeOq2dFw%40mail.gmail.com
 
 .

>>> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CABNTSaGqXagO98Ttx1-rjmqSrdNyHn4m_UUd5_xazF-xiW2O_Q%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegs4t0dwKdF%2BbnFJ2w_k6_E7reHqVkEn_1wyv0HgcQr-Rw%40mail.gmail.com.


Re: [racket-users] Re: The case, and a proposal, for elegant syntax in #lang racket2

2019-08-21 Thread Sorawee Porncharoenwase
Pyret was a pain. Error messages were not clear and the whole change
> confused students.
>

Can you elaborate more on this? My personal experience with Pyret is that
it has an exceptionally good error message, except when an internal
error occurs (which should not happen).

Two language features caused us trouble, being the cause of impenetrable
> bugs in student code:
>

>
(a) Implicit begin .. end in function body. I have been writing Scheme for
> 20 years, and I **didn't know this existed**, always writing begin .. end
> in the very rare cases it was needed.
>

> Beginner Student (imho correctly) treats this as an error. I would be
> happy if advanced Racket also treated it as an error. You can end up with
> bizarre results if it is allowed and you don't notice what you have done.
> It allows, encourages even, paranthesis errors.
>

Well, why do your students use `#lang racket` rather than student languages?

And in my opinion, imposing students' programming environment constraints
to professional programming environment is probably not a good idea. There
are people who use `#lang racket` in imperative style. Forcing them to
write `begin` everywhere will just cause a hassle.

Pyret has this feature, by the way.


> (b)  Conds allowed without else. Even beginner student allows this. It
> causes bugs. In htdp/universe you can end up with a void universe or a void
> somewhere in univers. the error emerges a long distance in space and time
> from the code that causes it. Make else clauses compulsory.
>

A lot of people agree with you. Here's a (pre-) RFC on the issue:
https://github.com/racket/racket2-rfcs/issues/39

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtY-G1Xbe34Hs7fD4Yj36%2BOX86rKVVWi%3DgLnUx54eUT6A%40mail.gmail.com.


Re: [racket-users] Splicing the result of one macro into another

2019-08-21 Thread Sorawee Porncharoenwase
>
> I appreciate all of the Racket documentation, but I think there is a need
>> for a much better presentation of the material in a graduated way.
>>
>
I think what you are saying is, there should be more Racket Guide content,
and I think everyone agrees on that...


> you seem to have an excellent grasp of macros.
>

Well, not really. There are a lot of stuff I don't know!


> How did you acquire your knowledge of macros?
>

Mostly from reading tutorials and public code:
- https://www.greghendershott.com/fear-of-macros/
- https://www.hashcollision.org/brainfudge/
- https://docs.racket-lang.org/guide/macros.html
- https://docs.racket-lang.org/syntax/stxparse.html
- https://beautifulracket.com
- https://docs.racket-lang.org/syntax-parse-example/

I also attended Racket School in 2017, though as I understand the topic of
macro was focused less compared to later years -- if you attended Racket
school in recent years, you probably got the knowledge more than I did.

For more advanced topics, I learned a lot from Alexis's blog posts (
https://lexi-lambda.github.io). Ultimately there are papers and reports
like http://www.cs.utah.edu/plt/scope-sets/ which is a lot harder to read
but would be rewarding once you understand it.

Mailing list and Slack are very helpful to me, but the answers are very
easy to get lost (including this very thread, perhaps).

> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/0a39a0c4-bde5-4207-9abd-63b9d1ceec07%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegst8MGdZ7LbF1a%3DEppZ5kTaKcnwibfRXTb7Od6cKqfmRA%40mail.gmail.com.


Re: [racket-users] Splicing the result of one macro into another

2019-08-20 Thread Sorawee Porncharoenwase
   1. You will need a cooperation of phone-numbers macro. There are two
   ways I am aware of
   1.1 You could hard code in phone-numbers to deal with add-prefix
   directly.
   1.2 A more general approach is to use local-expand in phone-numbers to
   partially expand macros in the body of phone-numbers. In this case, this
   is to partially expand add-prefix to something that phone-numbers can
   recognize and deal with.
   2. The macro add-prefix is weird. It doesn’t expand to the compile-time
   macro number. Instead, it expands to a runtime function application (to
   construct a list of lists) and perform the string-append at runtime.
   This means it would be really hard for phone-numbers to process the
   partially expanded syntax if you were to use approach 1.2. Are you sure
   that this behavior of add-prefix is what you want?

Here’s my attempt to solve this problem, while trying to maintain the
external behavior you described.

#lang racket

(require (for-syntax syntax/parse))

;; number macro is needed so that "bare" add-prefix works correctly

(define-syntax (number stx)
  (syntax-parse stx
[(_ x:string) #'(list 'number x)]))

(number "123") ; ==> '(number "123")

;; - if the immediate macro is `number`, don't partially expand it, because
;;   `phone-numbers` know how to deal with it already. Note that
;;   the result attribute should be of ellipsis depth 1, so we need to do
;;   some normalization here.
;;
;; - otherwise, partially expand the immediate macro. The protocol is that
;;   the immediate macro should expand to (list (number xxx) ...).
;;   We then extract the result from it.

(begin-for-syntax
  (define-syntax-class do-expand
#:attributes ([result 1])
(pattern ({~literal number} _)
 #:with (result ...) (list this-syntax))
(pattern _
 #:with ({~literal list} result ...)
(local-expand this-syntax 'expression #f

(define-syntax (phone-numbers stx)
  (syntax-parse stx
[(_ :do-expand ...)
 (syntax-parse #'((~@ result ...) ...)
   [(((~literal number) phone) ...)
#'(list phone ...)])]))

(phone-numbers
 (number "1212")
 (number "2121")) ; ==> '("1212" "2121")

;; add-prefix computes at compile-time. It abides the protocol described above.

(define-syntax (add-prefix stx)
  (syntax-parse stx
[(_ prefix ((~literal number) str) ...)
 #:with (prefixed ...) (map (λ (s)
  (datum->syntax
   this-syntax
   (string-append (syntax-e #'prefix)
  (syntax-e s
(attribute str))
 #'(list (number prefixed) ...)]))

(add-prefix "555"
(number "1212")
(number "2121")) ; ==> '((number "5551212") (number "5552121"))

;; add-suffix computes at compile-time. It abides the protocol described above.

(define-syntax (add-suffix stx)
  (syntax-parse stx
[(_ prefix ((~literal number) str) ...)
 #:with (suffixed ...) (map (λ (s)
  (datum->syntax
   this-syntax
   (string-append (syntax-e s)
  (syntax-e #'prefix
(attribute str))
 #'(list (number suffixed) ...)]))

(add-suffix "555"
(number "1212")
(number "2121")) ; ==> '((number "1212555") (number "2121555"))

;;;

(phone-numbers
 (add-prefix "555"
 (number "1212")
 (number "2121"))
 (number "1234"))

;; similar to typing

(phone-numbers
 (list (number "5551212") (number "5552121"))
 (number "1234"))

;; ==> '("5551212" "5552121" "1234")



On Tue, Aug 20, 2019 at 3:13 PM Brian Adkins  wrote:

> Consider the following two macros:
>
> (require (for-syntax syntax/parse))
>
> (define-syntax (phone-numbers stx)
>   (syntax-parse stx
> [(_ ((~literal number) phone) ...)
>  #'(list phone ...)]))
>
> (define x (phone-numbers
>(number "1212")
>(number "2121"))) ; ==> '("1212" "2121")
>
> (define-syntax (add-prefix stx)
>   (syntax-parse stx
> [(_ prefix ((~literal number) str) ...)
>  #'(list (list 'number (string-append prefix str)) ...)]))
>
> (define y (add-prefix "555"
>   (number "1212")
>   (number "2121"))) ; ==> '((number "5551212") (number
> "5552121"))
>
> I would like to be able to do the following:
>
> (phone-numbers
>  (add-prefix "555"
>  (number "1212")
>  (number "2121"))
>  (number "1234")) ; ==> '("5551212" "5552121" "1234")
>
> I was hoping it would be possible to do this without modifying the
> phone-numbers macro. In other words, to have the result of expanding
> add-prefix macro call be:
>
> (number "5551212") (number "5552121")
>
> So that it would 

Re: [racket-users] Re: Macro containing a list of elements that each have optional keyword options

2019-08-19 Thread Sorawee Porncharoenwase
You could use (splicing) syntax class to help with normalization:

#lang racket

(require syntax/parse/define
 (for-syntax syntax/parse
 racket/syntax))

(begin-for-syntax
  (define-splicing-syntax-class methods-cls
#:attributes (methods)
(pattern (~seq #:methods (method:expr ...))
 #:with methods #'(list 'method ...))
(pattern (~seq #:method method:expr)
 #:with methods #'(list 'method)))

  (define-syntax-class route-cls
(pattern (route:string
  handler:id
  (~alt (~optional ms:methods-cls
   #:name "#:method, or #:methods option")
(~optional (~seq #:when guard-e:expr)
   #:name "#:when option")) ...)
 #:with methods #`#,(or (attribute ms.methods) #'(list))
 #:with guard #`#,(attribute guard-e

(define-simple-macro (routes :route-cls ...)
  #:with name (format-id this-syntax "axio-routes")
  (define name (list (list route handler methods guard) ...)))

(define (foo-handler) 0)
(define (bar-handler) 0)
(define (baz-handler) 0)
(define (use-bar-handler?) 0)

(routes
 ("/foo" foo-handler #:method put)
 ("/bar" bar-handler #:methods (put update) #:when use-bar-handler?)
 ("/baz" baz-handler))

axio-routes


On Mon, Aug 19, 2019 at 1:56 PM Brian Adkins  wrote:

> (define-syntax (routes stx)
>   (syntax-parse stx
> [ (routes (element ...) ...)
>   (with-syntax ([ name  (format-id stx "axio-routes") ])
> #'(define name (list (route-element element ...) ...)))]))
>
> (define-syntax (route-element stx)
>   (syntax-parse stx
> [ (route-element route:string
>  handler:id
>  (~alt (~optional (~or* (~seq #:methods (methods:expr
> ...))
> (~seq #:method method:expr))
>   #:name "#:method, or #:methods
> option")
>(~optional (~seq #:when guard:expr)
>   #:name "#:when option"))
>  ...)
>   (with-syntax ([ method-list (let ([ m  (attribute method)  ]
> [ ms (attribute methods) ])
> (cond [ m(list m) ]
>   [ ms   ms   ]
>   [ else '()  ]))]
> [ guard-func (let ([ fun (attribute guard) ])
>(if fun
>fun
>#f)) ])
> #'(list route handler 'method-list guard-func))]))
>
> (routes
>  ("/foo" foo-handler #:method put)
>  ("/bar" bar-handler #:methods (put update) #:when use-bar-handler?)
>  ("/baz" baz-handler))
>
> axio-routes
>
> ==>  '(("/foo" # (put) #f) ("/bar"
> # (put update) #)
> ("/baz" # () #f))
>
> I know it ain't pretty yet, but it works now, so I can enhance it later. I
> should probably use a struct for each route vs. a list.
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/ffc7ec25-f663-4d1d-a3d6-d3097d9c3963%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsvZ21nJTcpFzMRU0fTjyXtbUY-ZoDDT9A%2BN5qJHnFsxg%40mail.gmail.com.


Re: [racket-users] [racket users] module question

2019-08-06 Thread Sorawee Porncharoenwase
You need:

(module B racket
  (require (submod ".." A))
  (printf "X=~a~%" X))


On Tue, Aug 6, 2019 at 3:58 PM Kevin Forchione  wrote:

> Is there a way to define 2 modules within a file and reference them or is
> a file limited to 1 module only (but may have multiple submodules)?
>
> Here’s a small sample:
>
> #lang racket
>
> (module A racket
> ˘  (provide X)
>   (define X 'foo))
>
> (module B racket
>   (require 'A)
>   (printf "X=~a~%" X))
>
> Apparently, as I understand it, I’m already nesting modules within the
> #lang racket. But I’m not sure how to require A from within B in this
> situation.
>
> Kevin
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/6326DC5D-44D5-4CE9-B2B8-E781A6D51561%40gmail.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtEv-i5-j%2BnnKpKANAspGLiVDwrJ_sbBxKhvhBv%3D7oLag%40mail.gmail.com.


Re: [racket-users] Re: Do custodians shutdown when Racket exits?

2019-08-06 Thread Sorawee Porncharoenwase
I have a similar question on will executor. It doesn't seem to get run on
program exiting/breaking. Do I need a plumber that calls `collect-garbage`?

On Tue, Aug 6, 2019 at 10:27 AM David Storrs  wrote:

> I should mention that the reason I'm looking into this is because I have
> UDP sockets that are not getting closed.  They are managed by custodians,
> but the custodians are not releasing them; I take this to mean that the
> custodians are not being run.
>
> On Tue, Aug 6, 2019 at 1:06 PM David Storrs 
> wrote:
>
>> A bunch of reading through docs suggests that custodians do not
>> automatically run when Racket exits and that if I want them to then I
>> should either use a plumber (which is not guaranteed to run if there's a
>> segfault) or register the custodian with the ffi/unsafe/custodian module (
>> http://web.mit.edu/racket_v612/amd64_ubuntu1404/racket/doc/foreign/Custodian_Shutdown_Registration.html)
>> Is that right, or is there something I'm missing?
>>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKofYd5Uv4JWCbwjrHnmJuc%3DV%2BjVHWTwRxB9kdF1LsinEKg%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvhrpb-%2B%2BvJbEqLMOv%2B7Jz1sywkfjkfX9EbXcon7y3RAg%40mail.gmail.com.


Re: [racket-users] Why custom-display of printable<%> interface is called twice?

2019-07-28 Thread Sorawee Porncharoenwase
I’m not sure why it’s like that, but I know what’s the problem and how to
fix it.

custom-display and custom-write provide the output port to you. You are
supposed to write to the port.

(define/public (custom-display out)
  (displayln "custom-display" out))
(define/public (custom-write out)
  (writeln "custom-write" out))


On Sun, Jul 28, 2019 at 2:45 AM Jesse Wang  wrote:

> Hi, I created a simple class to test the printable<%> interface:
> (define my-class%
>   (class* object% (printable<%>)
> (super-new)
>
> (define/public (custom-display out)
>   (displayln "custom-display"))
> (define/public (custom-write out)
>   (writeln "custom-write"))
> (define/public (custom-print out depth)
>   (print "custom-print\n" out
>
> But when I try to display an object of this class, the custom-display
> function is called twice, why?
> >(define obj (new my-class%))
> >(display obj)
> custom-display
> custom-display
>
> And When I write the object, custom-display is also called first:
> > (write obj)
> custom-display
> "custom-write"
>
> With print:
> > (print obj)
> custom-display
> custom-display
> "custom-print\n"
>
>
> I think I must have missed something here, and I can't find anything about
> this in the documentation of printable<%>, please help.
> Thanks.
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/213fb232-d7fe-49f9-90d3-981c8662a0c5%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsJ39%3DXVBsHxLiotquW8uUGG7XyS0BSmwiPg0QYPjgkXQ%40mail.gmail.com.


Re: [racket-users] Contracts referring to earlier elements?

2019-07-18 Thread Sorawee Porncharoenwase
Hi Kevin,

Take a look at Racket Guide’s Argument and Result Dependencies

and/or Racket Reference’s ->i

.

In contrast to The Racket Reference which is technical and more difficult
to navigate, Racket Guide is very easy to navigate and explains stuff
really well. Reading the table of contents is usually enough to point you
to the section that you want.

On Thu, Jul 18, 2019 at 1:48 PM Kevin Forchione  wrote:

> Hi guys,
> This is a little tricky to explain, so I’ll give a small example:
>
> [define/contract [foo x) (-> integer? not-x/c) body …)
>
> In this case the not-x/c is what I’m asking about. Some way that the
> contract can refer to a previous argument value? Ordinarily this would be a
> predicate, but the parameters don’t appear to be in the scope of the
> contract. so ((λ (v) (not (= v x))) won’t work here, but it gets at the
> issue I”m interested in. I could of course interrogate the arguments inside
> the body of the function, but was wondering if a contract could do so.
>
> Kevin
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/33F99A77-8609-4C37-AF59-E407A38A066A%40gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtPeTpVFVsDfNv5MX%2BpsH4rjjqLJ3s%2B-v9gC6jdxxuHDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2

2019-07-18 Thread Sorawee Porncharoenwase
>
> The other thing I'd like to see would be the option to return nothing.
> Not #, '(), or #f.  Nothing.  It's useful e.g. when you want to
> simultaneously transform and filter a list.
>

Would (values) satisfy your criteria?

#lang racket

(define (my-filter-map proc xs)
  (match xs
['() '()]
[(cons x xs)
 (call-with-values
  (thunk (proc x))
  (case-lambda
[() (my-filter-map proc xs)]
[(x) (cons x (my-filter-map proc xs))]))]))

(my-filter-map (λ (x) (if (odd? x) (values) (add1 x))) '(1 2 3 4)) ;=> '(3 5)

One thing I don’t like about it is that zero values (and multiple values in
general) are really unwieldy to work with and doesn’t compose well with the
rest of Racket. You can for example translate v >>= f in Haskell to just (and
v (f v)) in Racket. But trying to do the same thing with zero values is a
headache.

>
> On Wed, Jul 17, 2019 at 11:50 PM Daniel Prager 
> wrote:
>
>> I'm confused on one point.
>>
>> Why would a new canonical notation be preferable to, say, also fully
>> supporting an alternative general notation (like Shriram's p4p, or a
>> derivative thereof) or even multiple notations in addition to retaining
>> good old s-expressions?
>>
>> The idea would be that you could transform freely and readably between
>> alternative notations, enabling round-tripping without degradation.
>>
>> I imagine that effectively providing tooling, syntax-extension, good
>> error messages, and documentation across multiple notations would be (ahem)
>> challenging, but so long as we're dreaming big ...
>>
>>
>> Dan
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAFKxZVV-njHNCCLDP-RsDq%2BjbXrOGpOnaEp9Ob4ugTbdtmckAw%40mail.gmail.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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKodKrWNeL3tJQ5uO4X64jKzBVmYY2P9BgLsd%3Dqh8bhSQyw%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcueguTp19B7Yqb9nZM%3DJfiofWU4-JBdC-aaoFXq4vthUe3NQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] raise-argument-error missing list?

2019-07-08 Thread Sorawee Porncharoenwase
On Mon, Jul 8, 2019 at 12:56 PM Greg Hendershott rac...@greghendershott.com
 wrote:

- The return value is `any` -- not even `any/c`, just `any`. Effectively
>   don't check the return value(s).
>
If I use define/contract, does any restore tail-recursion?

You could also move some definitions into a sub-module, and contract the
> provide from there.
>
I’m very excited about #:unprotected-submodule

which could generate an unsafe submodule, and let clients pick a version
they want to use. Note that it’s not in Racket 7.3, but presumably is going
to be in Racket 7.4.

In general, though, I wish there are contract exporting combinators. E.g.,
a combinator that suppresses post-condition checking, or a combinator that
approximates a higher-order contract into a first-order contract.
contract-out then can generate multiple submodules with different contracts
according to these combinators.

In any case, the nice thing is that you can use or create any boundary
> you prefer to put the contract on.
>
It’s nice indeed, but I wish switching boundaries could be easier.
Changing (define/contract
...) to (provide (contract-out ...)) (define ...) (and vice versa) is not
fun. A macro that facilitates this switching in the stdlib would be nice.

But in a call chain we can end up verifying a value repeatedly and wouldn’t
it be marvelous if we could somehow pass it’s certification in syntax (no,
I don’t know what I’m talking about, just dreaming) so that verification
would only happen once and when needed?

That’s what Typed Racket does. As I understand, in untyped modules, Racket
also elides pair checking when it’s safe to do so.

Gustavo’s work-in-progress addition to the Chez Scheme compiler introduces
the kinds of optimizations that he has long built and maintained in the
current Racket implementation. For example, (f (car x) (cdr x)) can be
optimized to (f (car x) (unsafe-cdr x)). These optimizations are
particularly helpful for structure-field access and update, and preliminary
measurements suggest that the optimizations can provide about half of the
performance benefit of unsafe mode (so, typically 5-10%) without the
unsafety.

But yes, eliding contract checks in general is my dream as well.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegutcPCGrU2CFEXqBEWf3oktXd2kY-YegGO75z0T6%3DvWLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Trying to get my head around typed racket and higher order functions

2019-06-30 Thread Sorawee Porncharoenwase
inst is the way to go. How did you use it? This seems to work fine for me.

#lang typed/racket

(: create-points : (Listof Flonum) (Listof Flonum) -> (Listof
(Vectorof Flonum)))
(define (create-points xs ys)
  (map (inst vector Flonum) xs ys))


On Sun, Jun 30, 2019 at 1:03 AM greadey  wrote:

> Hi all,
>
> I have a function - create-points- which takes two lists of Flonum and
> yields a list of vector pairs suitable for passing to Racket's plot
> function.
>
> In un-typed code I can just do;
>
> (define (create-points xs ys)
>   (map vector xs ys))
>
> and voila!  It works.  However the only way I have managed to get it to
> type check is by wrapping the vector function in a lambda;
>
> (: create-points : (Listof Flonum) (Listof Flonum) -> (Listof (Vectorof
> Flonum))
>
> (define (create-points xs ys)
>   (map  (lambda ([x : Flonum] [y : Flonum]) (vector x y)) xs ys)).
>
> I have tried using an inst form, but I cannot seem to get that to work.
> Question is thought, is wrapping the vector function in a lambda the only
> way to do this?
>
> Cheers,
>
> greadey
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/b6192278-03b1-4720-a3c2-72a915e6c959%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvU8MgGhz8LhmDn-UEQY1kH1ipD3-QmNrd%3DR6W7zDd_QA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Pattern matching as computation

2019-06-27 Thread Sorawee Porncharoenwase
If you want only one match, it seems what you really want is ~seq-like form
from syntax/parse. E.g.,

#lang racket

(require syntax/parse)

(define ->value syntax->datum)

(define (apply-lift op args)
  (datum->syntax #f (apply op (->value args

(syntax-parse (vector 1 2 3 4)
  [#(a {~and {~seq {~between b 2 2} ...}
 {~bind [x (apply-lift + #'(b ...))]}} c)
   (->value #'(a (b ...) c x))])
;; => '(1 (2 3) 4 5)

(struct person (name age) #:prefab)
(struct horse (color owner) #:prefab)

(syntax-parse (vector 'brown 'bob 23)
  [#(the-color {~and {~seq args ...}
 {~bind [the-owner (apply-lift person #'(args ...))]}})
   (->value (apply-lift horse #'(the-color the-owner)))])
;; => '#s(horse brown #s(person bob 23))





On Thu, Jun 27, 2019 at 3:31 PM David Storrs  wrote:

>
>
> On Thu, Jun 27, 2019 at 5:13 PM Eric Griffis  wrote:
>
>> On Thu, Jun 27, 2019 at 11:56 AM David Storrs 
>> wrote:
>> >
>> > Suppose instead I wanted to have a pattern like so (this does not work):
>> >
>> > (match (vector 1 2 3 4)
>> >   [(vector a (app + b ..2 x) c) (list a b c x)]
>> > ; => '(1 (2 3) 4 5))  ;  NB:  does not work
>>
>> We have a few problems here.
>>
>> The pattern (vector a ? c) does not match the shape of the val-expr
>> (vector 1 2 3 4).
>>
>> In the second sub-pattern (app + b ..2 x), Racket complains `..2' is an
>> "incorrect use of ... in pattern" because every sub-pattern of `app' must
>> independently match the result of (+ 2).
>>
>> To get the expected result '(1 (2 3) 4 5) from the actual result (list a
>> b
>> c x), we'd need the following bindings:
>>
>> a --> 1
>> b --> '(2 3)
>> c --> 4
>> x --> 5
>>
>> At this point, I'm not sure what you're trying to do. Maybe you're trying
>> to bind `b' to '(2 3), then `x' with the sum (+ 2 3), then `c' with 4.
>>
>> Here's one way to do it from within a single pattern:
>>
>> (match (vector 1 2 3 4)
>>   [(and (vector a _ _ c)
>> (app (λ (vec)
>>(match vec
>>  [(vector _ p q _)
>>   (list (list p q) (+ p q))]))
>>  (list b x)))
>>(list a b c x)])
>>
>> > Less trivially, I'd like to be able to do something like this:
>> >
>> > #lang racket
>> > (struct person (name age) #:prefab)
>> > (struct horse (color owner) #:prefab)
>> >
>> > ; The following does not work
>> > (match (vector 'brown 'bob 23)
>> >   [(vector the-color (app (curry apply person) args ... the-owner))
>> >(horse the-color the-owner)])
>>
>> Here's an adaptation of the above technique that works:
>>
>> (match (vector 'brown 'bob 23)
>>   [(and (vector the-color _ _)
>> (app (λ (vec)
>>(match vec
>>  [(vector _ name age)
>>   (person name age)]))
>>  the-owner))
>>(horse the-color the-owner)])
>>
>
> Makes sense -- it's two matches,  but still within one sexp.  Thanks.
>
>
>> Incidentally, Algebraic Racket is designed for this:
>>
>> #lang algebraic/racket/base
>>
>> (require (prefix-in algebraic- algebraic/racket/base/forms))
>>
>> (algebraic-case (vector 1 2 3 4)
>>   [#(a p q c)
>>#:with b (list p q)
>>#:with x (+ p q)
>>(list a b c x)])
>>
>> (algebraic-case (vector 'brown 'bob 23)
>>   [#(the-color name age)
>>#:with the-owner (person name age)
>>(horse the-color the-owner)])
>>
>> If a #:with directive fails, the overall match fails:
>>
>> (algebraic-case (vector 'brown 'bob 23)
>>   [#(the-color name age)
>>#:with the-owner #f
>>#:with (person _ _) the-owner
>>(horse the-color the-owner)])
>>
>>
> That is drop-dead sexy.  Thanks, Eric.
>
>
> Eric
>>
>> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKocxGYu0vKvUzW%3Dfc1X7acXmZjCmz6mPKErDWvNmjKLmZw%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtXfWvz9n42Sa5KdWLGy5-ZDDQP7NM6gcT0ShGwKVcK5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Relative Pathname problem

2019-06-23 Thread Sorawee Porncharoenwase
This is almost certainly due to Geiser and not Racket. IIRC, there are C-c
C-a and C-c C-b. One of them works with Racket and the other does not.

If you only work with Racket, I would recommend racket-mode
 instead of Geiser. It's far more integrated to
Racket.

On Sun, Jun 23, 2019 at 1:03 PM Amir Teymuri  wrote:

> I have version 7.3. The problem was that i have to start the interactive
> racket from the scratch.rkt file which imports from other modules. I am
> using racket on Emacs with the Geiser mode.
>
> On Sunday, June 23, 2019 at 4:55:20 AM UTC+2, Ben Greenman wrote:
>>
>> I tried to reproduce this problem, but wasn't able to.
>>
>> Which version of Racket are you using? How did you run the program?
>>
>> On 6/20/19, Amir Teymuri  wrote:
>> > I have the following situation:
>> >
>> > mylibrary:
>> >
>> >-src
>> >   - font.rkt
>> >   - gui.rkt
>> >- scratch.rkt
>> >
>> >
>> > So the src/ directory and the scratch.rkt file live in the same
>> directory
>> > mylibrary/. According to the documentation of Modules
>> > (https://docs.racket-lang.org/guide/module-basics.html):
>> >
>> > The "sort.rkt" module uses the relative paths "db/lookup.rkt" and
>> > "machine/control.rkt" to import from the database and machine-control
>> > libraries...
>> >
>> > So i put these lines in my scratch.rkt:
>> >
>> > #lang racket
>> >
>> > (require "src/font.rkt"
>> >  "src/gui.rkt")
>> >
>> > but upon requiring the modules i get the error:
>> >
>> >
>> >
>> > (require "src/font.rkt"
>> >  "src/gui.rkt")
>> >
>> > Error: struct:exn:get-module-code
>> >
>> > get-module-code: no such file:
>> #
>> >
>> > Why is Racket putting another src/ before the actual src/ directory?
>> >
>> > Thanks,
>> > Amir
>> >
>> > --
>> > 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...@googlegroups.com.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/racket-users/ed560f1e-93df-4835-ad62-0d8b76cd8ed6%40googlegroups.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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/3ffd20cb-2f00-4b98-8b48-054cf4a265b3%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtJJ7jPKO0x_idhX37D3nayv%3Dx4ZhFQSF_-m54bat_s6g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] symbols question

2019-06-20 Thread Sorawee Porncharoenwase
Is #%top  what you are
looking for?

#lang racket

(require syntax/parse/define)

(define-simple-macro (#%top . x) 'x)

(define x 42)
x ;=> 42
y ;=> 'y
(string-length (symbol->string abcdef)) ;=> 6

Unbound identifiers are wrapped with #%top during expansion steps
,
so you can define #%top to deal with unbound ids. For instance, Pollen
 by default uses #%top to create default tags
.

On Thu, Jun 20, 2019 at 9:23 PM Kevin Forchione  wrote:

> Hi guys,
> Every now and then I wonder about the decisions behind the languages we
> work with and of late I’m wondering about symbols. By default symbols
> reveal their binding value unless you explicitly tell them not to — in
> other words unless you quote them. And that’s pretty useful. In macros I
> can control this behavior by taking my symbol and wrapping a quote around
> it. And I’ve even had some good results with guards using
> identifier-binding to determine whether I need to do that or not — though
> I’m not sure about the limitations and contextual restrictions of that
> approach — there’s nothing that simply says “if this symbol is exposed to
> evaluation it’ll produce a binding exception so we’ll wrap it in a quote
> for you” sort of mechanism that I’m aware of…  at least not one that
> doesn’t require some qualification.And there’s the other approach that I’m
> playing with now as well: wapping symbols in quotes by default unless I
> explicitly state not to — a sort of unquote passed into the macro syntax
> that makes the syntax look a little like MDL, but I haven’t worked out all
> the kinks in that approach yet. And of course sometimes I’d like to just
> toss symbols around without having a bind to worry about — keywords I
> suppose, but without the association to function arguments — just something
> to compare or key on. I suppose there’s probably a way to do this with the
> reader, though I haven’t looked into that much yet. And finally there’s the
> common lisp itch I get from time to time to have symbols with bindings and
> plist sort of associations — parameterized hash tables to store the values
> perhaps.
>
> In all this meandering, the question is whether there are libraries doing
> these sorts of things already? It’s fun to re-invent the wheel at times,
> but also instructive to learn while standing on the shoulders of giants, so
> to speak, and creatively stimulating. :)
>
> Kevin
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/EB9B5188-4B62-42BB-B24F-2B95166E95F7%40gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvT5013YWNKo3h6xEpXRYWtz_mpwbWPu1bRJbenObg_kg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] macro guard question (ellipsis)

2019-06-18 Thread Sorawee Porncharoenwase
Also note that with syntax/parse, it becomes much easier:

(require (for-syntax syntax/parse))

(define-syntax (foo stx)
  (syntax-parse stx
[(_ (key:id val:id ...) ...)
 #'(quote (list ((quote key) (quote val) ...) ...))]))


On Tue, Jun 18, 2019 at 8:56 PM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> I’d write this. Not sure if there’s a better way.
>
> (define-syntax (foo stx)
>   (syntax-case stx ()
> [(_ (key val ...) ...)
>  (andmap identifier? (syntax->list #'(key ... {~@ val ...} ...)))
>  #'(quote (list ((quote key) (quote val) ...) ...))]))
>
>
> On Tue, Jun 18, 2019 at 8:11 PM Kevin Forchione  wrote:
>
>> Hi guys,
>> I’ve been trying to figure out the syntax for a guard when the pattern
>> has ellipsis and you want to guard one of the variables. Here’s an
>> uninteresting macro but it shows what I mean.
>>
>> #lang racket
>>
>> (define-syntax (foo stx)
>>   (syntax-case stx ()
>> [(_ (key val ...) ...)
>>  (and (identifier? #'key) (identifier? #'val))
>>  #'(quote (list ((quote key) (quote val) ...) ...))]))
>>
>> (foo (a b) (c d e))
>>
>> Of course it complains about the ellipsis being missing in the pattern.
>> Is this something I can handle with a guard in this manner or do I need a
>> helper macro of some sort?
>>
>> Thanks!
>> Kevin
>>
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/D76D1CBC-BF78-493F-89B9-9498D615A5E7%40gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegu-g0rHDJWrhM9%2BkFhLsc9k0ztvj3OoO0Fe5w%2Bk6MmFqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] macro guard question (ellipsis)

2019-06-18 Thread Sorawee Porncharoenwase
I’d write this. Not sure if there’s a better way.

(define-syntax (foo stx)
  (syntax-case stx ()
[(_ (key val ...) ...)
 (andmap identifier? (syntax->list #'(key ... {~@ val ...} ...)))
 #'(quote (list ((quote key) (quote val) ...) ...))]))


On Tue, Jun 18, 2019 at 8:11 PM Kevin Forchione  wrote:

> Hi guys,
> I’ve been trying to figure out the syntax for a guard when the pattern has
> ellipsis and you want to guard one of the variables. Here’s an
> uninteresting macro but it shows what I mean.
>
> #lang racket
>
> (define-syntax (foo stx)
>   (syntax-case stx ()
> [(_ (key val ...) ...)
>  (and (identifier? #'key) (identifier? #'val))
>  #'(quote (list ((quote key) (quote val) ...) ...))]))
>
> (foo (a b) (c d e))
>
> Of course it complains about the ellipsis being missing in the pattern. Is
> this something I can handle with a guard in this manner or do I need a
> helper macro of some sort?
>
> Thanks!
> Kevin
>
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/D76D1CBC-BF78-493F-89B9-9498D615A5E7%40gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegtJUgVOOEm%3DS1qKmVqiviCqMYb6gudfjU_QfUzTSw5sZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Why struct type doesn't include field names?

2019-06-15 Thread Sorawee Porncharoenwase
First of all, . won’t work in standard Racket because . has a special
meaning (see
https://docs.racket-lang.org/reference/reader.html#%28part._parse-pair%29).

But yes, this is directly related to the discussion above because with the
field name information, you can write your own accessor.

#lang racket

(module submodule racket
  (provide @)
  (require syntax/parse/define)

  (define (access e fld)
(match-define-values (info _) (struct-info e))

;; for now we hard code it; would be able to extract it from
struct-type-info in Racket 2
(define fields '(bar baz))

(match-define-values (name _ _ accessor _ _ _ _) (struct-type-info info))
(accessor e (index-of fields fld)))

  (define-simple-macro (@ e:expr fld:id) (access e 'fld)))

(require 'submodule)

(struct foo (bar baz) #:transparent)
(define my-foo (foo 1 2))

(@ my-foo baz) ;=> 2

Note that your struct must not be opaque for this to work. Typed Racket
might have enough compile-time data to make this to work with opaque
structs, though.

But for now, https://docs.racket-lang.org/struct-define/index.html might be
a good workaround for your problem.





On Fri, Jun 14, 2019 at 3:37 PM Dmitry Pavlov  wrote:

> Hello,
>
> While we are at it: is it theoretically possible in Racket or Typed Racket
> (or will be possible in Racket 2 or Typed Racket 2) to access struct fields
> without repeating the name of the struct type again?
>
> Like in C
>
> typedef struct
> {
>double x;
>double y;
> } VeryLongStructureName;
>
> VeryLongStructureName a;
>
> double z = a.x + a.y;
>
>
> The analogous Racket code for the last line would be
>
> (define z (+ very-long-structure-name-x a) (+ very-long-structure-name-y
> a))
>
> and I am wondering whether it can be shortened to something like (define z
> (+ (. x a) (. x b)))
>
> (I know that match can work with structs, but it is not always as
> convenient as the C way with the dot)
>
>
> Best regards,
>
> Dmitry
>
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/d23df714-e808-91f3-b978-29bcca849100%40iaaras.ru
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegsp37-mE_i-wN9k8Q1hAAS%3DyO2fy0_qaQKZs%3DAdxET-vw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Why struct type doesn't include field names?

2019-06-13 Thread Sorawee Porncharoenwase
Several struct extensions need to construct accessors unhygienically even
though the accessors can be extracted from struct types. The reason is that
there’s not enough information to establish connection between field names
and accessors.

For instance, consider struct* from racket/match.

#lang racket

(module submodule racket
  (provide struct-id)
  #;(provide struct-id-a struct-id-b)
  (struct struct-id (a b)))

(require 'submodule)

(match (struct-id 1 2)
  [(struct-id p q) (printf "~a ~a\n" p q)])

#;(match (struct-id 1 2)
  [(struct* struct-id ([a p] [b q])) (printf "~a ~a\n" p q)])

The above code runs fine. Notice that we only provide struct-id from the
submodule, but match could still destruct the struct correctly because it
can obtain accessors from the struct type inside struct-id.

However, if we uncomment the second comment, the code fails with the error:

; struct*: field name not associated with given structure type
;   at: struct-id-b
;   in: (struct* struct-id ((a p) (b q)))

By uncommenting code inside the submodule to provide struct-id-b and
struct-id-a, the code now runs fine again.

As I understand, the reason why struct* and other struct extensions like
kw-make-struct 
couldn’t use accessors extracted from struct-id is that there’s no mapping
from field name to accessors.

Hence the question: why struct type doesn’t include field names?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvjQ_%2BgYg_VQb4TG-czSAMzZJOtZ0K3Ge7c_XNUO2QzCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Macro guards question

2019-05-29 Thread Sorawee Porncharoenwase
The issue is that #'arg will always be a syntax object. An identifier is a
kind of syntax object, so it makes sense to test (identifier? #’arg).
However, (symbol? #’arg) and (string? #’arg) will always fail.

Suppose then that you invoke the macro with "1" as the operand, it would
fail every case in syntax-case, so syntax-case throws a bad syntax (because
a syntax transformation must be total), causing the error that you saw.

If you insist on using syntax-case, then try this:

(define-syntax (foo stx)
  (syntax-case stx ()
[(_ arg) (identifier? #'arg) #'1]
[(_ arg) (string? (syntax->datum #'arg)) #'2]
[(_ arg) (number? (syntax->datum #'arg)) #'3]
[(_ (quote* x)) (and (free-identifier=? #'quote* #'quote)
 (symbol? (syntax->datum #'x))) #'4]
[(_ _) #'5]))

(foo a) ;=> 1
(foo "a") ;=> 2
(foo 10) ;=> 3
(foo 'a) ;=> 4
(foo (bar x)) ;=> 5

A better way though is to use syntax-parse.

(require (for-syntax syntax/parse))

(define-syntax (foo stx)
  (syntax-parse stx
#:literals (quote)
[(_ arg:id) #'1]
[(_ arg:string) #'2]
[(_ arg:number) #'3]
[(_ (quote x:id)) #'4]
[(_ _) #'5]))

(foo a) ;=> 1
(foo "a") ;=> 2
(foo 10) ;=> 3
(foo 'a) ;=> 4
(foo (bar x)) ;=> 5


On Wed, May 29, 2019 at 10:23 AM Kevin Forchione  wrote:

> Hi Guys,
> What are the rules for macro guards? I’ve only seen examples with
> (identifier? #’val) being used. What about (number? #’val) or (spring?
> #’val)? When I try these I get a foo: bad syntax so I’m suspecting these
> can’t be used or there’s some trick to them.
>
> What I’ve been trying to create (and maybe this isn’t the right way to go
> about it) is a syntax-case that would have have various type checks as
> guards and then select the branch based on whether I’ve got an identifier
> or just a symbol, or a number or a string, etc.
>
> (syntax-case six ()
>   [(_ arg) (identifier? #’arg) #’(identifier-handler arg)]
>   [(_ arg) (symbol? #’arg) #’(symbol-handler arg)]
>   [(_ arg) (string? #’arg) #’(string-handler arg)]
>…)
>
> That sort of thing.
>
> Primarily I find myself running into an issue where I’m using symbols for
> lookup keys and identifiers for their reference values  and running into a
> wall of wanting the macro to go ahead and handle them differently without
> have the old “foo undefined” popping up. :)
>
> Kevin
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/DED7E28E-9B3D-4045-B0DC-CBD3AB11E653%40gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvP%3DpmJRuZCSFmQjtyo7nxQFmo0JnoXjCW1WpnEdmnMpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Sorawee Porncharoenwase
On Mon, May 27, 2019 at 7:54 PM Greg Hendershott 
wrote:

> p.s. That (datum->syntax _ (string->symbol (syntax->datum _))) triplet
> has an equivalent handy shortcut -- `format-id`:
>
>   (format-id #'magic-name "~a" #'magic-name)


 This doesn't work in the string literal case because an argument of
`format-id` must be an identifier (or symbol, or string, but not a syntax
object of a string literal).

On Mon, May 27, 2019 at 10:45 PM Alexis King  wrote:

> As a final note, `syntax-parse`’s `#:with` form is slightly different from
> `with-syntax` in this respect, as it really will use `(datum->syntax #f
> )` instead of trying to guess at what scopes you might have wanted.
>

Aha! I didn't understand why sometimes `with-syntax` works while `#:with`
doesn't until now. Thanks so much for this.


> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/49B6B0B9-1D03-4E66-B5C1-C70C45A22235%40gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcueguBNLS_a-5vdDnh%3D%3DwQkazpipvfSEg-XuZqQA-8Ytystg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] redundancy in GUI callback functions

2019-05-25 Thread Sorawee Porncharoenwase
Just abstract the common part out? E.g.,

(define (update-text-field read-field write-field converter)
  (define text (send read-field get-value))
  (cond
[(string=? text "")
 (send read-field set-field-background (make-object color% 255 255 255 1))
 (send write-field set-value "")]
[(number? (string->number text))
 (send read-field set-field-background (make-object color% 255 255 255 1))
 (send write-field set-value (converter (string->number text)))]
[else
 (send read-field set-field-background (make-object color% 255 0 0 1))
 (send write-field set-value "")]))

(define (update-fahrenheit control event)
  (update-text-field text-celsius text-fahrenheit convert-c))

(define (update-celsius control event)
  (update-text-field text-fahrenheit text-celsius convert-f))

Note that your original code has a bug: you always use convert-c in both
directions. Obviously, in update-celsius you want to use convert-f.

There’s also another subtle bug that I didn’t fix. Suppose you type an
invalid character (like “a”) to the left text field. This will make the
field become red. Now, switch to the right field and type “32”. The left
field will output “0” while being red, though it probably should now be
white.

On Sat, May 25, 2019 at 7:57 PM Travis Hinkelman 
wrote:

> Hi All,
>
> I'm working through the tasks in 7guis
>  to learn about GUI programming
> in Racket. My code
>  for
> the temperature converter task works as expected but there is a lot of
> redundancy in my update-fahrenheit and update-celsius callback functions. I
> would appreciate feedback on how to make this code less redundant.
>
> Thanks,
>
> Travis
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/8f97260c-62be-4a6f-9459-244a88632ef9%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegukbchny44MGo6cnDH8THEfp74t09%2B0sqZTPa3UNiOa2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket Mode documentation

2019-05-24 Thread Sorawee Porncharoenwase
Hmm. I'm seeing "This site can’t be reached" (DNS_PROBE_FINISHED_NXDOMAIN).

On Thu, May 23, 2019 at 8:50 PM Greg Hendershott 
wrote:

> Recently I consolidated and updated Racket Mode documentation.
>
> It is generated in two formats:
>
> - Info: Installed locally. View in Emacs with `C-h i`.
>
> - HTML: View at .
>
>
> If you're curious how it's prepared:
> .
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/87sgt48q9r.fsf%40greghendershott.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegs5OyyAHu52L%3DDRG8jAvFKTRKJPGW%2B522kX5ESU6RjgjQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] How can I include a literal ellipsis in a macro?

2019-04-10 Thread Sorawee Porncharoenwase
Use either (... ...) or (quote-syntax ...).

See https://stackoverflow.com/a/38276476/718349

On Wed, Apr 10, 2019 at 3:23 AM David Storrs  wrote:

> Assuming I would like a macro to generate a match statement, like the
> following:
>
> (match foo
>   [(list (vector x y z) ...)  ])
>
> '...' already has a meaning for a syntax transformer and I'm not sure how
> to tell it "no, this one should be inserted literally".  I tried putting it
> into a binding so that I could use the binding instead of a literal '...',
> but this isn't legal syntax:   #:with repeat #'...
>
> What is the right way to do this?
>
> --
> 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.


  1   2   >