Re: [racket-users] Apple Silicon build errors

2022-01-17 Thread Sorawee Porncharoenwase
That sounds right to me.

On Mon, Jan 17, 2022 at 9:27 AM Nathaniel W Griswold  wrote:

> Ah, ok, my build finished and everything seems to be working well. The
> binary is signed, too. It seems to have used codesign.rkt along the way
> there, so i think i actually needed both Matthew's recommended commit and
> yours (codesign.rkt imports compiler/private/mach-o). Does that sound
> right, to use both patches? I was gonna try to get nixpkgs building 8.3.
>
> Thanks
>
> Nate
>
> > On Jan 17, 2022, at 10:56 AM, Sorawee Porncharoenwase <
> sorawee.pw...@gmail.com> wrote:
> >
> > That particular issue is fixed by
> https://github.com/racket/racket/commit/3a8a7102abff334ee4e054c3597bebba32bda307,
> if I remember correctly.
> >
> > On Mon, Jan 17, 2022 at 8:50 AM Nathaniel W Griswold  wrote:
> > Hm, Ok. The cherry-pick of 0a8b68b286 does in fact apply cleanly to the
> v8.3 tag.
> >
> > I am still having the same issue, though, even after a full clean. Right
> now, I only have command-line tools (latest). I am downloading the full
> Xcode again but it's gonna be a little bit before i can test that, the
> download is kinda big.
> >
> > Nate
> >
> > > On Jan 17, 2022, at 10:24 AM, Matthew Flatt 
> wrote:
> > >
> > > This is a problem with v8.3 and the latest Apple tools. It's fixed for
> > > the upcoming v8.4 release (so, in the main branch and in the current
> > > snapshot source distributions).
> > >
> > > In case you want a minimal patch, commit 0a8b68b286 is the repair and
> > > might apply cleanly to v8.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/7B3C6174-8094-4F23-8CB3-B70597D9F05B%40nan.sh
> .
> >
> > --
> > You received this message because you are 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/CADcuegv24-MqiRUNe9yt_Bc%2BPR3BYkXE%3DS9ypSsVFm44%3DEdObg%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/CADcuegt5i8sZGwST32NiuPrSnPRcXyqgkBrP55sNzb%3DLR-%2BXOA%40mail.gmail.com.


Re: [racket-users] Apple Silicon build errors

2022-01-17 Thread Sorawee Porncharoenwase
That particular issue is fixed by
https://github.com/racket/racket/commit/3a8a7102abff334ee4e054c3597bebba32bda307,
if I remember correctly.

On Mon, Jan 17, 2022 at 8:50 AM Nathaniel W Griswold  wrote:

> Hm, Ok. The cherry-pick of 0a8b68b286 does in fact apply cleanly to the
> v8.3 tag.
>
> I am still having the same issue, though, even after a full clean. Right
> now, I only have command-line tools (latest). I am downloading the full
> Xcode again but it's gonna be a little bit before i can test that, the
> download is kinda big.
>
> Nate
>
> > On Jan 17, 2022, at 10:24 AM, Matthew Flatt  wrote:
> >
> > This is a problem with v8.3 and the latest Apple tools. It's fixed for
> > the upcoming v8.4 release (so, in the main branch and in the current
> > snapshot source distributions).
> >
> > In case you want a minimal patch, commit 0a8b68b286 is the repair and
> > might apply cleanly to v8.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/7B3C6174-8094-4F23-8CB3-B70597D9F05B%40nan.sh
> .
>

-- 
You received this message because you are 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/CADcuegv24-MqiRUNe9yt_Bc%2BPR3BYkXE%3DS9ypSsVFm44%3DEdObg%40mail.gmail.com.


Re: [racket-users] Core Team: I need you decide what I should do about the spammer.

2021-12-19 Thread Sorawee Porncharoenwase
FWIW, here're the settings of racket-users from the About tab:

Anyone on the web: can see group
Group owners and managers: can view members
Anyone on the web: can view conversations
Group members: can post
Invited users: can join group

and here're the settings of racket-dev:

Anyone on the web: can see group
Group members: can view members
Anyone on the web: can view conversations
Group members: can post
Anyone on the web: can join group

It looks like racket-users might need to change "Group owners and managers:
can view members" to "Group members: can view members", and racket-dev
might need to change "Anyone on the web: can join group" to "Invited users:
can join group".



On Sun, Dec 19, 2021 at 5:25 PM Nadeem Abdul Hamid  wrote:

> In other Google groups that I'm on, when I view the group, the links in
> the left bar read "Conversations", "Members", "About", "My membership
> settings". But in the Racket Users, there isn't a link to the "Members"
> list.
>
> On Sun, Dec 19, 2021 at 5:24 PM Sage Gerard  wrote:
>
>> Looks like I scoped invitation powers to group managers, not members.
>> Checking on this.
>>
>>
>> Sent from ProtonMail mobile
>>
>>
>>
>>  Original Message 
>> On Dec 19, 2021, 4:17 PM, Nadeem Abdul Hamid < nad...@acm.org> wrote:
>>
>>
>> I don't have any special privileges... when I view the Google group, I
>> don't see a "Members" page at all and no where to invite anyone else. All I
>> can access is a link "My membership settings".
>>
>> --- nadeem
>>
>>
>> On Sun, Dec 19, 2021 at 3:49 PM Robby Findler 
>> wrote:
>>
>>> When I follow the link at the bottom of one of these messages, click on
>>> members, I see an "add members" button and clicking on it gives me a place
>>> to add email addresses. I didn't actually add email addresses to the list
>>> and try to add them, and I might have already had special privileges on
>>> this list so that might not have been the most useful test.
>>>
>>> Robby
>>>
>>>
>>> On Sun, Dec 19, 2021 at 11:32 AM Sage Gerard 
>>> wrote:
>>>
 Alright, thanks to all of you for the quick replies. As of this
 writing, the list has been reconfigured to create an explicit perimeter
 between the non-members and members. The public can no longer let
 themselves in.

 Not totally out of the woods yet.

1. Someone please confirm if you can invite others using Members
page -> "Add Member". If not, then please follow up with me.
2. This model can be compromised by someone going rogue and
inviting a bunch of spammers. I'm expecting that our communal trust is 
 high
enough to make this unlikely.

 Considering the risk profile seems less scary, disregard request to
 delete my emails. :)
 On 12/18/21 3:02 PM, Matthias Felleisen wrote:


 +2! And many thanks. (I was personally spared this spam until very
 recently. No clue why)

 — Matthias




 On Dec 18, 2021, at 2:55 PM, Robby Findler 
 wrote:

 +1! Thank you.

 Robby

 On Sat, Dec 18, 2021 at 1:43 PM Matthew Flatt 
 wrote:

> The "members" option sounds right to me. Thanks for tracking down a way
> to improve the situation!
>
> At Sat, 18 Dec 2021 19:35:23 +, Sage Gerard wrote:
> > Core team,
> >
> > Sam asked me to issue bans for a troublesome spammer. I've done so,
> even
> > just today. I understand I need quorum for larger decisions. This is
> why
> > I have not yet reconfigured the list to permanently stop the spammer.
> > After researching the problem further, I need your urgent attention.
> >
> > I found that the spam messages sometimes link to other Google group
> > posts affected by the spammer. A recent trail leads to a
> > comp.lang.python Google message in 2017. I suspect that email
> addresses
> > are scraped in unmoderated lists that freely hand out membership.
> After
> > checking the list settings, I found that this is one of those lists.
> I
> > hypothesize that our email addresses are being scraped and
> > cross-referenced for use in other unmoderated lists.
> >
> > It's one thing to flatly complain about a spammer on this list, and
> > another to willingly maintain a transmission vector. We need to stop
> > automatically handing out group membership with our current
> settings. We
> > can have  issue list memberships. I need you all to fill in
> the
> > blank with "moderators" or "members." I'll translate the settings
> > accordingly.
> >
> > Given the holidays, I respect your time. Please reciprocate with
> respect
> > for the urgency this problem creates. I will revoke my own mailing
> list
> > privileges and membership in three weeks, on January 8th, 2022. I
> will
> > leave the settings however they read at the time to prevent
> > interruption, 

Re: [racket-users] Let over lambda and location information

2021-11-29 Thread Sorawee Porncharoenwase
If you simply want the source location to be the macro call site, one
approach is finding where the source location currently is (in this case,
it’s the lambda inside make-keyword-procedure). Then, you simply need to
thread syntax/loc through macros to put the source location there.

Here’s an example:

#lang racket

(require racket/match
 syntax/parse/define)

(define-syntax-parse-rule
  (methods*
   [(method-name method-args ...) body ...] ...
   fallback)

  #:with the-proc
  (syntax/loc this-syntax
(lambda (kw-args kw-vals method . args)
  (match (assq method all-methods)
[(cons _name found-method)
 found-method
 #;(keyword-apply found-method kw-args kw-vals args)]
[#f
 (keyword-apply fallback kw-args kw-vals method args)])))

  (let ((method-name
 (lambda (method-args ...)
   body ...)) ...)
(define all-methods (list (cons 'method-name method-name) ...))
(define method-dispatch
  (make-keyword-procedure the-proc))
method-dispatch))

(define no-such-method
  (make-keyword-procedure
   (lambda (kw-vals kw-args method . args)
 (error "No such method" method

(define-syntax-parse-rule (methods method-defns ...)
  #:with out
  (syntax/loc this-syntax
(methods* method-defns ... no-such-method))
  out)

(define my-methods
  (methods
   [(double x)
(* x x)]))

my-methods ;=> #

Also note that there’s procedure-rename

and syntax-local-name

which you might want to use instead:

#lang racket

(require racket/match
 syntax/parse/define)

(define-syntax-parse-rule
  (methods*
   [(method-name method-args ...) body ...] ...
   fallback)

  #:with the-name (syntax-local-name)

  (let ((method-name
 (lambda (method-args ...)
   body ...)) ...)
(define all-methods (list (cons 'method-name method-name) ...))
(define method-dispatch
  (procedure-rename
   (make-keyword-procedure
(lambda (kw-args kw-vals method . args)
  (match (assq method all-methods)
[(cons _name found-method)
 found-method
 #;(keyword-apply found-method kw-args kw-vals args)]
[#f
 (keyword-apply fallback kw-args kw-vals method args)])))
   'the-name))
method-dispatch))

(define no-such-method
  (make-keyword-procedure
   (lambda (kw-vals kw-args method . args)
 (error "No such method" method

(define-syntax-rule (methods method-defns ...)
  (methods* method-defns ... no-such-method))

(define my-methods
  (methods
   [(double x)
(* x x)]))

my-methods ;=> #



On Mon, Nov 29, 2021 at 12:18 PM Christine Lemmer-Webber <
cweb...@dustycloud.org> wrote:

> Take the following code:
>
> #+BEGIN_SRC racket
> (require racket/match)
>
> (define-syntax-rule (methods* [(method-name method-args ...) body ...] ...
>   fallback)
>   (let ((method-name
>  (lambda (method-args ...)
>body ...)) ...)
> (define all-methods (list (cons 'method-name method-name) ...))
> (define method-dispatch
>   (make-keyword-procedure
>(lambda (kw-args kw-vals method . args)
>  (match (assq method all-methods)
>[(cons _name found-method)
> found-method
> #;(keyword-apply found-method kw-args kw-vals args)]
>[#f
> (keyword-apply fallback kw-args kw-vals method args)]
> method-dispatch))
>
> (define no-such-method
>   (make-keyword-procedure
>(lambda (kw-vals kw-args method . args)
>  (error "No such method" method
>
> (define-syntax-rule (methods method-defns ...)
>   (methods* method-defns ... no-such-method))
> #+END_SRC
>
> This is kind of a kluge, I know.  But you get the idea.  Let over
> lambda, because we're going to be reusing these procedures over and over
> again across multiple calls.
>
> Now let's say I instantiate this like:
>
> #+BEGIN_SRC racket
>   (define my-methods
> (methods
>  [(double x)
>   (* x x)]))
> #+END_SRC
>
> > my-methods
> #
>
> That's the line where method-dispatch is defined, *inside the macro*.
> But what I really want is for the annotation on the procedure to be
> *where my-methods is defined* not pointing back inside the macro.
>
> I have no idea how to do this.  Thoughts?
>
> --
> You received this message because you are 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/87sfveu34u.fsf%40dustycloud.org
> .
>

-- 
You received this message because you are subscribed to the 

Re: [racket-users] Racket Discourse

2021-11-21 Thread Sorawee Porncharoenwase
My personal opinion is that, if we want Discourse to be a replacement of
the mailing list, then we should treat it like one. Right now, it’s a
combination of the mailing list, wiki, FAQ site, and whatnot. And I don’t
want one more email in my inbox when someone decides to add an entry to the
FAQ.

As concrete examples, consider:

   -
   https://racket.discourse.group/t/urlang-is-javascript-with-a-sane-syntax/119
   - https://racket.discourse.group/t/gui-builder-designer/151

I’m not sure what’s the point of these posts *in the context of the mailing
list*. Stephen definitely knows MrEd designer and has been promoting it for
years, so this looks like his attempt to build a wiki/FAQ on Discourse.
While I really do appreciate Stephen’s effort into building and maintaining
the valuable wiki/FAQ at https://github.com/racket/racket/wiki, I
personally don’t think a mailing list is an appropriate medium for it.
Urlang is great, but I don’t understand why we are rehashing it now on
Discourse. Will we also see 1735 more posts to rehash every package on the
package website in the future?

Another issue is cross posting. Often posts are shared to all Slack,
Discord, Reddit, the current mailing list, and whatnot (and also in the
other direction). It makes sense to do that for event announcements. I’m
not sure the same can be said for other posts. They are inundating (at
least to me), especially if they happen a lot.

I understand that there's a spam problem on the current mailing list and in
fact have been complaining constantly on Slack. I actually even proposed to
Sam last year to consider Discourse as a replacement of the mailing list,
so I'm not against the software at all if that's what you worry about.

To be clear, no offense to anyone at all. It could be that my expectation
of the mailing list is far off from most people, and if that’s the case,
I’d simply excuse myself from it.
On Sun, Nov 21, 2021 at 3:42 PM Philip McGrath 
wrote:

> I've long been in the basically-content-with-the-mailing-list camp, but
> I've recently come around to the view that the status quo is untenable. I
> looked into it after Racket 'Con and discovered the mailing list had shrunk
> especially much for me, because the Google Groups spam filters were letting
> through so much spam that Google spam filters on one hop of my receiving
> side have been classifying a great deal of legitimate mailing list traffic
> as spam.
>
> I haven't done much with Discourse yet, but it seems promising, and I hope
> it works out.
>
> I'd guess the list administrators have tried this already, but, just in
> case, the Google Group settings should have a "Spam message handling"
> setting that could be set to "Moderate without notifying content
> moderators" (see
> https://support.google.com/groups/answer/2464926?hl=en#posting=%2Csettings-reference%2Cadvanced-settings-reference).
> If this is the official moment for giving up on this mailing list, it would
> probably be good to turn up these settings to some draconian level anyway,
> just to leave one fewer spam target on the internet.
>
> -Philip
>
> On Sun, Nov 21, 2021 at 6:08 PM 'John Clements' via Racket Users <
> racket-users@googlegroups.com> wrote:
>
>> Wait, you think that’s high traffic? Gee whiz, the mailing list *has*
>> shrunk, hasn’t it?
>>
>> Okay, that was not an entirely serious reply, but I do think that in
>> contrast to the discord & slack channels, the discourse is likely to be
>> searchable and at least lightly curated six months from now. Also, if you
>> take a look at the mailing list archive
>>
>> https://www.mail-archive.com/racket-users@googlegroups.com/
>>
>> … you’ll see a *shocking* amount of spam. Many of us don’t see this
>> because we have semi-reasonable spam filters, but others are putting up
>> with what looks like more than 50% spam on this list. That’s just not
>> acceptable.
>>
>> John
>>
>>
>> > On Nov 21, 2021, at 14:14, Sorawee Porncharoenwase <
>> sorawee.pw...@gmail.com> wrote:
>> >
>> > I could be in the minority here, but as an early proponent of Discourse
>> to replace the mailing list (even before RacketCon), I feel reluctant to
>> join it after observing it for a while. It has a very high traffic, with
>> almost 100% of the contents being cross-posted everywhere else (and vice
>> versa) anyway.
>> >
>> > While I appreciate any efforts into promoting the site, I do think
>> different content has different appropriate mediums. For example, FAQs
>> probably should go to the wiki. There's no need to clutter anyone's inbox
>> for this type of content.
>> >
>> > On Sun, Nov 21, 2021 at 10:09 AM 'John Clements' via Racket Users &

Re: [racket-users] Racket Discourse

2021-11-21 Thread Sorawee Porncharoenwase
I could be in the minority here, but as an early proponent of Discourse to
replace the mailing list (even before RacketCon), I feel reluctant to join
it after observing it for a while. It has a very high traffic, with almost
100% of the contents being cross-posted everywhere else (and vice versa)
anyway.

While I appreciate any efforts into promoting the site, I do think
different content has different appropriate mediums. For example, FAQs
probably should go to the wiki. There's no need to clutter anyone's inbox
for this type of content.

On Sun, Nov 21, 2021 at 10:09 AM 'John Clements' via Racket Users <
racket-users@googlegroups.com> wrote:

> TL;DR: Go to
>
>https://racket.discourse.group/invites/okLTSrQw1T
>
> and sign up for Racket Discourse (https://racket.discourse.group/)
>
> # Thoughts behind the move:
>
> Over time, it has become steadily more apparent that email-only
> mailing lists are an outdated communication medium for the Racket
> community. More recent arrivals in our community have generally
> chosen other platforms like slack or discord to carry on discussions.
> As a result, the signal-to-noise ratio of the racket users mailing list
> has dropped below the level of viability.
>
> In short, it’s time to give up on the mailing list.
>
> After a good deal of research, it looks like there’s room for a whole
> bunch of discussion platforms for Racket, but it also seems as though
> there should be a “permanent” one; it should be archived, it should be
> searchable in its entirety, and it should not tie us to someone else’s
> plan to monetize user data.
>
> Given these criteria, the winner is Discourse, an open-source
> messaging platform built by Jeff Atwood, Robin Ward, and Sam
> Saffron. It has a reasonable business model (they host projects like
> ours unless they get really big, whereupon you can either host it
> yourself or pay them to do it); it’s widely used by other language
> communities; and it appears to do most of what we want.
>
> # So where can I sign up?
>
> Sign up here: https://racket.discourse.group/invites/okLTSrQw1T
>
> The discourse platform has been in a “soft opening” phase for about
> two weeks now, since RacketCon, and we have about a hundred users.
> You’re receiving this message because we’d like to have *YOU* there
> as well.
>
> # Can I still receive messages like a mailing list?
>
> Yes, you can. I have it enabled myself!
> To use discord as a mailing-list:
> Sign up, go to Preferences > Email, and tick “Enable mailing list mode'.
>
> Yours,
>
> John Clements & Stephen De Gabrielle
>
> --
> You received this message because you are 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/9d080367-1b70-4818-8e76-8c6714db404c%40mtasv.net
> .
>

-- 
You received this message because you are 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/CADcuegvmrZ%3DeoQPm-kuaow%2BAz9TnDUop2aypSWh6-HrZ3E_hGg%40mail.gmail.com.


Re: [racket-users] confusion about real vs not real zero

2021-11-19 Thread Sorawee Porncharoenwase
Yeah, I was about to reply that I don't think there's a workaround, too.

What is your goal, though? Do you intend to support complex numbers
properly right now? In particular, that problematic code is random
generation from contracts, which is rarely invoked anyway. Intuitively,
there's no reason why the complex number feature is required to get the
code running.

So one potential solution is to not support complex numbers right now, and
compile all complex number literals to a JS expression that throws an
exception at runtime.



On Fri, Nov 19, 2021 at 12:20 PM Sam Tobin-Hochstadt 
wrote:

> On Fri, Nov 19, 2021 at 3:13 PM Stephen Chang 
> wrote:
> >
> > Lol I read that page and still didn't get it.
> >
> > Any opinion for a potential workaround?
>
> It depends what you mean by "workaround". The distinction between
> exact and inexact numbers is pretty deeply built-in to how Racket
> numbers work, so there's not going to be a simple workaround that
> fixes this issue.
>
> For RacketScript I think the choices are (a) use floats for everything
> and have semantics that diverge substantially from Racket or (b) have
> a separate implementation of integers that's not JS numbers (maybe JS
> bigints would work).
>
> Sam
>
> >
> > On Fri, Nov 19, 2021 at 3:08 PM Sorawee Porncharoenwase
> >  wrote:
> > >
> > > I had this exact same question when I looked at the RacketScript issue
> lol.
> > >
> > > The answer is https://docs.racket-lang.org/reference/numbers.html:
> > >
> > > a complex number with an exact zero imaginary part is a real number.
> > >
> > > Since 0.0 is not exact, 0.0i is not a real number.
> > >
> > > On Fri, Nov 19, 2021 at 11:59 AM Stephen Chang 
> wrote:
> > >>
> > >> In the following, why is the first considered a real number but the
> > >> second considered not real
> > >>
> > >> > (real? 0.0+0i)
> > >> #t
> > >> > (real? 0.0+0.0i)
> > >> #f
> > >>
> > >> --
> > >> You received this message because you are 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/CAFfiA1%2BYygGrLH2rtwby8AWg7Edyvq-tzmANTNypq5Rqd-eXFw%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/CAFfiA1%2B3yRzzh%3DKhcOddt0geMezNsxQGHqzwGTYbZjLekUQ8kQ%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/CADcuegsLHOrP9coJGwbd3Mqj4YKovzBvBoSdSk83xtVT5yb9Bg%40mail.gmail.com.


Re: [racket-users] confusion about real vs not real zero

2021-11-19 Thread Sorawee Porncharoenwase
I had this exact same question when I looked at the RacketScript issue lol.

The answer is https://docs.racket-lang.org/reference/numbers.html:

a complex number with an exact zero imaginary part is a real number.

Since 0.0 is not exact, 0.0i is not a real number.

On Fri, Nov 19, 2021 at 11:59 AM Stephen Chang  wrote:

> In the following, why is the first considered a real number but the
> second considered not real
>
> > (real? 0.0+0i)
> #t
> > (real? 0.0+0.0i)
> #f
>
> --
> You received this message because you are 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/CAFfiA1%2BYygGrLH2rtwby8AWg7Edyvq-tzmANTNypq5Rqd-eXFw%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/CADcuegu2iBp3847QRgPcqzH4JoR%3DFpUXPf-n_G7xP1%3DWmfs85w%40mail.gmail.com.


Re: [racket-users] Re: [ANN] fmt: a Racket code formatter

2021-10-19 Thread Sorawee Porncharoenwase
On Tue, Oct 19, 2021 at 7:01 AM Diego Crespo
mycontributiontothewo...@gmail.com
 wrote:

If you are curious about what the output looked like before, here is the
> pasterack link of some of my code http://pasterack.org/pastes/23639.
> Racket supports using brackets instead of parenthesis, but you typically
> only see it used in things like cond and let expressions. This was adding
> them to far more expressions. Other than looking odd, there was nothing
> wrong with the code (other than my own errors :))
>
FWIW, here’s what the tool would output now (provided that the input code’s
paren shapes are not yet compromised): http://pasterack.org/pastes/21352

raco fmt will usually keep paren shape intact, but it can convert paren
shape in some positions. Right now, the only conversion is from parenthesis
to bracket, and it’s enabled for:

   - cond, case-lambda, match, case body
   - syntax-case, syntax-rules body
   - syntax-parse (including syntax-parser and define-syntax-parser) body.
   - for bindings (including for/... and for*/...)
   - let bindings (including letrec, let-syntax, let-values, …)
   - parameterize, with-syntax, shared bindings
   - and a few more

What happened earlier was that class was erroneously configured to have
this paren shape conversion, even though it should not.

On Tuesday, October 19, 2021 at 9:34:04 AM UTC-4 hen...@topoi.pooq.com
> wrote:
>
>> and was disappointed.
>>
> I would not recommend this, but if you strongly feel that the class body
should use brackets, you are free to write your own formatting rules.
(Though I have not documented how to do so.)

-- 
You received this message because you are 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%2BepCLAXHzjXxPdq%3DR6su0heHOJRBYgWL7_tLj5J%3Db2A%40mail.gmail.com.


Re: [racket-users] Re: [ANN] fmt: a Racket code formatter

2021-10-18 Thread Sorawee Porncharoenwase
Don't get used to it. It's a bug!

Fixed in
https://github.com/sorawee/fmt/commit/e056aee1e9a3ea0a72a4c85075426fa76f037852.
Thanks for the report!

On Mon, Oct 18, 2021 at 6:14 PM Diego Crespo <
mycontributiontothewo...@gmail.com> wrote:

> This is really cool. Between this, a Racket linter, and an LSP, Racket is
> seriously looking a lot better for larger teams. I ran it through some of
> my code and I'm curious about the decision to use brackets more liberally.
> I was surprised when it changed my methods in my classes to be bracketed,
> as well as the init, and field expressions. I could probably get used to it
> given enough time, but I haven't seen that style in other Racket code
> before.
>
>
> On Tuesday, September 28, 2021 at 2:03:28 PM UTC-4 sorawe...@gmail.com
> wrote:
>
>> Announcing the pre-alpha version of fmt, a Racket code formatter. Code
>> formatter is a tool that reformats your code so that it conforms to a style
>> consistently.
>>
>>- Source: https://github.com/sorawee/fmt/
>>- Documentation and demo: https://docs.racket-lang.org/fmt/
>>
>> As a part of this work, I implemented Jean-Philippe Bernady’s non greedy
>> pretty printer  (ICFP’17) and
>> extended it so that it is practical for actual use.
>>
>>- Source: https://github.com/sorawee/pprint-compact/
>>- Documentation and demo: https://docs.racket-lang.org/pprint-compact/
>>
>> Hope you find these useful, and let me know if you have any feedback.
>>
>> 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/3fc35f69-9e3f-4bc0-82cf-c31baeebc21an%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/CADcuegv%2B3xL8un9fNr%2BKeT7%3D44s%2BoMuFfH6uemyw2q5JiU9cOg%40mail.gmail.com.


Re: [racket-users] Rationale for package structure

2021-10-09 Thread Sorawee Porncharoenwase
I think it's so that `raco pkg install mypkg-lib` won't install
`racket-doc` if you use Minimal Racket?

If you don't split `mypkg` to `mypkg-lib` and `mypkg-doc`, but specify
`deps` and `build-deps` correctly, `raco pkg install --binary mypkg` won't
pull in `racket-doc` either. I don't know when this feature was added
though. Perhaps, it could be that the package splitting convention predates
the feature, and the convention persists.

On Sat, Oct 9, 2021 at 10:58 AM 'Joel Dueck' via Racket Users <
racket-users@googlegroups.com> wrote:

> I’ve always used the single collection format [1] in my packages.
>
> However, I see a lot of package authors will use a multi-collection format
> and split the library, documentation and maybe tests out into separate
> collections.
>
> What are the benefits of splitting the main library and its documentation
> into separate collections?
>
> [1]:
> https://docs.racket-lang.org/pkg/Package_Concepts.html#%28part._concept~3amulti-collection%29
>
> --
> You received this message because you are 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/6ea9f50e-0d4f-4800-bc17-d31979a614cfn%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/CADcuegs%3D-YZKaTSmPxreNekuUyxcyMG6AOSzxwnkCnr_8jBkgg%40mail.gmail.com.


Re: [racket-users] Having trouble getting documentation to generate

2021-10-08 Thread Sorawee Porncharoenwase
And while we are at the package website issue, can someone please take a
look at my PR to fix the blank package bug (
https://github.com/racket/pkg-index/pull/29)?

On Fri, Oct 8, 2021 at 11:00 AM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> Here’s additional information: I uploaded pprint-compact on September 22.
> https://pkgs.racket-lang.org/ briefly shows the documentation for a few
> days. But after a package update around September 26, the website no longer
> lists the documentation. The doc is still actually available at
> https://docs.racket-lang.org/pprint-compact/.
>
> The root cause seems to be how
> https://pkgs.racket-lang.org/pkgs-all.json.gz doesn’t have the doc data
> in the build/docs field.
>
> On Fri, Oct 8, 2021 at 10:40 AM Siddhartha Kasivajhula 
> wrote:
>
>> Looks like the try-catch package docs still aren't showing up
>> <https://pkgd.racket-lang.org/pkgn/package/try-catch>.
>>
>> This might be a broader issue with the package index and docs, since I
>> just renamed one of my packages that already had docs, and the docs now no
>> longer exist on the package index (it says "this package needs
>> documentation"). I think this is because the package now reflects as a new
>> package and so runs afoul of whatever issue appears to be afflicting new
>> arrivals.
>>
>> I checked the "New Releases" section of the latest issue of Racket News
>> <https://racket-news.com/2021/10/racket-news-issue-54.html#newreleases> to
>> validate whether new packages are especially affected, and of the packages
>> listed there, a majority of them include scribble docs that we can see
>> listed in the package modules, but the docs show up for none of them:
>>
>> https://pkgs.racket-lang.org/package/in-out-logged
>> https://pkgs.racket-lang.org/package/libansilove
>> https://pkgs.racket-lang.org/package/pprint-compact
>> https://pkgs.racket-lang.org/package/codepoint
>> https://pkgs.racket-lang.org/package/fmt
>> https://pkgs.racket-lang.org/package/pareto-frontier
>> https://pkgs.racket-lang.org/package/majordomo2
>>
>>
>>
>>
>> On Wed, Sep 29, 2021 at 9:01 AM David Storrs 
>> wrote:
>>
>>> Cool, thanks.
>>>
>>> On Wed, Sep 29, 2021 at 11:23 AM Matthew Flatt 
>>> wrote:
>>>
>>>> At Wed, 29 Sep 2021 11:20:47 -0400, David Storrs wrote:
>>>> > On Wed, Sep 29, 2021 at 9:57 AM Matthew Flatt 
>>>> wrote:
>>>> >
>>>> > > At Wed, 29 Sep 2021 02:27:53 +, Philip McGrath wrote:
>>>> > > > I haven't tried `raco setup` to look at its output, but one
>>>> possible
>>>> > > > improvement would be for whatever code complains about the
>>>> "invalid
>>>> > > `deps'
>>>> > > > specification" to always report the invalid file's path.
>>>> > >
>>>> > > I've pushed that addition.
>>>> > >
>>>> > >
>>>> > Thanks, Matthew.  Is this a "download Racket 8.2" thing or an "update
>>>> from
>>>> > github" thing?
>>>>
>>>> The improvement is only in the GitHub repo right now. So, updating from
>>>> GitHub gets it now, it will also be part of the next round of
>>>> snapshots, and then it will be part of the upcoming v8.3 release.
>>>>
>>>>
>>>> Matthew
>>>>
>>> --
>>> You received this message because you are 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/CAE8gKoegBUGVbfmguydZwaVBWgrNOJWJ3CmxTvShROR4-dpvJw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/racket-users/CAE8gKoegBUGVbfmguydZwaVBWgrNOJWJ3CmxTvShROR4-dpvJw%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/CACQBWF%3DmjJAxAg6xbwfYTDQk8TnDhJyoTYhroxA1XW70CV67zg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CACQBWF%3DmjJAxAg6xbwfYTDQk8TnDhJyoTYhroxA1XW70CV67zg%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/CADcuegv%2BgRu_rwxd6ZZCaxe_%2BmS_%2B0f%2B__DrpczTUFAOQzFS9A%40mail.gmail.com.


Re: [racket-users] Having trouble getting documentation to generate

2021-10-08 Thread Sorawee Porncharoenwase
Here’s additional information: I uploaded pprint-compact on September 22.
https://pkgs.racket-lang.org/ briefly shows the documentation for a few
days. But after a package update around September 26, the website no longer
lists the documentation. The doc is still actually available at
https://docs.racket-lang.org/pprint-compact/.

The root cause seems to be how https://pkgs.racket-lang.org/pkgs-all.json.gz
doesn’t have the doc data in the build/docs field.

On Fri, Oct 8, 2021 at 10:40 AM Siddhartha Kasivajhula 
wrote:

> Looks like the try-catch package docs still aren't showing up
> .
>
> This might be a broader issue with the package index and docs, since I
> just renamed one of my packages that already had docs, and the docs now no
> longer exist on the package index (it says "this package needs
> documentation"). I think this is because the package now reflects as a new
> package and so runs afoul of whatever issue appears to be afflicting new
> arrivals.
>
> I checked the "New Releases" section of the latest issue of Racket News
>  to
> validate whether new packages are especially affected, and of the packages
> listed there, a majority of them include scribble docs that we can see
> listed in the package modules, but the docs show up for none of them:
>
> https://pkgs.racket-lang.org/package/in-out-logged
> https://pkgs.racket-lang.org/package/libansilove
> https://pkgs.racket-lang.org/package/pprint-compact
> https://pkgs.racket-lang.org/package/codepoint
> https://pkgs.racket-lang.org/package/fmt
> https://pkgs.racket-lang.org/package/pareto-frontier
> https://pkgs.racket-lang.org/package/majordomo2
>
>
>
>
> On Wed, Sep 29, 2021 at 9:01 AM David Storrs 
> wrote:
>
>> Cool, thanks.
>>
>> On Wed, Sep 29, 2021 at 11:23 AM Matthew Flatt 
>> wrote:
>>
>>> At Wed, 29 Sep 2021 11:20:47 -0400, David Storrs wrote:
>>> > On Wed, Sep 29, 2021 at 9:57 AM Matthew Flatt 
>>> wrote:
>>> >
>>> > > At Wed, 29 Sep 2021 02:27:53 +, Philip McGrath wrote:
>>> > > > I haven't tried `raco setup` to look at its output, but one
>>> possible
>>> > > > improvement would be for whatever code complains about the "invalid
>>> > > `deps'
>>> > > > specification" to always report the invalid file's path.
>>> > >
>>> > > I've pushed that addition.
>>> > >
>>> > >
>>> > Thanks, Matthew.  Is this a "download Racket 8.2" thing or an "update
>>> from
>>> > github" thing?
>>>
>>> The improvement is only in the GitHub repo right now. So, updating from
>>> GitHub gets it now, it will also be part of the next round of
>>> snapshots, and then it will be part of the upcoming v8.3 release.
>>>
>>>
>>> Matthew
>>>
>> --
>> You received this message because you are 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/CAE8gKoegBUGVbfmguydZwaVBWgrNOJWJ3CmxTvShROR4-dpvJw%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/CACQBWF%3DmjJAxAg6xbwfYTDQk8TnDhJyoTYhroxA1XW70CV67zg%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/CADcueguOtU9segBz_C%2BWmAkMadSZajS%3Dv69iPbx5gJPEHGKPSg%40mail.gmail.com.


Re: [racket-users] Restarting loop from exception handler breaks with-handlers, Ctrl+C?

2021-10-07 Thread Sorawee Porncharoenwase
Typo: with-handlers*

On Thu, Oct 7, 2021 at 5:52 PM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> I think you want with-handler*? According to the docs:
>
> with-handlers:
>
> Before any predicate or handler procedure is invoked, the continuation of
> the entire with-handlers
> <https://docs.racket-lang.org/reference/exns.html#%28form._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._with-handlers%29%29>
> expression is restored, but also parameterize-break
> <https://docs.racket-lang.org/reference/breakhandler.html#%28form._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._parameterize-break%29%29>ed
> to disable breaks. Thus, breaks are disabled by default during the
> predicate and handler procedures (see Breaks
> <https://docs.racket-lang.org/reference/breakhandler.html>), and the
> exception handler is the one from the continuation of the with-handlers
> <https://docs.racket-lang.org/reference/exns.html#%28form._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._with-handlers%29%29>
> expression.
>
> with-handler*
>
> Like with-handlers
> <https://docs.racket-lang.org/reference/exns.html#%28form._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._with-handlers%29%29>,
> but if a handler-expr procedure is called, breaks are not explicitly
> disabled, and the handler call is in tail position with respect to the
> with-handlers*
> <https://docs.racket-lang.org/reference/exns.html#%28form._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._with-handlers%2A%29%29>
> form.
>
> On Thu, Oct 7, 2021 at 5:36 PM 'William J. Bowman' via Racket Users <
> racket-users@googlegroups.com> wrote:
>
>> I have a little model of a server below. The server handles all
>> exceptions, and restarts itself after some errors. It also handles break?,
>> to actually exit when requested.
>>
>> While this server is running, if I press Ctrl+C before `(error 'foo)` is
>> handled, the server exits correctly with 120. However, if I press Ctrl+C
>> after `(error 'foo)` is handled, the `exn:break?` handler is never called,
>> the server no longer responds to `Ctrl+C`, and (in this example) it
>> eventually exits with status `1`.
>>
>> I cannot figure out why. As far as I can tell, this should always handle
>> `Ctrl+C` by exiting with 120.
>>
>> > #lang racket/base
>> >
>> > (let loop ([n 0])
>> >   (with-handlers ([exn:break? (lambda _ (exit 120))]
>> >   [void
>> >(lambda (exn)
>> >  (printf "handled error: ~a~n" (exn-message exn))
>> >  (loop (add1 n)))])
>> > (displayln n)
>> > (sleep 1)
>> > (cond
>> >   [(zero? n) (error 'foo)]
>> >   [(= n 5) (exit 1)])
>> > (loop (add1 n
>>
>> --
>> William J. Bowman
>>
>> --
>> You received this message because you are 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/YV%2BSWNpldfOB5tA3%40williamjbowman.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/CADcuegv2uWs_2KnFw%2ByD2OzmOVBi5tkktyh8Aour1E5xTh-RKw%40mail.gmail.com.


Re: [racket-users] Restarting loop from exception handler breaks with-handlers, Ctrl+C?

2021-10-07 Thread Sorawee Porncharoenwase
I think you want with-handler*? According to the docs:

with-handlers:

Before any predicate or handler procedure is invoked, the continuation of
the entire with-handlers

expression is restored, but also parameterize-break
ed
to disable breaks. Thus, breaks are disabled by default during the
predicate and handler procedures (see Breaks
), and the
exception handler is the one from the continuation of the with-handlers

expression.

with-handler*

Like with-handlers
,
but if a handler-expr procedure is called, breaks are not explicitly
disabled, and the handler call is in tail position with respect to the
with-handlers*

form.

On Thu, Oct 7, 2021 at 5:36 PM 'William J. Bowman' via Racket Users <
racket-users@googlegroups.com> wrote:

> I have a little model of a server below. The server handles all
> exceptions, and restarts itself after some errors. It also handles break?,
> to actually exit when requested.
>
> While this server is running, if I press Ctrl+C before `(error 'foo)` is
> handled, the server exits correctly with 120. However, if I press Ctrl+C
> after `(error 'foo)` is handled, the `exn:break?` handler is never called,
> the server no longer responds to `Ctrl+C`, and (in this example) it
> eventually exits with status `1`.
>
> I cannot figure out why. As far as I can tell, this should always handle
> `Ctrl+C` by exiting with 120.
>
> > #lang racket/base
> >
> > (let loop ([n 0])
> >   (with-handlers ([exn:break? (lambda _ (exit 120))]
> >   [void
> >(lambda (exn)
> >  (printf "handled error: ~a~n" (exn-message exn))
> >  (loop (add1 n)))])
> > (displayln n)
> > (sleep 1)
> > (cond
> >   [(zero? n) (error 'foo)]
> >   [(= n 5) (exit 1)])
> > (loop (add1 n
>
> --
> William J. Bowman
>
> --
> You received this message because you are 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/YV%2BSWNpldfOB5tA3%40williamjbowman.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/CADcuegvKwRkOuC_3nQ4UqWFVK2kac1nCgucYuFz%2BD%2BRJnD0kNg%40mail.gmail.com.


Re: [racket-users] Looking to trigger the end of a loop by the creation of a file.

2021-10-02 Thread Sorawee Porncharoenwase
What do you mean by "Tried using Racket function: filesystem-change-evt but
that did not seem appropriate."? What's inappropriate about it?

My first thought is to initialize a variable with `#f`. Spawn a thread
before the loop that uses `filesystem-change-evt` so that when the event
that you are interested in occurs, mutate the variable to `#t`. In the
loop, break from the loop when the variable is `#t`.

I guess you can also poll `file-exists?` yourself in the thread, with some
`sleep` between each polling.

Related library: https://github.com/zyrolasting/file-watchers/

On Sat, Oct 2, 2021 at 4:25 PM Don Green  wrote:

> Looking to trigger the end of a loop by the creation of a file.
> Is this possible? Is this advisable?
> Currently using:
> a 'for' loop with
> a 'for' loop guard expression to test for the existence of a file.
> Tried file-exists? but that does not seem appropriate.
> Tried using Racket function: filesystem-change-evt but that did not seem
> appropriate.
> Is it possible to trigger an end condition on a 'for' loop by the creation
> of a file?
> I suspect my problem is that it takes a significant amount of time for the
> operating system to register the creation of a file.
> So maybe the best that can be done is to use file-exists? as it works but
> there a many loops of the 'for' loop before the end condition takes effect.
> Any comments?
>
> --
> You received this message because you are 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/adaf4e50-7430-4d2e-923a-5a0cdff24ebfn%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/CADcueguT2p_qdN8fAAnxnsYK_E9k5dFcHGD9n9RLNREk-PD7qw%40mail.gmail.com.


[racket-users] [ANN] fmt: a Racket code formatter

2021-09-28 Thread Sorawee Porncharoenwase
Announcing the pre-alpha version of fmt, a Racket code formatter. Code
formatter is a tool that reformats your code so that it conforms to a style
consistently.

   - Source: https://github.com/sorawee/fmt/
   - Documentation and demo: https://docs.racket-lang.org/fmt/

As a part of this work, I implemented Jean-Philippe Bernady’s non greedy
pretty printer  (ICFP’17) and
extended it so that it is practical for actual use.

   - Source: https://github.com/sorawee/pprint-compact/
   - Documentation and demo: https://docs.racket-lang.org/pprint-compact/

Hope you find these useful, and let me know if you have any feedback.

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/CADcueguOiOBK4vE3kCfvWYkb2Eaz-JfM5_Yd%3DGct-6umSUEG6w%40mail.gmail.com.


Re: [racket-users] Having trouble getting documentation to generate

2021-09-28 Thread Sorawee Porncharoenwase
>
> When I manually run
>
> $ cd try-catch/scribblings/ && scribble try-catch.scbl
>
> I get the try-catch.html file as expected but racket/base functions such
> as with-handlers are not properly linked -- i.e. they appear in blue with a
> red line under them and are not links.
>

   - As I understand, if you run scribble manually, you need to provide
   additional flags to make links work. I never remember what these flags are
   (perhaps +m?). But if you run Scribble via DrRacket, it should include
   these flags for you automatically.
   - But you can also just view the already rendered docs via raco docs
   try-catch. No need to use scribble again — it’s already run as a
part of raco
   setup. You can re-render it via raco setup. I like this way far better
   since the scribble command generates so many files in the source
   directory that I would need to add to .gitignore (I know --dest exists,
   but I usually forgot to provide it),  but raco setup generates the
   rendered doc either elsewhere or in doc directory, which can be added in
   .gitignore easily (actually it's already in gitignore if you use raco
   pkg new command).

-- 
You received this message because you are 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/CADcueguB8du0ez9f3USQYo-BRDP-xpFL-SKzdJa6fVx3CZO33A%40mail.gmail.com.


Re: [racket-users] What is the correct name for non-list parenthesized forms?

2021-09-24 Thread Sorawee Porncharoenwase
It's usually called "binding pair". See also
https://docs.racket-lang.org/syntax/stxparse-intro.html which defines a
syntax class describing the said structure.

On Fri, Sep 24, 2021 at 10:25 AM David Storrs 
wrote:

> Racket has a number of forms that include what look like lists of lists
> but are not.  For example:  (let ((foo 7) (bar 8)) ...)
>
> What would the '(foo 7)' and '(bar 8)' elements be called?  Groups, maybe?
>
> --
> You received this message because you are 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/CAE8gKodX800fK45c_dyVFCNB-AKmYmK26DxC42ZRDVHdzJ2Q7g%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/CADcuegt0egonqm7iXsXGUBZ-Z9SbetTMMp7FaPn0Qii6fZuy%2BQ%40mail.gmail.com.


Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-17 Thread Sorawee Porncharoenwase
>
> 2) (card (line . xs)) has only one field, xs. Of course, you could also
> define it as a normal field which contains a list, but there's some other
> scenarios where I found it more elegant to represent it as a dotted
> argument (like representing s-expressions as a struct).
>
Oh sorry, that was a typo. I meant currently you expect

> (card (line . xs))
> (line 1 2 3 4 5 6 7 8 9)
(line 1 2 3 4 5 6 7 8 9)

to be the output, but I was asking if:

> (card (line . xs))
> (line 1 2 3 4 5 6 7 8 9)
(line '(1 2 3 4 5 6 7 8 9))

makes more sense. In any case, your response clears things up that there is
indeed only one field. You simply want it to be printed like that.

This is actually a pretty fun problem. Here’s a quick prototype. Dropping
it here in case anyone is interested:

#lang racket

(require syntax/parse/define
 (for-syntax syntax/parse/lib/function-header
 racket/syntax
 racket/list
 racket/struct-info))

(begin-for-syntax
  (struct my-struct-info (fields args ctor)
#:property prop:procedure
(λ (inst stx)
  (syntax-parse stx
[(_ args ...) #`(#,(my-struct-info-ctor inst) args ...)]
[x:id #'#,(my-struct-info-ctor inst)]

(define-syntax-parse-rule (define-accessors+predicate
{~var struct-id (static values #f)}
name:id)
  #:with (fields ...) (struct-field-info-list (attribute struct-id.value))
  #:do [(define the-struct-info (extract-struct-info (attribute
struct-id.value)))]
  #:with predicate (list-ref the-struct-info 2)
  #:with (accessors ...) (list-ref the-struct-info 3)
  #:with new-predicate (format-id #'name "~a?" #'name)
  #:with (new-accessors ...)
  (map (λ (id) (format-id #'name "~a-~a" #'name id)) (attribute fields))

  (begin
(define new-predicate predicate)
(define new-accessors accessors) ...))

(define-syntax-parse-rule
  (card
   {~optional (~var super-id (static my-struct-info? "card type"))}
   {~and header:function-header (_:id . args)})

  #:with ((all-fields ...) all-args)
  (let ([info (attribute super-id.value)])
(cond
  [info
   (unless (list? (syntax-e (my-struct-info-args info)))
 (raise-syntax-error 'card
 "supertype can't have variadic fields"
 this-syntax))
   #`(({~@ . #,(my-struct-info-fields info)} . header.params)
  ({~@ . #,(my-struct-info-args info)} . args))]
  [else #'(header.params args)]))

  #:fail-when (check-duplicates (attribute all-fields) #:key syntax-e)
  "duplicate field name"

  (begin
(struct shadow (all-fields ...)
  #:transparent
  ;; TODO: implement gen:custom-write (probably with
make-constructor-style-printer)
  ;; to customize struct value printing
  #:reflection-name 'header.name)
(define-accessors+predicate shadow header.name)
(define (shadow-ctor . all-args)
  (shadow all-fields ...))
(define-syntax header.name
  (my-struct-info #'(all-fields ...)
  #'all-args
  #'shadow-ctor

(let ()
  (card (hola a b #:c c))
  (println (hola 1 2 #:c 3))

  (card (ciao a [b 3]))
  (println (ciao 7))
  (println (ciao 7 4))

  (card (line . xs))
  (println (line 1 2 3 4 5 6 7 8 9)))

(let ()
  (card (hola a #:b b))
  (card hola (ciao c))
  (define v (ciao 1 #:b 2 3))
  (println v)
  (println (list (ciao-a v) (ciao-b v) (ciao-c v)))
  (println (list (ciao? v) (hola? v

(let ()
  (card (foo . xs))
  ;; uncomment should result in a syntax error
  (card #;foo (bar . ys))

  (card (a xs))
  ;; uncomment should result in a syntax error
  (card #;a (b xs))

  (void))

What I did not implement is making the struct value printed in the way you
want, but that can be adjusted by using gen:custom-write. Note that I
didn’t (re)use struct‘s supertype feature since you want fields in the
opposite order.

-- 
You received this message because you are 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/CADcuegvDpWqFACR1CQ9Z48GQdvpgkpk2pJTVBzj-t3zojr9nkg%40mail.gmail.com.


Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-17 Thread Sorawee Porncharoenwase
Instead of creating hola-fields which exists at run-time, you can
(define-syntax
hola ...) to a struct containing the field information at compile-time (it
probably needs to contain other information too). The struct could have
prop:procedure which in this case will be the syntax transformer that
generates struct creation. Looking up the field compile-time information
then can be done by using syntax-local-value or static syntax class. See
section 2.1 in https://www.cs.utah.edu/plt/publications/jfp12-draft-fcdf.pdf
for explanations.

What’s unclear to me are:

1) How would you deal with the following? Should it be an error?

(card (foo . xs))
(card foo (bar . ys))

2) How would you determine the number of fields (and field names) in the
following?

> (card (line . xs))
> (line 1 2 3 4 5 6 7 8 9)

Wouldn’t it make more sense to have:

> (card (line . xs))
> (line '(1 2 3 4 5 6 7 8 9))

where xs is the only field.

3) Shouldn’t the following result in (ciao 7 3)?

> (card (ciao a [b 3]))
> (ciao 7)



On Thu, Sep 16, 2021 at 2:12 PM Dimaugh Silvestris <
dimaughsilvest...@gmail.com> wrote:

> Sorry, I haven't posted the full macro because it's long and makes use of
> several other functions, but I'll try to summarize what it does:
>
> Short summary: I'm trying to have a macro (mymacro oldname newname (fields
> ...)) that accesses oldname-foo, which contains a list of symbols, and then
> define a function that takes (cons oldname-foo (fields ...)) formated as
> identifiers as arguments. Or at least to get the length of oldname-foo and
> name them whatever.
>
> Full explanation: using make-struct-type I'm building a different struct
> system I call cards, where structs can be defined as a function call, which
> will be their constructor, and they are printed as the constructor function
> call that would generate them. So, for instance, we can do:
> > (card (hola a b #:c c))
> > (hola 1 2 #:c 3)
> (hola 1 2 #:c 3)
> or
> > (card (ciao a [b 3]))
> > (ciao 7)
> (ciao 7)
> > (ciao 7 4)
> (ciao 7 4)
>
> or even
>
> > (card (line . xs))
> > (line 1 2 3 4 5 6 7 8 9)
> (line 1 2 3 4 5 6 7 8 9)
>
> Also the names of the fields are stored in *-fields
> (this is the abc-foo of the above example), so *hola-fields contains '(a b
> #:c c).
> So far this is working perfectly, but I don't have inheritance. So when I
> create a card that inherits from a previous card, I need to access its
> *-fields to define a new function containing both the parent
> and the son fields. That is, I'm trying to get this behavior:
> > (card (hola a #:b b))
> > (card hola (ciao c))  ;;; should expand to (define (ciao a #:b b c)
> ...), among other things
> > (ciao 1 #:b 2 3)
> (ciao 1 #:b 2 3)
>
> On Thu, 16 Sept 2021 at 22:35, Sorawee Porncharoenwase <
> sorawee.pw...@gmail.com> wrote:
>
>> In general, it would be helpful to provide an example of the macro use,
>> so that we know what you want to do. If it doesn't work, it would be
>> helpful to provide the buggy program and an error message so that we can
>> help with the issue that you are encountering.
>>
>> From my guess, you have a variable named abc-foo somewhere, and with
>> this macro, you wish to define a function named abc that can access the
>> value of abc-foo? If so, here’s an example of a working program:
>>
>> #lang racket
>>
>> (require (for-syntax racket/syntax))
>>
>> (define-syntax (my-macro stx)
>>   (syntax-case stx ()
>> [(_ name other-args ...)
>>  (with-syntax ([varname (format-id #'name "~a-foo" #'name)])
>>#'(define name
>>(λ (other-args ...)
>>  (println (list varname other-args ...)]))
>>
>> (define abc-foo 123)
>> (my-macro abc x y)
>> (abc 5 6) ;=> '(123 5 6)
>>
>>
>>
>>
>>
>> On Thu, Sep 16, 2021 at 1:21 PM Dimaugh Silvestris <
>> dimaughsilvest...@gmail.com> wrote:
>>
>>> (sorry if I'm asking too many questions about macros lately, I'm
>>> learning about them but I keep running into scenarios I can't find
>>> documentation for)
>>>
>>> I'm trying to capture the value of a variable whose identifier I can
>>> only get with format-id, inside a with-syntax.
>>> Something like this pseudocode (imagine name-foo contains a list of
>>> symbols):
>>> (define-syntax (my-macro stx)
>>>   (syntax-case stx ()
>>> ((_ name other-args ...)
>>>  (with-syntax* ((varname (format-id #'name "~a-foo" #'name))
>>> (varval (cons (datum->syntax #'varname)
>>> (datum->

Re: [racket-users] Is it possible to capture a the value of a variable inside a macro?

2021-09-16 Thread Sorawee Porncharoenwase
In general, it would be helpful to provide an example of the macro use, so
that we know what you want to do. If it doesn't work, it would be helpful
to provide the buggy program and an error message so that we can help with
the issue that you are encountering.

>From my guess, you have a variable named abc-foo somewhere, and with this
macro, you wish to define a function named abc that can access the value of
abc-foo? If so, here’s an example of a working program:

#lang racket

(require (for-syntax racket/syntax))

(define-syntax (my-macro stx)
  (syntax-case stx ()
[(_ name other-args ...)
 (with-syntax ([varname (format-id #'name "~a-foo" #'name)])
   #'(define name
   (λ (other-args ...)
 (println (list varname other-args ...)]))

(define abc-foo 123)
(my-macro abc x y)
(abc 5 6) ;=> '(123 5 6)





On Thu, Sep 16, 2021 at 1:21 PM Dimaugh Silvestris <
dimaughsilvest...@gmail.com> wrote:

> (sorry if I'm asking too many questions about macros lately, I'm learning
> about them but I keep running into scenarios I can't find documentation for)
>
> I'm trying to capture the value of a variable whose identifier I can only
> get with format-id, inside a with-syntax.
> Something like this pseudocode (imagine name-foo contains a list of
> symbols):
> (define-syntax (my-macro stx)
>   (syntax-case stx ()
> ((_ name other-args ...)
>  (with-syntax* ((varname (format-id #'name "~a-foo" #'name))
> (varval (cons (datum->syntax #'varname) (datum->syntax
> #'(other-args ...)
>#'(define name (λ varval (print varval)))
>
>
> Which of course doesn't work. I understand this might have to do with how
> macros work at an earlier phase than runtime, so is it impossible?
>
> --
> You received this message because you are 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/CAN4YmRF%3Do3NsXOvK2fvUDeYL_jfA9r946%3D%3DguoGb_%3DKyS%3Dm%2Bxw%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/CADcueguMfdx5zjRw4iP%3D3_7PhzjpzSMbS02pzVqTPwGMfP7jjQ%40mail.gmail.com.


Re: [racket-users] New module log-bracketed; should probably be something else

2021-09-02 Thread Sorawee Porncharoenwase
Thoughts:

   - Perhaps the logger should be optional. The default value would be
   (current-logger).
   - The event name (like on-complete) could also be optional. The default
   would be the source location of the macro invocation site
   - Instead of “time: ~a”, I think it would be nice to support many
   “pairs”, which are formatted like raise-arguments-error.

Example:

(define (on-complete x)
  (log-test-debug "I'm in on-complete")
  x)

(with-log ()
  1)

(with-log (#:logger test-debug
   #:msg "on-complete"
   ["time" (current-seconds)])
  (on-complete (person 'bob)))

would output:

test: entering test.rkt:5:1
test: exiting test.rkt:5:1
result: 1
1
test: entering on-complete
time: 123
test: I'm in on-complete
test: exiting on-complete
time: 124
result: (person 'bob)
(person 'bob)



On Thu, Sep 2, 2021 at 2:06 PM Martin DeMello 
wrote:

> I do like the second form better, especially since the actual code being
> run is not obscured by simply being the last argument to a long log
> function.
>
> martin
>
> On Thu, Sep 2, 2021 at 1:55 PM David Storrs 
> wrote:
>
>> I often find that for debugging I want to see a log message saying "I'm
>> about to do X" followed by X followed by "I'm done with X" and I want it to
>> return the result of X.
>>
>> I wrote this macro and posted it to the package server:
>> https://pkgs.racket-lang.org/package/log-bracketed
>>
>> In retrospect, the syntax is bad and I should change it.  Can anyone
>> suggest something better?
>>
>>   (define (on-complete x) (log-test-debug "entering on-complete") x)
>>   (struct person (name) #:transparent)
>>
>>   (log-bracketed test-debug "on-complete" "time: ~a" (current-seconds) 
>> (on-complete (person 'bob)))
>>   (log-bracketed test-debug "on-complete" "" "no user-specified logging 
>> information")
>>
>> Spits out:
>>
>>
>> test: about to on-complete. time: 1630611613
>> test: entering on-complete
>> test: after on-complete. time: 1630611613. result: (person 'bob)
>> (person 'bob)
>> test: about to on-complete
>> test: after on-complete. result: "no user-specified logging information"
>> "no user-specified logging information"
>>
>>
>> The problem is that this looks like it's a simple logging message when in
>> fact it's real code that should not be ignored.  I'm trying to think of a
>> better way to do it...maybe something like this?:
>>
>>   (with-bracketing-logs ([test-debug "on-complete" "time: ~a" 
>> (current-seconds)])
>>
>>  (on-complete (person 'bob))
>>
>>
>>
>> --
>> You received this message because you are 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/CAE8gKocZha-NpiFAAKT1c8QTG3MDFRnvxCD4T0P269EncZW3KQ%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/CAFrFfuEqt1NVjE2Ft1JVArvWnKUBvK7jPVoLqPhYCd-dB00A3Q%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/CADcuegtr0B5dwrCcQzRGeASOpGXs93-ZErSFK-C1pVXjObg%2Bgg%40mail.gmail.com.


Re: [racket-users] gen:custom-write macro

2021-09-01 Thread Sorawee Porncharoenwase
There are positions that macros can’t operate.
https://lexi-lambda.github.io/blog/2018/10/06/macroexpand-anywhere-with-local-apply-transformer/
explains this issue really well, so I recommend you to read it.

There’s also another issue, which is that you want write-proc to be named
write-proc, but Racket, which has a hygienic macro system, will “rename” it
automatically for you. So you need to explicitly indicate that you want the
name write-proc. Like this:

#lang racket

(require racket/struct)

(define-syntax (print-as stx)
  (syntax-case stx ()
[(_ lam1 lam2)
 #`(define #,(datum->syntax stx 'write-proc)
 (make-constructor-style-printer
  lam1 lam2))]))

(struct point (x y)
  #:methods gen:custom-write
  [(print-as
   (lambda (obj) 'p)
   (lambda (obj)
 (list [point-x obj] [point-y obj])))])

(point 1 2)

On Wed, Sep 1, 2021 at 10:26 AM Dimaugh Silvestris
dimaughsilvest...@gmail.com 
wrote:

Tired of writing:
>
> #:methods gen:custom-write
>   [(define write-proc
>  (make-constructor-style-printer
>   (lambda (x) blablabla)
>   (lambda (x) blablabla)))]
>
> I made this macro:
>
> (define-syntax (print-as stx)
>   (syntax-case stx []
> {[_ lam1 lam2]
>  #'[(define write-proc
>   (make-constructor-style-printer
>lam1 lam2))]}))
>
> So I could just:
>
> (struct point (x y)
>   #:methods gen:custom-write
>   [print-as
>(lambda (obj) 'p)
>(lambda (obj)
>  (list [point-x obj] [point-y obj]))])
>
> But I get a bad syntax error. I've tried many subtle changes to no avail.
> What am I doing wrong?
>
> --
> You received this message because you are 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/CAN4YmRH0jUXyG3YMKojrP2WSAKunrCjtN%3DyTFN2dPjmvvQDVdg%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/CADcuegshmaQGZbAUNOpmVZd0B0Wrt5Adu4BuJm1dpfnxqPFz4A%40mail.gmail.com.


Re: [racket-users] Context aware macro

2021-08-30 Thread Sorawee Porncharoenwase
>
> But what surprises me the most is that it only works at the top level:
> assign.rkt>
> assign.rkt> (assign foo 3)
> assign.rkt> (assign (bar x) (assign foo 7) (* x foo))
> assign.rkt> (bar 1)
> 7
> assign.rkt> global
> '#hash((bar . (λ (x) (assign foo 7) (* x foo))) (foo . 3))
>
Interesting. Following your steps, I got a different result that makes more
sense:

'#hash((bar . (λ (x) (assign foo 7) (* x foo))) (foo . 7))

Another question: my macro doesn't work with (f . xs) notation. Of course,
> I could add a [_ f . xs] syntax-case. But I would also have to add a [_ f a
> ... . xs]. Plus keywords. Is there a way not to have to describe every
> possible situation?
>
For a “flat” function definition, (_ f a ... . xs) is the most general
form. It encompasses patterns like (_ f . xs), where a matches 0 times, and (_
f 1 2), where xs is (). So if you have that, you don’t need any other cases.

FYI: function definition allows the curry form too. E.g.,

(define ((f x) y)
  (+ x y))

The most convenient way to parse the header is to switch from syntax-case
to syntax-parse, and use the function-header syntax class in
syntax/parse/lib/function-header. Lambda doesn’t support currying notation
though, so maybe you don’t care about it.

-- 
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAN4YmREN1q%2BDTF1UbTHc8LmN3gfnea5HAZCQfc%3DRPyLVHX2yVg%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/CADcueguaarpbWdz3PEPjySY85ab9UNc%3Dx3h%2B4h3V6JLXEBOSMg%40mail.gmail.com.


Re: [racket-users] Can raco install old packages with a specific version?

2021-08-18 Thread Sorawee Porncharoenwase
s/could/should/

On Wed, Aug 18, 2021 at 3:07 PM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> Oh, and to install from source, go in the project directory, which could
> contain the file info.rkt. Run raco pkg install.
>
>
> On Wed, Aug 18, 2021 at 3:05 PM Sorawee Porncharoenwase <
> sorawee.pw...@gmail.com> wrote:
>
>> Hi Kiwan,
>>
>> There are many possibilities that you can do.
>>
>> One is to download the source code of a version that you want from
>> https://github.com/emina/rosette/releases and then install from source.
>>
>> Another is to find a commit that you want from GitHub and use the command
>> line like raco pkg install
>> https://github.com/emina/rosette.git#bb08ef1a1bdc7232bbc857985aedba116fcecf47
>> .
>> This bb08ef1a1 commit is the latest commit in Rosette 3, so you can
>> simply use it if you prefer to.
>> It might be a bit difficult to find a commit on your own though since the
>> history in the repo is kinda messed up.
>>
>> Hope this helps,
>> Sorawee
>>
>>
>>
>>
>> On Wed, Aug 18, 2021 at 2:52 PM Kiwan  wrote:
>>
>>> Hi, all.
>>> I am new to this community and new to Racket.
>>> So apology in advance if my question is inappropriate and please guide
>>> me to the right channel in that case.
>>>
>>> I am trying to run a codebase someone else wrote. It is based on Racket
>>> 7.5 w/ Rosette 3.x.
>>> When I try running it with Racket 8.2 w/ Rosette 4.0, the code does not
>>> run properly due to major syntatic changes between the versions (especially
>>> from Rosette).
>>>
>>> I am planning to port the codebase to the latest Racket/Rosette, but
>>> since I don't have a running version, I first want to make the code run as
>>> it is for reference purposes.
>>> I know that I can install Racket 7.5 by specifying its version. However,
>>> I am having a hard time figuring out how I can install the old Rosette 3.x
>>> with raco package manager.
>>>
>>> Is it possible to install old packages with raco (e.g., similar to how I
>>> would do apt-get install $pkg==$version)? Or should I compile the old
>>> Rosette from source?
>>>
>>> I would highly appreciate any help.
>>> Thank you,
>>> Best regards
>>> Kiwan
>>>
>>> --
>>> You received this message because you are 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/a02da3b4-9965-4588-ae9e-e78010a2c283n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/racket-users/a02da3b4-9965-4588-ae9e-e78010a2c283n%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/CADcuegvMkZbSDK5UppS-JzjBAP2U%3DzebVnm0No2tFyRV%2Bb64_Q%40mail.gmail.com.


Re: [racket-users] Can raco install old packages with a specific version?

2021-08-18 Thread Sorawee Porncharoenwase
Oh, and to install from source, go in the project directory, which could
contain the file info.rkt. Run raco pkg install.


On Wed, Aug 18, 2021 at 3:05 PM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> Hi Kiwan,
>
> There are many possibilities that you can do.
>
> One is to download the source code of a version that you want from
> https://github.com/emina/rosette/releases and then install from source.
>
> Another is to find a commit that you want from GitHub and use the command
> line like raco pkg install
> https://github.com/emina/rosette.git#bb08ef1a1bdc7232bbc857985aedba116fcecf47
> .
> This bb08ef1a1 commit is the latest commit in Rosette 3, so you can
> simply use it if you prefer to.
> It might be a bit difficult to find a commit on your own though since the
> history in the repo is kinda messed up.
>
> Hope this helps,
> Sorawee
>
>
>
>
> On Wed, Aug 18, 2021 at 2:52 PM Kiwan  wrote:
>
>> Hi, all.
>> I am new to this community and new to Racket.
>> So apology in advance if my question is inappropriate and please guide me
>> to the right channel in that case.
>>
>> I am trying to run a codebase someone else wrote. It is based on Racket
>> 7.5 w/ Rosette 3.x.
>> When I try running it with Racket 8.2 w/ Rosette 4.0, the code does not
>> run properly due to major syntatic changes between the versions (especially
>> from Rosette).
>>
>> I am planning to port the codebase to the latest Racket/Rosette, but
>> since I don't have a running version, I first want to make the code run as
>> it is for reference purposes.
>> I know that I can install Racket 7.5 by specifying its version. However,
>> I am having a hard time figuring out how I can install the old Rosette 3.x
>> with raco package manager.
>>
>> Is it possible to install old packages with raco (e.g., similar to how I
>> would do apt-get install $pkg==$version)? Or should I compile the old
>> Rosette from source?
>>
>> I would highly appreciate any help.
>> Thank you,
>> Best regards
>> Kiwan
>>
>> --
>> You received this message because you are 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/a02da3b4-9965-4588-ae9e-e78010a2c283n%40googlegroups.com
>> <https://groups.google.com/d/msgid/racket-users/a02da3b4-9965-4588-ae9e-e78010a2c283n%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/CADcuegun78mkN4TFx84sTE7TXbt8rsbgeMtGWbtYFvJvg4UaPQ%40mail.gmail.com.


Re: [racket-users] Can raco install old packages with a specific version?

2021-08-18 Thread Sorawee Porncharoenwase
Hi Kiwan,

There are many possibilities that you can do.

One is to download the source code of a version that you want from
https://github.com/emina/rosette/releases and then install from source.

Another is to find a commit that you want from GitHub and use the command
line like raco pkg install
https://github.com/emina/rosette.git#bb08ef1a1bdc7232bbc857985aedba116fcecf47
.
This bb08ef1a1 commit is the latest commit in Rosette 3, so you can simply
use it if you prefer to.
It might be a bit difficult to find a commit on your own though since the
history in the repo is kinda messed up.

Hope this helps,
Sorawee




On Wed, Aug 18, 2021 at 2:52 PM Kiwan  wrote:

> Hi, all.
> I am new to this community and new to Racket.
> So apology in advance if my question is inappropriate and please guide me
> to the right channel in that case.
>
> I am trying to run a codebase someone else wrote. It is based on Racket
> 7.5 w/ Rosette 3.x.
> When I try running it with Racket 8.2 w/ Rosette 4.0, the code does not
> run properly due to major syntatic changes between the versions (especially
> from Rosette).
>
> I am planning to port the codebase to the latest Racket/Rosette, but since
> I don't have a running version, I first want to make the code run as it is
> for reference purposes.
> I know that I can install Racket 7.5 by specifying its version. However, I
> am having a hard time figuring out how I can install the old Rosette 3.x
> with raco package manager.
>
> Is it possible to install old packages with raco (e.g., similar to how I
> would do apt-get install $pkg==$version)? Or should I compile the old
> Rosette from source?
>
> I would highly appreciate any help.
> Thank you,
> Best regards
> Kiwan
>
> --
> You received this message because you are 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/a02da3b4-9965-4588-ae9e-e78010a2c283n%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/CADcueguqNOBBA8Hht7B7zNbHKtU%3DAms-sc9AyuNFBXKtCnuLSA%40mail.gmail.com.


Re: [racket-users] Doc pages search engine difficulties

2021-08-17 Thread Sorawee Porncharoenwase
But content search is also unsatisfactory in many situations. As an
example, take a look at Python’s documentation, which has the content
search. I searched for “list” (
https://docs.python.org/3/search.html?q=list_keywords=yes=default),
hoping to find the documentation for the list function, and the result that
I wanted is the 20th one. Earlier search results include the readline
library, because it contains the content “the history *list*”, and a code
example “reprlib.repr(set(‘supercalifragi*list*icexpialidocious’))”. This
problem virtually doesn’t exist with the indexed term search in Racket.

I'm not saying that there’s nothing to improve. I think making it possible
to do a content search, perhaps via a query like content:"file browser
dialog", might be a good idea. But I definitely think we should not take
the current search functionality away.




On Tue, Aug 17, 2021 at 8:52 AM Dexter Lagan  wrote:

>   True, I’m forced to do this when the search won’t do. It’s too bad the
> default search doesn’t work as well. Would it be shameful to use Google as
> the main search engine, as many others do? I’m sure most wouldn’t
> appreciate having to depend on Google for this. I’ll look at the code just
> so I understand.
>
> Dex
>
> On Aug 17, 2021, at 5:27 PM, Sorawee Porncharoenwase <
> sorawee.pw...@gmail.com> wrote:
>
> 
>
> FWIW, you can use Google to do that. The search query
>
> site:docs.racket-lang.org file browser dialog
>
> shows https://docs.racket-lang.org/mrlib/Path_Dialog.html as the first
> search result. The page also has a link to get-file and put-file.
>
>
> On Tue, Aug 17, 2021 at 7:34 AM Dexter Lagan 
> wrote:
>
>> Hello there,
>>
>>   I'm trying to teach one of my coworkers how to search for function
>> names in the Racket manual, and I'm having serious problems finding very
>> simple things, such as the function to display the file browser dialog
>> (get-file). I know most function names by heart but my coworker isn't that
>> fortunate. I see I'm not the only one, as per these
>> <https://stackoverflow.com/questions/38932984/file-dialog-box-to-create-save-a-new-file-in-racket>
>> Stack Overflow answers.
>>
>>   Does anybody know why the search engine doesn't seem to index page
>> contents other than exact function names and titles?
>>
>>   I understand search engines aren't trivial matters, but I'm thinking
>> that finding very basic Racket functions would be crucial for beginners. If
>> somebody could point me to the search engine repo, I'd love to have a look.
>>
>> Thanks in advance!
>>
>> 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/377da13a-dafe-4558-b21c-f71cd8238a93n%40googlegroups.com
>> <https://groups.google.com/d/msgid/racket-users/377da13a-dafe-4558-b21c-f71cd8238a93n%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/CADcuegt66-e5LY4r95eH0S3_OukcN0i1VDFuJiskCNd1retuhw%40mail.gmail.com.


Re: [racket-users] Doc pages search engine difficulties

2021-08-17 Thread Sorawee Porncharoenwase
FWIW, you can use Google to do that. The search query

site:docs.racket-lang.org file browser dialog

shows https://docs.racket-lang.org/mrlib/Path_Dialog.html as the first
search result. The page also has a link to get-file and put-file.


On Tue, Aug 17, 2021 at 7:34 AM Dexter Lagan  wrote:

> Hello there,
>
>   I'm trying to teach one of my coworkers how to search for function names
> in the Racket manual, and I'm having serious problems finding very simple
> things, such as the function to display the file browser dialog (get-file).
> I know most function names by heart but my coworker isn't that fortunate. I
> see I'm not the only one, as per these
> 
> Stack Overflow answers.
>
>   Does anybody know why the search engine doesn't seem to index page
> contents other than exact function names and titles?
>
>   I understand search engines aren't trivial matters, but I'm thinking
> that finding very basic Racket functions would be crucial for beginners. If
> somebody could point me to the search engine repo, I'd love to have a look.
>
> Thanks in advance!
>
> 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/377da13a-dafe-4558-b21c-f71cd8238a93n%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/CADcuegvZnhqO4_Mqi9sVSPkegJ6LAnGOO%3D%3DRSkE80eS7MWO_LA%40mail.gmail.com.


Re: [racket-users] Find the source location of the syntax error in DrRacket

2021-08-13 Thread Sorawee Porncharoenwase
Isn’t that a matter of putting more syntax/loc? I tried:

(-define-syntax let-syntaxes
(lambda (stx)
  (syntax-case stx ()
[(_ ([(id ...) expr] ...) body1 body ...)
 (with-syntax ([((tmp ...) ...)
(map
 generate-temporaries
 (syntax->list (syntax ((id ...) ...])
   (with-syntax ([inner-body
  (syntax/loc stx
(letrec-syntaxes+values
([(id ...)
  (values
   (make-rename-transformer (quote-syntax tmp))
   ...)] ...)
()
  body1 body ...))])
 (syntax/loc stx
   (letrec-syntaxes+values ([(tmp ...) expr] ...) ()
 inner-body])))

and the button now functions as you expect.

On Fri, Aug 13, 2021 at 7:45 PM Shu-Hung You 
wrote:

> Here are two syntax errors that behave differently in DrRacket:
>
> #lang racket
>
> (define-syntax (m-late stx)
>   #'(let () (define x 0)))
> (define-syntax (m-early stx)
>   #'(let-syntax () (define x 0)))
>
> ; (m-late)
> ; (m-early)
>
> DrRacket *correctly* highlights the source location of the errors in
> both cases. Additionally, for (m-early) I can click on the X button to
> jump to the error location.
>
> However, for (m-late) the X button brings me to internal Racket code.
> What's going on here?
>
> In case it helps, here are the error messages when I run the code in
> terminal:
>
> ;; m-late
> errstx.rkt:4:4: begin (possibly implicit): no expression after a
> sequence of internal definitions
>   in: (begin (define x 0))
>   location...:
>/Volumes/ramdisk/errstx.rkt:4:4
>/Volumes/ramdisk/errstx.rkt:4:12
>
> ;; m-early
> /racket/private/letstx-scheme.rkt:38:17: begin (possibly
> implicit): no expression after a sequence of internal definitions
>   in: (begin (define x 0))
>   location...:
>/racket/private/letstx-scheme.rkt:38:17
>/Volumes/ramdisk/errstx.rkt:6:19
>
> --
> You received this message because you are 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/CAMTzy%2BZtpWGdtkZkvzF4%3D25kpqUqGKsBcCDf4T%3DY3S2hV0v_GA%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/CADcuegtjNL%2BT-kTqbNKx_AkyLstpiRkyKjLJTuTGtyYcpGdmQA%40mail.gmail.com.


Re: [racket-users] Rosette variable definitions from an s-expression (I'm new to Rosette)

2021-07-12 Thread Sorawee Porncharoenwase
The recommended way is to write an interpreter to interpret your s-exp.
E.g.,

#lang rosette

(define vars (make-hash))

(define (lookup v)
  (hash-ref! vars v
 (λ ()
   (define-symbolic* a-var integer?)
   a-var)))

(define (interp e)
  (match e
[(? symbol? e) (lookup e)]
[`(> ,a ,b) (> (interp a) (interp b))]))

(define (verify-me e)
  (verify (assert (interp e

(define a-sol (verify-me '(> i j)))

a-sol

(evaluate (interp 'i) a-sol)


On Mon, Jul 12, 2021 at 1:28 PM David Wonnacott 
wrote:

> I'm hoping there are readers of this list who are familiar with Rosette
> , or
> could at least suggest a better place for me to ask such questions.
>
> I'm trying to use Rosette for some symbolic code simplification, and I'd
> like to be able to hand it various expressions that involve sets of
> variables (with types) and sets of assumptions *that I extract from
> s-expressions with other Racket code*.
>
> So, while I could do this:
>
>   #lang rosette/safe
>   (define-symbolic i j integer?)
>   (verify (assert (> i j)))
>
> or even this:
>
>   #lang rosette/safe
>   (define-symbolic i j integer?)
>   (define query (> i j))
>   (verify (assert query))
>
> and have it provide a counter-example model, e.g., i=j=0, I can't do this
> simplified version of what I'm aiming at:
>
>   #lang rosette/safe
>   (define (verify-me query)
> (define-symbolic (symbolics query) integer?)
> (verify (assert query)))
>   (verify-me '(> i j))
>
> Possibly I could do something unpleasant with macros to resolve this,
> though I suspect I'd need to convert a *lot* of other code into macros;
> possibly I could create a collection of fresh symbolics, and then replace
> the things I want to treat as symbolic in "query" with some kind of map.
> But, it didn't seems to me that I was asking for a really unusual usage
> case, so I'm hoping there's a more "normal" way to do this, i.e., to
> extract all names not it (make-base-namespace) from an s-expression and
> then make symbolics for some/all of them as if with define-symbolic.
>
> Perhaps this is easy, or perhaps this is just not something one could do
> with Rosette, or perhaps something in between?
>
> Dave W
>
> --
> You received this message because you are 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/6d45e35e-dbef-43f9-bf5c-318c6f25f557n%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/CADcuegszRmCFaDS%2BpAaCXmap30_nQLYwei-LseQOQSGRGRvbDg%40mail.gmail.com.


Re: [racket-users] Trying to specify resize-border for instance of dialog

2021-06-25 Thread Sorawee Porncharoenwase
It should be 'resize-border. Notice the single quote character in front of
“resize-border”.

FWIW, if you want to ask multiple short questions, you could also use the
Racket Slack channel.

The sign up link: https://racket-slack.herokuapp.com/
The channel: https://racket.slack.com/

On Fri, Jun 25, 2021 at 4:56 PM Don Green 
wrote:

> When I specify as follows:
>
> (define dialog2 (new dialog%
>  (label "Get-Prototype-dialog")
>  (style resize-border)
>  ))
>
> Returned error:
> resize-border: unbound identifier in: resize-border
>
> --
> You received this message because you are 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/dea0122e-02ab-4d79-8432-e32b8e733fc4n%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/CADcuegusiXL263ZQfFc%2BgfOaiMx8tDwejKQrqExJuEghcDrZ9A%40mail.gmail.com.


Re: [racket-users] Using get-file in racket/gui ...

2021-06-10 Thread Sorawee Porncharoenwase
The Racket Reference has a section on the notation used in documentations:
https://docs.racket-lang.org/reference/notation.html

But yes, what you said is correct: you are forced to specify every prior
optional positional argument. This is why I think optional positional
arguments are bad in general. Optional keyword arguments are much better.

On Thu, Jun 10, 2021 at 9:03 AM Don Green 
wrote:

> Where is the documentation that describes how to interpret the racket
> syntax?
> For example:
> (get-file  (message parent directory ...)) ;where the arg list of options
> are optional but if included are positional meaning that to specify an
> argument such as 'directory' means that the previous 2 args must also be
> specified.
>
> On Thursday, June 10, 2021 at 7:53:53 AM UTC-6 Plane wrote:
>
>> Of course, I meant the third, not fourth. Oops!
>>
>> On Thu, 10 Jun 2021, Crystal Jacobs wrote:
>>
>> > Looking at the docs:
>> >
>> >
>> https://docs.racket-lang.org/gui/Windowing_Functions.html?q=get-file#%28def._%28%28lib._mred%2Fmain..rkt%29._get-file%29%29
>> >
>> > It seems like the second argument is the message shown in the title of
>> the
>> > pop-up window. You can include a path as the fourth argument:
>> >
>> > (get-file #f f "/home/don/projects")
>> >
>> > -Crystal
>>
> --
> You received this message because you are 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/534bb7cb-b646-4cb5-ae7c-6d8c7d476ed2n%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/CADcueguEDX-a81MRjBkzPAy0JjLeztxhTKFarfrs6ME8s%3DAeVA%40mail.gmail.com.


Re: [racket-users] Computed properties for a struct?

2021-06-04 Thread Sorawee Porncharoenwase
I think you can create a custom accessor, and use macros to avoid the Royal
Pain.

One question is, is the derived field expensive to compute? If not, your
custom accessor can just compute the output every time it’s called. But if
it’s expensive, you can use memoization. Both approaches have the benefit
of performing the computation lazily.

#lang racket

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

(define (memoize f)
  (define table (make-hasheq))
  (λ (self) (hash-ref! table self (λ () (f self)

(define-syntax-parse-rule
  (provide+define-struct
   name fields
   {~seq #:field custom-accessor-name e} ...)
  #:with (custom-accessor-name* ...)
  (for/list ([n (attribute custom-accessor-name)])
(format-id #'name "~a-~a" #'name n))
  (begin
(struct name fields)
(define custom-accessor-name* (memoize e)) ...
(provide (struct-out name)
 custom-accessor-name* ...)))

(provide+define-struct
 foo (bar baz)
 #:field bad (λ (self) (+ (foo-bar self) (foo-baz self)))
 #:field bay (λ (self)
   (println 'should-be-called-once)
   (* (foo-bad self) 2)))

(define obj (foo 3 4))
(foo-bay obj)
; 'should-be-called-once
; 14
(foo-bay obj)
; 14


On Sat, Jun 5, 2021 at 5:21 AM flirora  wrote:

> Is there a way to define a struct so that it has a field whose value is
> filled in (instead of passed to the constructor) with a value derived from
> other fields? For example, could you define a struct foo with two
> explicit fields, x and y, plus a field called z whose value is computed
> as (+ x y) (yes, simple, but imagine that this is a more expensive
> operation):
>
> > (define foo1 (foo 1 2))
> > (define foo2 (foo 7 12))
> > (foo-z foo1)
> 3
> > (foo-z foo2)
> 19
>
> The closest I could find in the documentation was the #:auto property,
> but:
>
>1. it makes the field mutable, even though I'm not interested in
>mutating z
>2. the default value is fixed across all constructions, while I want z
>to depend on x and y
>
> Of course, I could make z an explicit field, write a custom constructor,
> and export that instead of the default constructor for foo. But that seems
> to be a Royal Pain, especially since (AFAIK) you can't provide the struct
> as a whole anymore. (And I need to write about 12 of these structs to boot.)
>
> --
> You received this message because you are 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/9f9e1548-d01d-469f-b565-22601e02dd82n%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/CADcuegvQdqm5BRx8DGa6Afqgw6vHOjaOhG3C6WdJznaEJW1%3DCQ%40mail.gmail.com.


Re: [racket-users] defmodule question

2021-04-25 Thread Sorawee Porncharoenwase
It looks like you are implying that @(defmodule circuit-simulation/circuits
#:packages ()) doesn’t work locally on your computer, but it should
(provided that you raco pkg install it properly).

On Sun, Apr 25, 2021 at 9:05 PM Jacob Jozef  wrote:

> Hi
>
>
>
> I have a #lang scribble/manual module in a file called
> ‘circuit-manual.scrbl ‘.
>
> It contains:
>
>
>
> @;@(defmodule circuit-simulation/circuits #:packages ())
>
> @(defmodule "circuits.rkt" #:packages ())
>
>
>
> When I open it in DrRacket and press the scribble HTML button,
>
> A neat HTML document is generated.
>
>
>
> When I put my stuff on GITHUB in a repository called ‘circuit-simulation’,
>
> I must uncomment the first line and comment out the second line
>
> or else the package manager cannot correctly install my package.
>
> In the document all links to the documented items are lost.
>
>
>
> The info module is:
>
> #lang info
>
> (define scribblings '(("circuit-manual.scrbl" (
>
>
>
> Can I avoid the necessity to comment and uncomment the defmodule form?
>
> Do I something wrong? May be I need to put more info in the info module?
>
>
>
> Thanks, Jos
>
>
>
> --
> You received this message because you are 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/E175DF73-9A99-4C48-A9AA-432C52DB25F0%40hxcore.ol
> 
> .
>

-- 
You received this message because you are 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/CADcueguzLyEsOwfV4MxCcMESQUto8L5NnwYnXfQ9oRbUfYBGVA%40mail.gmail.com.


Re: [racket-users] New package announce: value-evt

2021-04-01 Thread Sorawee Porncharoenwase
Oops, accidentally submitted the email before finishing writing.

Have you tried `raco docs value-evt`?

On Fri, Apr 2, 2021 at 12:10 AM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> `raco setup` does render the doc on my computer. I install Racket via git,
> so for me, the doc is located at
> `/path/to/racket/racket/doc/value-evt/index.html`. Yours might be in a
> different location.
>
> So I think you just need to wait for the package server to build your
> documentation.
>
> On Thu, Apr 1, 2021 at 11:37 PM Sage Gerard  wrote:
>
>> I compared the info.rkt files between your thread-with-id library and
>> value-evt. One thing that stands out is the extra empty list in
>> value-evt. I'm wondering if that hid defaults that would otherwise be
>> provided.
>>
>> https://github.com/dstorrs/value-evt/blob/master/info.rkt
>> https://github.com/dstorrs/thread-with-id/blob/master/info.rkt
>>
>> If that's not it, I'd have to take time after work to look more closely.
>>
>> On 4/1/21 12:31 PM, David Storrs wrote:
>> > On Thu, Apr 1, 2021 at 12:18 PM Sage Gerard 
>> wrote:
>> >> Neat! Thanks for this. Did you make sure to list your scribble file in
>> >> `scribblings` under info.rkt?
>> >>
>> > I did, yes.
>> >
>> > Although, now that you mention it, when I do raco setup value-evt it
>> > does all the things, says "Building documentation" but the .html file
>> > did not appear in the directory and it's not linked into my local doc
>> > set.  I hadn't noticed because I had previously created the file
>> > directly using 'scribble value-evt.scrbl'  What might I have done
>> > wrong?
>> >
>> >> On 4/1/21 12:12 PM, David Storrs wrote:
>> >>> Wraps an arbitrary value into a synchronizable event. The
>> >>> synchronization result of the event is the original value, with two
>> >>> exceptions: procedures sync to their return value and lists sync
>> >>> recursively. Both of these values can be disabled via keywords.
>> >>>
>> >>> The package server is telling me that it needs documentation.  That
>> >>> confuses me since it has a .scrbl file and the .html was already
>> >>> present in the repository.  ISTR that the docs are only built once
>> >>> every 24 hours, so presumably they will pop up at some point?
>> >>>
>> >>> Examples:
>> >>>
>> >>> ; value-evts are both evt? and value-evt?. They sync to their argument
>> >>>> (define e (value-evt 9))
>> >>>> e
>> >>> #
>> >>>> (evt? e)
>> >>> #t
>> >>>> (value-evt? e)
>> >>> #t
>> >>>> (sync e)
>> >>> 9
>> >>> ;
>> >>> ; By default, syncing on a procedure syncs to the return value
>> >>>> (define proc (lambda () (+ 2 2)))
>> >>>> (sync (value-evt proc))
>> >>> 4
>> >>> ;
>> >>> ; You can instead get the procedure itself back
>> >>>> (sync (value-evt proc #:eval-proc? #f))
>> >>> #
>> >>> ;
>> >>> ; It's not a problem to specify #:eval-proc? on something that isn't
>> a procedure
>> >>>> (sync (value-evt "eval-proc? keyword is ignored for non-proc"
>> #:eval-proc? #f))
>> >>> "eval-proc? keyword is ignored for non-proc"
>> >>> ;
>> >>> ; eventify always returns an evt
>> >>> ; Things that are evts are unchanged
>> >>>> (define ch (make-channel))
>> >>>> (evt? ch)
>> >>> #t
>> >>>> (eq? ch (eventify ch))
>> >>> #t
>> >>> ;
>> >>> ; Things that are not evts become value-evts
>> >>>> (evt? 'bob)
>> >>> #f
>> >>>> (evt? (eventify 'bob))
>> >>> #t
>> >>> ;
>> >>> ; by default, value-evts containing a list sync recursively
>> >>>> (let ([result-ch (make-channel)]
>> >>>   [arg-ch1   (make-channel)]
>> >>>   [arg-ch2   (make-channel)])
>> >>>   (void (thread (λ () (channel-put result-ch (sync (value-evt
>> (list
>> >>> arg-ch1 arg-ch2)))
>> >>>   (channel-put arg-ch1 'arg1-ch-ok)
>> >>>   (channel-put arg-ch2 'arg2-ch-ok)
>> >&g

Re: [racket-users] New package announce: value-evt

2021-04-01 Thread Sorawee Porncharoenwase
`raco setup` does render the doc on my computer. I install Racket via git,
so for me, the doc is located at
`/path/to/racket/racket/doc/value-evt/index.html`. Yours might be in a
different location.

So I think you just need to wait for the package server to build your
documentation.

On Thu, Apr 1, 2021 at 11:37 PM Sage Gerard  wrote:

> I compared the info.rkt files between your thread-with-id library and
> value-evt. One thing that stands out is the extra empty list in
> value-evt. I'm wondering if that hid defaults that would otherwise be
> provided.
>
> https://github.com/dstorrs/value-evt/blob/master/info.rkt
> https://github.com/dstorrs/thread-with-id/blob/master/info.rkt
>
> If that's not it, I'd have to take time after work to look more closely.
>
> On 4/1/21 12:31 PM, David Storrs wrote:
> > On Thu, Apr 1, 2021 at 12:18 PM Sage Gerard  wrote:
> >> Neat! Thanks for this. Did you make sure to list your scribble file in
> >> `scribblings` under info.rkt?
> >>
> > I did, yes.
> >
> > Although, now that you mention it, when I do raco setup value-evt it
> > does all the things, says "Building documentation" but the .html file
> > did not appear in the directory and it's not linked into my local doc
> > set.  I hadn't noticed because I had previously created the file
> > directly using 'scribble value-evt.scrbl'  What might I have done
> > wrong?
> >
> >> On 4/1/21 12:12 PM, David Storrs wrote:
> >>> Wraps an arbitrary value into a synchronizable event. The
> >>> synchronization result of the event is the original value, with two
> >>> exceptions: procedures sync to their return value and lists sync
> >>> recursively. Both of these values can be disabled via keywords.
> >>>
> >>> The package server is telling me that it needs documentation.  That
> >>> confuses me since it has a .scrbl file and the .html was already
> >>> present in the repository.  ISTR that the docs are only built once
> >>> every 24 hours, so presumably they will pop up at some point?
> >>>
> >>> Examples:
> >>>
> >>> ; value-evts are both evt? and value-evt?. They sync to their argument
>  (define e (value-evt 9))
>  e
> >>> #
>  (evt? e)
> >>> #t
>  (value-evt? e)
> >>> #t
>  (sync e)
> >>> 9
> >>> ;
> >>> ; By default, syncing on a procedure syncs to the return value
>  (define proc (lambda () (+ 2 2)))
>  (sync (value-evt proc))
> >>> 4
> >>> ;
> >>> ; You can instead get the procedure itself back
>  (sync (value-evt proc #:eval-proc? #f))
> >>> #
> >>> ;
> >>> ; It's not a problem to specify #:eval-proc? on something that isn't a
> procedure
>  (sync (value-evt "eval-proc? keyword is ignored for non-proc"
> #:eval-proc? #f))
> >>> "eval-proc? keyword is ignored for non-proc"
> >>> ;
> >>> ; eventify always returns an evt
> >>> ; Things that are evts are unchanged
>  (define ch (make-channel))
>  (evt? ch)
> >>> #t
>  (eq? ch (eventify ch))
> >>> #t
> >>> ;
> >>> ; Things that are not evts become value-evts
>  (evt? 'bob)
> >>> #f
>  (evt? (eventify 'bob))
> >>> #t
> >>> ;
> >>> ; by default, value-evts containing a list sync recursively
>  (let ([result-ch (make-channel)]
> >>>   [arg-ch1   (make-channel)]
> >>>   [arg-ch2   (make-channel)])
> >>>   (void (thread (λ () (channel-put result-ch (sync (value-evt (list
> >>> arg-ch1 arg-ch2)))
> >>>   (channel-put arg-ch1 'arg1-ch-ok)
> >>>   (channel-put arg-ch2 'arg2-ch-ok)
> >>>   (sync result-ch))
> >>> '(arg1-ch-ok arg2-ch-ok)
> >>> ;
> >>> ; You can ask for it to return the original list
>  (let ([arg-ch1   (make-channel)]
> >>>   [arg-ch2   (make-channel)])
> >>> (sync (value-evt (list arg-ch1 arg-ch2) #:recurse-lists? #f)))
> >>> '(# #)
> >>> ;
> >>> ; all-evt is the same as value-evt but takes a rest argument
> >>> ; so you don't have to supply your own list
>  (let ([result-ch (make-channel)]
> >>>   [arg-ch1   (make-channel)]
> >>>   [arg-ch2   (make-channel)])
> >>>   (define e (all-evt  arg-ch1 arg-ch2))
> >>>   (printf "all-evt returns: ~v" e)
> >>>   (void (thread (λ () (channel-put result-ch (sync e)
> >>>   (channel-put arg-ch1 'arg1-ch-ok)
> >>>   (channel-put arg-ch2 'arg2-ch-ok)
> >>>   (sync result-ch))
> >>> all-evt returns: #
> >>> '(arg1-ch-ok arg2-ch-ok)
> >>>
> >>> --
> >>> You received this message because you are 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/CAE8gKocr0FbpTKwgNcseNjjA_-64f4exQDkgfPPxxvFpR16pww%40mail.gmail.com
> .
> >> --
> >> ~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 

Re: [racket-users] Why are there seemingly unnecessary if expressions shown by the Macro stepper?

2021-03-21 Thread Sorawee Porncharoenwase
That’s not the job of the macro expander. And the Racket optimizer does
reduce (if '#t (#%app not '#f) '#f) — in fact to #t.

If you use Racket CS, try running:

PLT_LINKLET_SHOW_CP0=1 racket file.rkt

where file.rkt is

#lang racket
(displayln (if #t (not #f) #f))

Here’s the optimized program:

;; cp0 -
(lambda (instance-variable-reference .get-syntax-literal!1
 .set-transformer!2 displayln3 print-values4)
  (call-with-module-prompt
(lambda ()
  (#%call-with-values
(lambda () (displayln3 #t))
print-values4)))
  (#2%void))


On Mon, Mar 22, 2021 at 1:28 AM schle...@gmail.com 
wrote:

> The [WordCount] thread caused me to play around with the solutions to see
> whether I could see anything else that can be tweaked, I tried a few things
> but they didn't improve performance, but it was fun anyway.
>
> Then I though I could try the macro stepper and look at the expansion of
> [crowdsourced].
> I disabled macro hiding and stepped to the end.
> There I saw if statements with a condition that is `(quote #t)` with a
> little lock symbol before it.
>
> I would like to understand why those terms aren't reduced further.
> Are they placeholders and are replaced and resolved at a later time?
>
> terms copied (without the lock symbol) from the macro stepper
> (if (if '#t (#%app not '#f) '#f)
>   (#%app for-loop (#%app unsafe-fx+ '1 pos))
>   (#%app values))
>
> From a naive standpoint I would expect it to be simplified:
> (if '#t (#%app not '#f) '#f) -> (#%app not '#f)
>
> (if (#%app not '#f)
>   (#%app for-loop (#%app unsafe-fx+ '1 pos))
>   (#%app values))
>
> So expressed another way: why isn't the if with boolean literal as
> condition reduced to the corresponding branch? Or does this happen, just
> isn't shown in the macro stepper?
> What am I misunderstanding here?
>
> If there aren't simplifications like that, what is preventing them or
> making them not worthwhile?
>
>
> [WordCount]
> https://groups.google.com/g/racket-users/c/lGA60P6jboY/m/2ZLDAunBBgAJ
> [crowdsourced]
> https://gist.github.com/Bogdanp/b9256e1a91de9083830cb616b3659ff8
>
> --
> You received this message because you are 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/fce863fe-85d7-44a6-a2ba-5778df40e6bfn%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/CADcuegs1qGL0MnAzUmP9gFOOVL%2BRp-EB5wghpaY8sjiKObDbkA%40mail.gmail.com.


Re: [racket-users] Word Count program/benchmark performance

2021-03-18 Thread Sorawee Porncharoenwase
string-split always uses regex. I wonder if a fast path when the splitter
is a regular string will be worth it.

On Fri, Mar 19, 2021 at 4:19 AM Pawel Mosakowski 
wrote:

> Hi Bogdan,
>
> This is a brilliant solution and also completely over my head. It finishes
> in ~3.75s on my PC and is faster than the Python version which basically
> delegates all the work to C. I will need to spend some time on
> understanding it but I am looking forward to learning something new.
>
> Many thanks,
> Pawel
>
> On Thursday, March 18, 2021 at 7:22:10 PM UTC bogdan wrote:
>
>> I managed to get it about as fast as Python by making it really
>> imperative and rolling my own hash:
>>
>> https://gist.github.com/Bogdanp/fb39d202037cdaadd55dae3d45737571
>>
>> Sam Tobin-Hochstadt writes:
>>
>> > Here are several variants of the code:
>> > https://gist.github.com/d6fbe3757c462d5b4d1d9393b72f9ab9
>> >
>> > The enabled version is about the fastest I can get without using
>> > `unsafe` (which the rules said not to do). It's possible to optimize a
>> > tiny bit more by avoiding sorting, but only a few milliseconds -- it
>> > would be more significant if there were more different words.
>> >
>> > Switching to bytes works correctly for the given task, but wouldn't
>> > always work in the case of general UTF8 input. But those versions
>> > appeared not be faster for me. Also, writing my own string-downcase
>> > didn't help. And using a big buffer and doing my own newline splitting
>> > didn't help either.
>> >
>> > The version using just a regexp matching on a port (suggested by
>> > Robby) turned out not to be faster either, so my suspicion is that the
>> > original slowness is just using regexps for splitting words.
>> >
>> > Sam
>> >
>> > On Thu, Mar 18, 2021 at 11:28 AM Sam Tobin-Hochstadt
>> >  wrote:
>> >>
>> >> Here's a somewhat-optimized version of the code:
>> >>
>> >> #lang racket/base
>> >> (require racket/string racket/vector racket/port)
>> >>
>> >> (define h (make-hash))
>> >>
>> >> (time
>> >> (for* ([l (in-lines)]
>> >> [w (in-list (string-split l))]
>> >> [w* (in-value (string-downcase w))])
>> >> (hash-update! h w* add1 0)))
>> >>
>> >> (define v
>> >> (time
>> >> (for/vector #:length (hash-count h)
>> >> ([(k v) (in-hash h)])
>> >> (cons k v
>> >> (time (vector-sort! v > #:key cdr))
>> >> (define p (current-output-port) #;(open-output-nowhere))
>> >> (time
>> >> (for ([pair (in-vector v)])
>> >> (write-string (car pair) p)
>> >> (write-string (number->string (cdr pair)) p)
>> >> (newline p)))
>> >>
>> >> It's much more imperative, but also pretty nice and compact. The
>> >> `printf` optimization is significant for that portion of the program,
>> >> but that isn't much of the running time. The overall running time for
>> >> 10 copies of the KJV is about 9 seconds on my laptop.
>> >>
>> >> I think the remaining difference between Racket and other languages is
>> >> likely the `string-split` and `string-downcase` functions, plus the
>> >> relatively-inefficient string representation that Racket uses.
>> >>
>> >> Sam
>> >>
>> >>
>> >> On Thu, Mar 18, 2021 at 10:28 AM Pawel Mosakowski <
>> pa...@mosakowski.net> wrote:
>> >> >
>> >> > Hi David,
>> >> >
>> >> > Yes, the 21 seconds includes the interpreter startup time. I have
>> done a simple test to see how long it takes:
>> >> >
>> >> > $ time racket -e '(displayln "Hello, world")'
>> >> > Hello, world
>> >> >
>> >> > real 0m0.479s
>> >> > user 0m0.449s
>> >> > sys 0m0.030s
>> >> >
>> >> > I have also put my code inside a main function and profiled it:
>> >> >
>> >> > Profiling results
>> >> > -
>> >> > Total cpu time observed: 20910ms (out of 20970ms)
>> >> > Number of samples taken: 382 (once every 55ms)
>> >> > (Hiding functions with self<1.0% and local<2.0%: 1 of 12 hidden)
>> >> >
>> >> > ==
>> >> > Caller
>> >> > Idx Total Self Name+src Local%
>> >> > ms(pct) ms(pct) Callee
>> >> > ==
>> >> > [1] 20910(100.0%) 0(0.0%) [running body]
>> ...word-occurences-profile.rkt":##f
>> >> > profile-thunk [2] 100.0%
>> >> > --
>> >> > [running body] [1] 100.0%
>> >> > [2] 20910(100.0%) 0(0.0%) profile-thunk
>> ...ket/pkgs/profile-lib/main.rkt:9:0
>> >> > run [3] 100.0%
>> >> > --
>> >> > profile-thunk [2] 100.0%
>> >> > [3] 20910(100.0%) 0(0.0%) run
>> ...share/racket/pkgs/profile-lib/main.rkt:39:2
>> >> > main [4] 100.0%
>> >> > --
>> >> > run [3] 100.0%
>> >> > [4] 20910(100.0%) 50(0.2%) main
>> ...cket/count-word-occurences-profile.rkt:5:0
>> >> > read-from-stdin-it [5] 98.5%
>> >> > ??? [6] 0.2%
>> >> > --
>> >> > main [4] 100.0%
>> >> > [5] 20606(98.5%) 11796(56.4%) read-from-stdin-it
>> 

Re: [racket-users] Unusual check-expect results for images in Racket 8.0: getting #

2021-03-14 Thread Sorawee Porncharoenwase
Yes, this was reported at https://github.com/racket/htdp/issues/135. It's
now fixed. You can either download a snapshot version (
http://snapshot.racket-lang.org/) or downgrade to 7.9 to make it work
properly meanwhile.

On Mon, Mar 15, 2021 at 8:43 AM Peijing Teh  wrote:

> Hi,
>
> I am working through Grigor Kiczales's Systematic Program Design course,
> and recently updated Dr Racket to Racket 8.0.
>
> I started getting this unusual check-expects error (see screenshot): the
> image is not rendering and it instead shows as #.
>
> How do I let the developers know this is happening?
>
> To pre-empt questions:
>
>- (require 2htdp/image) is  already defined in line 1 of the
>Definitions area
>- the check-expects all ran correctly (so they are probably correctly
>defined)
>- all the images defined  have been standard shapes e.g. (square 10
>"solid" "blue") etc.
>- I am running a 2021 Mac Mini M1 macOS Big Sur 11.2.1
>
> With kindness,
> PJ
>
> --
> You received this message because you are 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/5e5dc6c5-94af-4bbd-a549-51ff31a59752n%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/CADcueguBX_3FCctmeR95w8LXssknu_Nz2zDjzC%2BFcpw%2BmEbknA%40mail.gmail.com.


Re: [racket-users] fluent: unix style pipes and lambda shorthand to make your code more readable

2021-03-12 Thread Sorawee Porncharoenwase
>
> There is probably a solution to this problem. I'm just not seeing it yet.
>
Yeah, syntax parameters are not really relevant here.

A way to make rename-in work is to define-syntax the “token” to a dummy
syntax transformer, and change your macro to recognize the token using
~literal. Here’s an example:

#lang racket

(module foo racket
  (require syntax/parse/define)
  (define-syntax (:= stx)
(raise-syntax-error #f "out of context" stx))
  (define-syntax-parse-rule (def x {~literal :=} e)
(define x e))
  (provide def :=))

(require (rename-in 'foo [:= ←]))

(def x ← 5)
x



>
> >
> > I like the ~> and ~~> arrows they are quite distinct, seems like a good
> default
> > to me.
> > I think the rackety way would be to have one default name and make them
> > rename-able.
> > Then fluent/unicode would not be necessary, but I also would not be
> bothered by
> > it.
> >
> > On a technical level I would prefer a solution that does not result in
> more and
> > more code generation for every renamed variant.
> > Roger Keays schrieb am Donnerstag, 11. März 2021 um 19:44:28 UTC+1:
> >
> > > > > It might be nice to use ~> and ~>> (or |> and |>> or choose
> your own)
> > as infix
> > > > > to avoid clashing with >.
> >
> > I'm thinking about changing the default operators to ~> and ~~> and
> making
> > the unicode versions available using (require fluent/unicode). I
> actually
> > prefer the long arrow for thread-last to the current syntax (>>).
> >
> > Any thoughts?
> >
> > On Wed, Mar 10, 2021 at 07:31:08PM -0500, Hendrik Boom wrote:
> > > On Wed, Mar 10, 2021 at 08:23:46PM +0700, Roger Keays wrote:
> > > > > I've been using the Clojure-like threading package for a while
> now
> > and this has
> > > > > some nice advantages that are mentioned in the docs, like
> blending
> > the first
> > > > > arg > and last arg >> variants easily in a sequence.
> > > > >
> > > > > How does fluent manage this infixing from a (require ...)
> rather than
> > a #lang?
> > > >
> > > > It provides a custom #%app macro which rearranges the code into
> regular
> > s-expressions. I was surprised by how much flexibility this feature
> of
> > racket gives you. It would have taken months to build this from
> scratch in
> > any other language. The racket version is 25 lines of code. [1]
> > > >
> > > > > It might be nice to use ~> and ~>> (or |> and |>> or choose
> your own)
> > as infix
> > > > > to avoid clashing with >.
> > > >
> > > > I wanted a single character because I use it so often. I suppose
> with
> > the unicode (→) option, there is less need for a single-character
> solution.
> > Need to think about this...
> > >
> > > Only if your keyboard has a convenient single key to type it with.
> > >
> > > -- hendrik
> > >
> > > >
> > > >
> > > > [1]
> https://github.com/rogerkeays/racket-fluent/blob/main/main.rkt
> > > > >
> > > > >
> > > > > 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...@googlegroups.com.
> > > > > To view this discussion on the web visit
> https://groups.google.com/d/
> > msgid/
> > > > > racket-users/
> > > > > CAFKxZVVBV1sP%2BKk%2B%2Bdw7k7a_TcEsL-yz6%2BLKDLZOa2Wfc1RAYw%
> > 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...@googlegroups.com.
> > > > To view this discussion on the web visit
> https://groups.google.com/d/
> >
>  msgid/racket-users/sigid.0703ba7d55.20210310132341.GA3081%40papaya.papaya.
> > >
> > > --
> > > You received this message because you are 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...@googlegroups.com.
> > > To view this discussion on the web visit
> https://groups.google.com/d/
> > msgid/racket-users/20210311003108.qjqsrn4kd6nbwtd5%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/79e3eb5f-90cb-49fb-824b-92e5b184053en%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To 

Re: [racket-users] Is something wrong with the documentation site?

2021-03-08 Thread Sorawee Porncharoenwase
See also the discussion at
https://github.com/mbutterick/pollen-users/issues/92

On Tue, Mar 9, 2021 at 2:31 AM Sage Gerard  wrote:

> There's an issue where if a package build fails, the pretty links to the
> docs do not resolve.
>
> For future reference, you can get around this by going to the package
> page...
>
> https://pkgs.racket-lang.org/package/pollen
>
> ...and then clicking "Documentation". That particular URL seems to still
> work. I cannot speak to what discrepancies may exist between the version
> that failed to build and the document returned via the package page.
> On 3/8/21 2:28 PM, Andre Garzia wrote:
>
> Hi Folks,
>
> I just noticed that I can't seem to find the docs for some packages such
> as Pollen anymore.
>
> https://docs.racket-lang.org/pollen/
>
> Is returning a page not found.
>
> I don't know if it is related, but my Racket 8.0 CS on macOS is also
> complaining that "pkg" is not a valid raco command. Did something change?
>
> Warm regards
> Andre
>
> --
> https://www.andregarzia.com 
> Want to support me? Buy me a coffee at https://ko-fi.com/andregarzia
> --
> You received this message because you are 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/CAF3jwTmyyS-qXuKYAMUiG2zfrxXePmOUXpG2kZUWNyAwO3uQAA%40mail.gmail.com
> 
> .
>
> --
> ~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/f0b85cf9-ee09-7b73-0b95-363c5de5fb6e%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/CADcuegs1aQJe92vxtujR3obWNT0Cv1XAJs%3DtbnfP5RPSU815yA%40mail.gmail.com.


Re: [racket-users] Possible bug when reading/writing large inexact numbers

2021-03-07 Thread Sorawee Porncharoenwase
This is already fixed. Racket 8.0 doesn't have this issue.

On Mon, Mar 8, 2021 at 8:31 AM Greg Rosenblatt  wrote:

> Large inexact numbers may change values after a second round trip between
> read and write.  I was expecting to reach a fixed point after the first
> round trip.  Is this a bug?
>
> Welcome to Racket v7.8 [cs].
> > 4.57030e+53
> 4.5703e+53
> > 4.5703e+53
> 4.57029995e+53
>
> --
> You received this message because you are 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/28f2c566-472f-48eb-881f-028dad5b1285n%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/CADcuegtQ_%3D69tB6mAtJaXRFoxkaC8wgHyb1mHmAYTYn22OiQAQ%40mail.gmail.com.


Re: [racket-users] Racket slower than Chez Scheme on interpreter benchmark, potential low hanging fruit?

2021-03-07 Thread Sorawee Porncharoenwase
With the recent improvements by Phil, the rank of the syntax object variant
moves up from 26th to the second (what?!?), losing only to c++ / g++.
Moreover, it's significantly faster than the third place.

On Fri, Mar 5, 2021 at 3:29 AM philngu...@gmail.com <
philnguyen0...@gmail.com> wrote:

> Oh I see. So one problem is here that `match-define` expands to `match`
> with an implicit error case, which at the low level, isn't distinguished
> from a user-written second case, and the tag check can't just be eliminated.
>
> On Thursday, March 4, 2021 at 9:40:22 AM UTC-8 Sam Tobin-Hochstadt wrote:
>
>> I think there are two reasons that code gets slower.
>>
>> 1. The `match-define` includes pair and struct checks, which are
>> omitted for plain accessor uses because of the unsafe declaration.
>> 2. That use of `match` expands to `define-values` which ends up as a
>> `call-with-values` and a `case-lambda` at the chez layer and is not
>> removed.
>>
>> `match` could recognize that it's being compiled with unsafe mode and
>> omit these checks, although it's not that straightforward. Also
>> schemify (or Chez) could do more to eliminate the use of multiple
>> values, although that's hard without eliminating the failure cases.
>>
>> Sam
>>
>> On Thu, Mar 4, 2021 at 3:23 AM philngu...@gmail.com
>>  wrote:
>> >
>> > Thanks for the tip about PLT_CS_COMPILE_LIMIT! I submitted a revision
>> to the syntax object variant that incorporated sleepnova's and yjqww6's
>> improvements.
>> >
>> > Also, I never knew about `(#%declare #:unsafe)` until I saw yjqww6's
>> pull request. It makes a noticeable difference. One unsatisfying thing is
>> that in one place, if I replace the 4 separate define clauses with just
>> `(match-define (cons (op o val) rst) parsed)`, the benchmarks are more than
>> twice slower.
>> >
>> > On Wednesday, March 3, 2021 at 11:12:30 AM UTC-8 Sam Tobin-Hochstadt
>> wrote:
>> >>
>> >> First, there's no longer a difference because yjqww6 just had a PR
>> >> merged that improves the Racket performance.
>> >>
>> >> The performance difference that was there was mostly because the Chez
>> >> code was run with `--optimize-level 3` which turns off safety. If that
>> >> was changed to `--optimize-level 2` the timing became much slower.
>> >>
>> >> Sam
>> >>
>> >> On Mon, Mar 1, 2021 at 2:39 AM philngu...@gmail.com
>> >>  wrote:
>> >> >
>> >> > There’s this benchmark on BF interpreter where the Racket and Chez
>> Scheme implementations are very similar, but Chez Scheme is much faster
>> than Racket 8.0 at interpreting bench.b (3s vs 8s) and mandel.b (40s vs
>> 136s).
>> >> >
>> >> > There’s the “Racket (Syntax Object)” variant that directly parses
>> BF’s syntax into Racket syntax object, which is faster (3.7s for bench, 82s
>> for mandel), but still significantly behind Chez Scheme’s naive
>> interpreter.
>> >> >
>> >> > Profiling doesn’t give very illuminating results, saying most of the
>> cost is from interpreting BF’s loop instruction.
>> >> >
>> >> > Given that Racket is on Chez, could this benchmark reveal some low
>> hanging fruit for improving Racket’s performance?
>> >> >
>> >> > --
>> >> > You received this message because you are 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...@googlegroups.com.
>> >> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/83b2819d-8295-4769-944d-fa0c155976dan%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...@googlegroups.com.
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/a5e77286-68b8-481a-8dea-0f547c5ce968n%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/f771a13a-9fc4-4b71-9e47-3a83eb5290e7n%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/CADcuegvSFZvD9SaTz2uakJp%3D6tmoEmVbGJKhxwzdeHsse8jVkQ%40mail.gmail.com.


Re: [racket-users] Re: When are rackunit tests delayed? (different between 7.8 and 8)

2021-03-06 Thread Sorawee Porncharoenwase
This is a regression caused by me (
https://github.com/racket/rackunit/commit/d7665ddc17405b25c7365eda5c560b671340853d).
I will try to find a way to fix.

On Thu, Feb 25, 2021 at 3:30 PM jackh...@gmail.com 
wrote:

> The test-suite semantics in rackunit are complex, under-specified, and
> quite brittle. I recommend avoiding them entirely and sticking entirely to
> test cases and test-begin.
>
> On Monday, February 22, 2021 at 10:19:04 PM UTC-8 William J. Bowman wrote:
>
>> Below is an example that behaves "correctly", as in all tests run and are
>> counted as failured or errors correctly, in Racket 7.8, but which crashes
>> in
>> Racket 8.
>>
>> > #lang racket
>> >
>> > (require
>> > rackunit
>> > rackunit/log)
>> >
>> > (define (suite1)
>> > (test-suite
>> > ""
>> > (test-begin
>> > (check-not-equal? (error "actual") (error "expected")
>> >
>> > (define (suite2)
>> > (test-suite
>> > ""
>> > (check-not-equal? (error "actual") (error "expected"
>> >
>> > (module+ test
>> > (require rackunit/text-ui)
>> >
>> > ;; Correctly counts the tests as errors in 7.8 and 8.0
>> > (check-pred
>> > integer?
>> > (run-tests (suite1)))
>> >
>> > ;; Counts the tests as errors in 7.8, but crashes in 8.0
>> > (check-pred
>> > integer?
>> > (run-tests (suite2)))
>> >
>> > ;; Gets run in 7.8, but not in 8.0
>> > (check-equal? 0 0))
>>
>> This has something to do with when test-suite delays a test, which seems
>> inconsistent across the Racket versions.
>> I'm not sure whether the problem was some undefined behaviour in
>> test-suite or
>> not.
>>
>> I'm a bit confused about the semantics of test-suites and tests, since
>> the
>> documentation claims a test (unlike a check) is delayed, yet test-case
>> and
>> test-begin do not delay tests, while test-suite does produce a delayed
>> suite of
>> tests.
>> However, test-begin DOES seem to delay a test in the context of a
>> test-suite.
>>
>> I'd appreciate any insight.
>>
>> --
>> William J. Bowman
>>
>> --
> You received this message because you are 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/73510d26-7405-4c0a-a0e3-1b06f77f3576n%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/CADcuegsoySbdyd_axOWUXjicijTYbS3-ZJQYkE3cntq_7wjaJQ%40mail.gmail.com.


Re: [racket-users] can't create a new package on pkgd.racket-lang.org

2021-02-19 Thread Sorawee Porncharoenwase
For the raco pkg install error, it looks like your branch is named main, so
you need to run raco pkg install git://
github.com/rogerkeays/racket-dollar#main

Ideally, raco pkg install git://github.com/rogerkeays/racket-dollar should
also work, but currently it doesn’t
.

On Fri, Feb 19, 2021 at 6:52 PM Roger Keays  wrote:

>
> Hi,
>
> Today I made an account on racket-lang.org to post a package, but when I
> submit the form, it just bounces back at me, blank. The package I added
> does not appear under "my packages", so it seems the submission failed.
> There are no error messages.
>
> https://pkgd.racket-lang.org/pkgn/create
>
> I'm submitting an example #lang extension from github for
> educational/demonstration purposes:
> https://github.com/rogerkeays/racket-dollar
>
> Could this be because my account is new? I also noticed I get an error
> when trying to get raco to install from github:
>
> $ raco pkg install git://github.com/rogerkeays/racket-dollar#master
> Querying Git references for racket-dollar at git://
> github.com/rogerkeays/racket-dollar#master
> git: could not find requested reference
>   reference: master
>   context...:
>/usr/share/racket/collects/net/git-checkout.rkt:344:0: select-commits
>/usr/share/racket/collects/net/git-checkout.rkt:73:8
>/usr/share/racket/collects/net/git-checkout.rkt:54:2: retry-loop
>/usr/share/racket/collects/pkg/private/stage.rkt:59:2: lookup-normally
>/usr/share/racket/collects/pkg/private/stage.rkt:107:0:
> stage-package/info46
>/usr/share/racket/collects/pkg/private/install.rkt:659:4: for-loop
>/usr/share/racket/collects/pkg/private/install.rkt:141:0:
> install-packages76
>
>  
> /usr/share/racket/collects/pkg/private/../../racket/private/more-scheme.rkt:261:28
>
>  /usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt:430:3
>/usr/share/racket/collects/racket/file.rkt:435:8
>/usr/share/racket/collects/racket/file.rkt:391:2: loop
>/usr/share/racket/collects/pkg/main.rkt:206:16
>(submod "/usr/share/racket/collects/pkg/main.rkt" main): [running body]
>temp37_0
>for-loop
>run-module-instance!125
>...
>
> $ racket -v
> Welcome to Racket v7.2.
>
> Suggestions welcome.
>
> --
> You received this message because you are 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/sigid.16823f523d.20210217164232.GA4731%40papaya.papaya
> .
>

-- 
You received this message because you are 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/CADcuegtie4M_Cjjycvc15hbfSN98HQxcNZZYH4LUxW5kfPUviA%40mail.gmail.com.


Re: [racket-users] put-image

2021-02-06 Thread Sorawee Porncharoenwase
As explained in documentation of WeScheme
,
put-image is only available in WeScheme. Racket and its libraries don’t
have this function.

It’s easy to implement it yourself, however, by using place-image and
image-height. Both are available in 2htdp/image

On Sat, Feb 6, 2021 at 3:24 PM patric...@gmail.com 
wrote:

>
> What do I need to do to be able to use the "put-image" method from
> WeScheme? I am starting off my program with:
>
>
>
> *#lang htdp/bsl(require 2htdp/image)*
>
> Is there another package I need to use?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/c8788557-0fe6-46a2-be1a-1dbb432ab939n%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/CADcuegvDB8a%2BN13xcr6dcgDo4z92sDqDA%2BkU%3DhjnHffGN1h8Vg%40mail.gmail.com.


Re: [racket-users] Using GraphViz inside of Scribble?

2021-01-27 Thread Sorawee Porncharoenwase
Here’s how to add graphviz to Pollen
. The same technique
can be used for Scribble, but you would want to use image

as the tag function. You might also need to use define-runtime-path

.

On Wed, Jan 27, 2021 at 9:23 PM Tim Meehan  wrote:

> IMHO, Racket's documentation is the gold standard. I tell everyone I work
> with that we should document things this well.
> Until now, I haven't seen any room for potential improvements.
>
> Now, I like ASCII art as much as the next person, but when I was reading
> the documentation for the GUI class hierarchy, I remembered that there was
> a graphviz  package for
> Racket now.
> I'm no good with Scribble, but I bet that someone clever could add some
> automatic graphs to it without much trouble.
>
> I'm not much good at GraphViz either, but here is my take on the first two
> ASCII art diagrams. I just used "dot -Tpdf" to make the tests.
>
> --
> You received this message because you are 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/CACgrOxKkeVxdMq9-94%2BX87oCmBKaY0XHg-Sq4yj-fPLy%2B6MYyg%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/CADcuegstUJsYGjcm5C7_Hniw_%3DTvb69FyQa820JN4vP0kChD%2BA%40mail.gmail.com.


Re: [racket-users] Unsafe structs

2021-01-19 Thread Sorawee Porncharoenwase
However, ‘struct-field-info-list’ returns only fields defined by the
actual type and does not include fields that were inherited. What I
don’t see is any simple way to get at the struct’s inheritance hierarchy
—- it seems that you have to iterate ‘struct-type-info’ to enumerate the
supertypes.

Yes, that’s a (the?) way to extract field names of supertypes. The reason I
designed it in that way is that field name is a concept for each level in
the hierarchy, not across levels. You can’t have two identical field names
in a level, but you can have identical field names across levels. So
lumping field names across levels together doesn’t look like a good idea to
me.

On Fri, Jan 8, 2021 at 12:39 PM Sam Tobin-Hochstadt 
wrote:

> Thanks for this detailed account (and for trying it out). I have some
> questions inline:
>
>
> On Sat, Jan 2, 2021 at 5:34 PM Dominik Pantůček
>  wrote:
> > And now for the worse part. TR rough edges:
> >
> > * Higher-order procedures and polymorphic functions in all imaginable
> > combinations. That was a total disaster. Yes, the documentation clearly
> > states that - but typing any code using these is like trying to break a
> > badly designed cipher. Irregularities here and there. Sometimes simple
> > `inst' was enough. Sometimes casting both the function and the arguments
> > was necessary. The biggest trouble is that the error messages are very
> > cryptic and sometimes even do not point to the offending construct but
> > only the module file. I will provide MWE to show this if someone wants
> > to look into it.
>
> An example would be great here. In general you should only need one
> use of `inst` in any of these cases, and you shouldn't ever need a
> `cast`.
>
> > * Struct: Missing struct generics - when porting code that relies on
> > them, there's not much that can be done.
>
> This is indeed a limitation -- struct generics are complex and we
> (mostly Fred Fu) are thinking about them, but it's not there yet.
>
> > * Math: there really is just a natural logarithm and no logarithm with
> > arbitrary base? Yes, one-line to implement, but why?
>
> I'm not sure why this didn't get added originally, but it's easy to fix.
>
> > * Math/Fixnums/Flonums: All fx+/-/*/... accept two arguments only. No
> > unary fl-, no variadic-argument fl+ or fxior (this one hurt the most).
>
> These definitely became variadic after the type definitions were
> written, but that's of course not an excuse for not updating them.
>
> > * unsafe/ops: unsafe-vector-* resisted a lot - until I just gave up and
> > require/typed it for my particular types. Maybe casting would help, but
> > the error messages were different to the classical problems of the
> > polymorphic functions in TR.
>
> Can you say more about what happened here?
>
> > * Classes: My notes say "". Which roughly says it
> > all. Although I managed to back down to only using bitmap% class,
> > properly typing all procedures using it was a nightmare. By properly I
> > mean "it compiles and runs".
>
> More detail here would be helpful as well.
>
> > * with-input-from-file does not accept Path or String, only Path-String
> > and the conversion rules are either missing or strange at best.
> > Basically I ended up with just converting to String and casting to
> > Path-String to make everything work.
> >
> > * with-input-from-file also revealed that procedure signatures as types
> > can be very tricky - just passing `read' was not possible, because it
> > accepts some optional arguments. Wrapping it in thunk helped though.
>
> I don't understand what the problem was here; for example this works for
> me:
>
> #lang typed/racket
> (with-input-from-file "/tmp/x.rkt" read)
>
> and `Path-String` is just the union of Path and String.
>
> > * order of definitions matters. Not that this is unexpected, it is just
> > strange when working with larger code-base where it didn't matter.
> > Actually the error messages were helpful here.
>
> What do you mean by "order of definitions matters" here?
>
> > * Type annotations of procedures with variadic arguments. The only place
> > where I had to put annotations outside of the procedure definition. It
> > is nothing super-problematic, but it feels inconsistent with the rest.
>
> I would encourage type annotations before the procedure definition in
> all cases -- the `define` form doesn't really have the right places to
> put everything that can go in a function type.
>
> > * More modules need to be required everywhere. If module A provides a
> > procedure that accepts a type from module B, all modules using that
> > procedure must also require the module B to know the type. In normal
> > Racket it does not matter as long as you just pass the opaque data along.
>
> Can you give an example?
>
> > * Syntax macros are extra hard. As I use some syntax trickery to convert
> > semi-regular code to "futurized" one, I basically gave up and just ran
> > everything single-threaded. The main issue is passing 

Re: [racket-users] Typed Racket: Subtype of a struct typed where one field has a fixed value

2021-01-16 Thread Sorawee Porncharoenwase
According to https://docs.racket-lang.org/ts-reference/type-ref.html,
`Zero` exists.

On Sat, Jan 16, 2021 at 8:14 AM je...@lisp.sh  wrote:

> Working in Typed Racket, consider a struct like this:
>
> (struct point
>   ([x : Real]
>[y : Real]))
>
> Is there a way to express the type of those points whose y field is, say,
> 0? In other words, I'd like a talk about point structs where x varies
> freely, but y is always 0. Obviously, I can make a function that
> discriminates this subclass, but I'm not sure how to express it as a type.
> I've hunted around in the docs, but I can't quite find what I'm looking for.
>
> --
> You received this message because you are 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/ee8bc006-590c-48f6-ac8b-4ef4f88019dfn%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/CADcuegvQDSR%2B7-rFp5crP7vK1%2Bnbgg0OS4yVz9Q%2B%3D%3Dg3XqRpfA%40mail.gmail.com.


[racket-users] History changes

2021-01-10 Thread Sorawee Porncharoenwase
Hi Racketeers,

Laurent Orseau asked if it’s possible for the release announcement to
include @history changes (compared to the previous release), because some
small but useful changes might go unnoticed otherwise. I think this is a
great idea, so I tried to implement the feature. The result for 8.0 release
is included at the end of the email. However, I’m not satisfied with my
current approach, and I would appreciate it if anyone could suggest a way
to improve it.

My current workflow is:

   1. Download two Racket versions that I want to diff @history.
   2. Patch share/pkgs/scribble-lib on both versions
   3. Run raco setup -c scribblings; HISTORY_INFO_PATH=/path/to/info raco
   setup scribblings on both versions
   4. Run the diffing program on the two info files.

Patching scribble-lib is something I want to avoid. Specifically, I need to
modify scribble-lib to

   - modify history to recognize HISTORY_INFO_PATH and emit information.
   This alone is enough to get all information except the “who I am” field
   (see below)
   - modify all documenting forms, like defform, defproc, etc. so that it
   cooperates with history to supply “who I am” field. This is further
   complicated by the fact that deftogether exists, so I need to hack the
   with-togetherable-racket-variables protocol to keep the information
   around.

It would be nice if I don’t have to modify scribble-lib, or, failing that,
avoid touching documenting forms. Isn’t it possible for history to know
which defform it’s under?
Anyhow, here's the output for v8.0

who: #%declare
package: base
source: racket-doc/scribblings/reference/syntax.scrbl:433:19
desc:
  Changed in version 7.9.0.5: Added #:unsafe.


who: system-type
package: base
source: racket-doc/scribblings/reference/runtime.scrbl:132:19
desc:
  Changed in version 7.9.0.6: Added 'os* and 'arch modes.


who: _cprocedure
package: base
source: racket-doc/scribblings/foreign/types.scrbl:780:19
desc:
  Changed in version 7.9.0.16: Added the #:varargs-after argument.


who: _fun
package: base
source: racket-doc/scribblings/foreign/types.scrbl:916:19
desc:
  Changed in version 7.9.0.16: Added the #:varargs-after option.


source: racket-doc/scribblings/raco/setup.scrbl:383:19
desc:
  Changed in version 7.9.0.3: Added PLT_SETUP_NO_FORCE_GC,
PLT_SETUP_SHOW_TIMESTAMPS, and --sync-docs-only.


source: racket-doc/scribblings/raco/decompile.scrbl:37:19
desc:
  Changed in version 1.9: Added --partial-fasl.


package: compiler-lib
source: racket-doc/scribblings/raco/test.scrbl:198:19
desc:
  Changed in version 1.8: Added --output and -o.


package: base
source: racket-doc/scribblings/reference/syntax-model.scrbl:450:19
desc:
  Changed in version 7.9.0.13: Added implicit-made-explicit properties.


who: fx+/wraparound
package: base
source: racket-doc/scribblings/reference/fixnums.scrbl:104:17
desc:
  Added in version 7.9.0.6.


who: bytes-open-converter
package: base
source: racket-doc/scribblings/reference/bytes.scrbl:520:19
desc:
  Changed in version 7.9.0.17: Added built-in converters for "WTF-8",
<"WTF-8-permissive", and "WTF-16".


who: hash-intersect
package: base
source: racket-doc/scribblings/reference/hashes.scrbl:795:17
desc:
  Added in version 7.8.0.11.


package: base
source: racket-doc/scribblings/reference/cont.scrbl:105:19
desc:
  Changed in version 7.9.0.13: The name argument gives the name of the
prompt tag.


who: object-name
package: base
source: racket-doc/scribblings/reference/struct-inspectors.scrbl:191:20
desc:
  Changed in version 7.9.0.13: Recognize the name of continuation prompt
tags.


who: unsafe-fx+/wraparound
package: base
source: racket-doc/scribblings/reference/unsafe.scrbl:91:17
desc:
  Added in version 7.9.0.6.


who: unsafe-set-immutable-car!
package: base
source: racket-doc/scribblings/reference/unsafe.scrbl:306:17
desc:
  Added in version 7.9.0.18.


who: editor:silent-cancel-on-save-file-out-of-date?
package: gui-lib
source: gui-lib/framework/main.rkt:1634:18
desc:
  Added in version 1.53.


who: make
package: gui-lib
source: gui-doc/scribblings/gui/tab-panel-class.scrbl:65:19
desc:
  Changed in version 1.55: Added the 'can-reorder and 'can-close styles.


who: on-reorder
package: gui-lib
source: gui-doc/scribblings/gui/tab-panel-class.scrbl:121:17
desc:
  Added in version 1.55.


who: on-close-request
package: gui-lib
source: gui-doc/scribblings/gui/tab-panel-class.scrbl:132:17
desc:
  Added in version 1.55.


who: on-superwindow-activate
package: gui-lib
source: gui-doc/scribblings/gui/window-intf.scrbl:481:19
desc:
  Added in version 1.54.


who: message-box/custom
package: gui-lib
source: gui-doc/scribblings/gui/dialog-funcs.scrbl:355:19
desc:
  Changed in version 1.53: Added the return-the-dialog? argument and the
ability to change the dialog box's message.


who: message+check-box
package: gui-lib
source: gui-doc/scribblings/gui/dialog-funcs.scrbl:388:19
desc:
  Changed in version 1.53: Added the return-the-dialog? argument and the
ability to change the 

Re: [racket-users] compose in Typed Racket

2020-12-16 Thread Sorawee Porncharoenwase
syntax-parse can already perform pattern matching. No need to use match

(define-syntax (multi-compose stx)
  (syntax-parse stx
[(_ f:expr g:expr)
 #'(compose f g)]
[(_ f:expr funcs:expr ...)
 #'(compose f (multi-compose funcs ...))]))


On Wed, Dec 16, 2020 at 1:37 PM unlimitedscolobb 
wrote:

> On Thursday, December 10, 2020 at 6:01:52 PM UTC+1 unlimitedscolobb wrote:
>
>> On Thursday, December 10, 2020 at 5:49:43 PM UTC+1 hen...@topoi.pooq.com
>> wrote:
>>
>> A macro might be able to generate either of the above from
>>> (comp f g h k)
>>> .
>>>
>> Indeed. I'm re-reading the docs on macros and I think I see a clean and
>> clear way to achieve what I need.
>>
>> I'll post my attempt as soon as I get the time to write it.
>>
>>
> Okay, so this is my shot:
>
> #lang typed/racket
>
> (require (for-syntax syntax/parse racket/match))
>
> (define-syntax (multi-compose stx)
>   (syntax-parse stx
> [(_ funcs:expr ...)
>  (match-define (list fn fn-1 fs ...)
>(reverse (syntax->list #'(funcs ...
>  (datum->syntax stx (for/fold ([sexp `(compose ,fn-1 ,fn)])
>   ([f (in-list fs)])
>   `(compose ,f ,sexp)))]))
>
> (multi-compose f1 f2 ... fn-1 fn) expands to (compose f1 (compose f2 ( ...
> (compose fn-1 fn) ... )))
>
> My syntax-transformation-fu is essentially non-existent, even after
> reading through Greg's Fear of Macros multiple times, so please do tell me
> if you see some flagrant opportunities for improvement in the code above.
>
> I'm planning to throw together a small package with compose-n , compose-3
> to compose-10, and multi-compose, and publish it.  It would normally be my
> Christmas package for myself, but it make take some more time :-)
>
> -
> Sergiu
>
> --
> You received this message because you are 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/219c189f-dd93-4b18-9ef9-2ff477ce3a15n%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/CADcuegv89YYkzVWRJMu1HCQC7HDH5QzLfdr0_ZKRbiqGzxjneA%40mail.gmail.com.


Re: [racket-users] (current-memory-use cust) gives "wrong number of arguments" in typed racket

2020-12-13 Thread Sorawee Porncharoenwase
Fixed by https://github.com/racket/typed-racket/pull/1009.

On Sat, Dec 12, 2020 at 7:09 PM James Cook  wrote:

> I'm new to racket, and I'm not sure if this is a bug or oversight or I'm
> just missing something.
>
> In typed racket, when I try to pass a custodian as an argument to the
> current-memory-use function, I get an error like so:
>
> falsifian angel ~ $ racket -I typed/racket
> Welcome to Racket v7.9 [cs].
> > (define c (make-custodian))
> > (current-memory-use c)
> ; readline-input:2:0: Type Checker: could not apply function;
> ;  wrong number of arguments provided
> ;   expected: 0
> ;   given: 1
> ;   in: (current-memory-use c)
> ; [,bt for context]
>
> If I don't pass "-I typed/racket" then there's no trouble. What's going
> on? Does the current-memory-use function need a better type annotation?
>
> James
>
> --
> You received this message because you are 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/164bb6df-9dd6-4aa5-91a5-8ea3d70ad2a4n%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/CADcuegtM0caJq97o0mfPXVG5w81fb72OomqNFg69Oq4WALu_qQ%40mail.gmail.com.


Re: [racket-users] Racket GUI editor: how read and process keyboard input

2020-12-06 Thread Sorawee Porncharoenwase
IIRC, capslock can’t be handled by applications. When people customize
capslock to do something else, what they actually do is to ask their OS to
redirect the capslock keypress to other keys (say, F2), and then intercept
these other keys instead.

To catch keypresses like F2, create your own class that has text% as a
superclass, and override on-default-char.

On Sun, Dec 6, 2020 at 5:17 AM Christian Lykke  wrote:

>
> I would like to create an editor where I can use capslock
> or some other key to input special commands
> somewhat similar to M-x in emacs.
>
> with capslock (since I never use capslock anyway):
>
> every time I write someting in the editor, a function should
> run that will do something with the input.
> If capslock is turned off, the text should just be written
> in the editor normally.
> if capslock is on, then the text (letters, numbers ect)
> should instead be written
> in the field "commandField". if capslock is on and
> the input is a space or cariagereturn,
> then anoter function should run that takes the text
>  in the "commandField" field as its argument and executes a command.
> The command could be "increasesize" and
> then the function would run "select all" and then
> increase
> the font size by 1, and finally clear the "commandField".
> How could I do this?
>
> with some other key:
>
> It might be better to use another key than capslock,
> for example a function key.
> How could I create a boolean variable that
> changes everytime a specific key (for example f2)
>  gets pressed?
>
> Thank you !
>
> Here is the editor code I have so far:
>
> #lang racket
> (require racket/gui)
>
> ;first frame of the program
> (define firstFrame (new frame% [label "An editor that allow you to input
> commands"]
>   [width 500]
>   [height 500]))
>
> ;the commands you type should be vissible in this message control
> (define commandField (new message% [parent firstFrame]
>   [label "no commands yet..."]))
>
> ;the text area
> (define mainCanvas (new editor-canvas% [parent firstFrame]))
> (define mainTextArea (new text%))
> (send mainCanvas set-editor mainTextArea)
>
> ;A menu bar for ordinary texteditor functionality
> (define manubar (new menu-bar% [parent firstFrame]))
> (define editDropdown (new menu% [label "Edit"] [parent manubar]))
> (define fontDropdown (new menu% [label "Font"] [parent manubar]))
>
> (append-editor-operation-menu-items editDropdown #f)
> (append-editor-font-menu-items fontDropdown)
> (send mainTextArea set-max-undo-history 100)
>
> (send firstFrame show #t)
>
> --
> You received this message because you are 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/f07ba9b2-df26-4402-bb97-722d2c4f8d4dn%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/CADcuegudKjEi_a_bnC3SvUnTkVwokiwLzL%2BqK8OVBK9GG-ofDQ%40mail.gmail.com.


Re: [racket-users] Towards an Incremental Racket Parser for better IDE experience?

2020-12-02 Thread Sorawee Porncharoenwase
IIUC, many tools (Racket Mode , drcomplete
) do exactly what Robby said: cache
the most recent successfully expanded code.


On Wed, Dec 2, 2020 at 7:08 AM Robby Findler 
wrote:

> I'm not sure this approach is going to work for Racket. Being able to run
> `read` when the input is malformed is going to only get you so far, as the
> macro expansion seems unlikely to work and this is a point of extension for
> programers using Racket.
>
> Maybe a better approach would be to help DrRacket be better at keeping
> information from the last time the expansion was successful and apply that
> information to a program that has been edited since then?
>
> Robby
>
>
> On Wed, Dec 2, 2020 at 8:53 AM nicobao  wrote:
>
>> Hi!
>>
>> The Racket Reader and the Racket Expander always return "Error : blabla"
>> when you send it a bad Racket source code.
>> As a consequence, when there is a source code error, DrRacket and the
>> Racket LSP cannot provide IDE functionalities like "find references", "info
>> on hover", "find definition"...etc.
>> This is an issue, because 99% of the time one write code, the code is
>> incorrect. Other languages (Rust, Typescript/JS, Java, OCaml...etc) rely on
>> an incremental parser than can provide a tree even if the source code is
>> wrong. Basically it adds an "ERROR" node in the tree, and go on instead of
>> stopping everything and returning at the first error.
>> Currently this compiler issue is blocking the Racket IDE to provide
>> better user experience.
>> For my practical use case of Racket, it is important.
>>
>> I would like to help working towards that direction.
>> I see two possible solutions to that:
>> 1) improve the recursive descent parser of the Reader, as well as the
>> Expander to make them incremental and fault-tolerant
>> 2) re-writing the parser in something like tree-sitter or Menhir, at the
>> cost of having to re-write the Reader/Expander logic (!!!)
>>
>> Both solutions are daunting tasks.
>>
>> For solution 1), could you point me to the Racket's recursive descent
>> parser source code? What about the Expander ?
>>
>> For solution 2), I was thinking of writing a tree-sitter grammar for
>> racket. However, I can't find a formal description of the grammar, like
>> Scheme did here:
>> https://www.scheme.com/tspl4/grammar.html#APPENDIXFORMALSYNTAX
>> Of course, the Racket documentation is still quite comprehensive, but it
>> would be nice if anyone could tell me if there is such formal document
>> somewhere?
>> Besides, I wonder whether Racket/Scheme could even be described using a
>> LR(1) or a GLR grammar?
>>
>> Finally, is any work have been started towards this direction?
>>
>> Totally off-topic, but has anyone ever thought of compiling Racket down
>> to OCaml, in order to reuse js_of_ocaml and produce optimized JS code from
>> Racket?
>> I was wondering whether it would be feasible.
>>
>> Final note: I know all of that is _very_ ambitious!
>>
>> Kind regards,
>> Nicolas
>>
>> --
>> You received this message because you are 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/d77440e3-1876-44e5-b52b-323d5715df66n%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/CAL3TdOOB-8qUncNcRz_NFqvQVEK5rT5jeRY8jfq1W6mN2h40eg%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/CADcueguEB9nkXoVrZ%3D-DyqqPnKLQmbwqudHY5OfOS0P8v53Kkw%40mail.gmail.com.


Re: [racket-users] Rosette: can it help me

2020-11-26 Thread Sorawee Porncharoenwase
You are doing a recursion on a symbolic value, which is a common pitfall in
Rosette.

See slide 81
 and
subsequent slides for more details. Slide 87 shows a solution to this
problem.

On Thu, Nov 26, 2020 at 1:12 PM Bertrand Augereau <
bertrand.auger...@gmail.com> wrote:

> Hello everybody,
>
> not sure if this is the good place to ask about this but I couldn't
> find a good location so I'm asking for help here, after all it's
> strongly connected to Racket :)
>
> I'm trying to reverse-engineer some specific piece of hardware with
> the help of Rosette, to discover if it can help or not. In the long
> run I want it to help me find magic numbers for a specific routine to
> match captures of the hardware output (can't say more about this
> though).
>
> After dumbing down (a lot) my first tries, I'm having issues with this
> code running endlessly:
> #lang rosette/safe
>
> (define (zero-a x) 0)
> (define (zero-b x)
>   (if (= x 0) 0 (zero-b (- x 1
>
> (define-symbolic x integer?)
> (assert (>= x 0))
> (assert (<= x 10))
>
> (verify (assert (= (zero-a x) (zero-b x
>
> I don't have a strong theoretical understanding of what Rosette can
> and cannot do, but I thought that by restraining the range with the
> asserts, at least I'd get a brute force search of the solution space,
> which should be fast.
> Does it make sense ? Can somebody explain me where is my misunderstanding ?
>
> Thank you folks,
> Bertrand
>
> --
> You received this message because you are 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/CAHV%3D05otPXjbrEaHWvJF-SeDSxz2-Mjq3p%3DSHR3HvuJRAJJ3-A%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/CADcuegvopDTOWr2V4xf7gWPMVMiNSJbabiE5r48aYycg6iqRoQ%40mail.gmail.com.


Re: [racket-users] Passing keywords from a list

2020-11-26 Thread Sorawee Porncharoenwase
If you are OK with preprocessing the argument list into a dictionary, then
you can use keyword-apply/dict

.

For example:

#lang racket

(require racket/dict)

(define proc (lambda (#:color color #:size size) (display (cons color size
(define args '(#:color "red" #:size 3))
(define args*
  (for/hash ([chunk (in-slice 2 args)])
(values (first chunk) (second chunk

(keyword-apply/dict proc args* '())


On Thu, Nov 26, 2020 at 12:53 AM Dimaugh Silvestris <
dimaughsilvest...@gmail.com> wrote:

> Is it possible to reproduce this behavior
> ((lambda (#:color color #:size size) (display (cons color size))) #:color
> "red" #:size 3)
> when what I have is a list such as '(#:color "red" #:size 3) ?
> How can I feed keyword arguments stored in a list as symbols in a way that
> doesn't involve parsing manually?
>
> --
> You received this message because you are 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/06a1b45b-77ca-4595-b5b6-0b4ce01fe026n%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/CADcuegtRx--ZTxg0sNGb3475Pqb9vw_Hun%2BNp-A76SO8xGg1nQ%40mail.gmail.com.


Re: [racket-users] Macros expanding to require forms

2020-11-12 Thread Sorawee Porncharoenwase
See
https://docs.racket-lang.org/reference/stxtrans.html#%28def._%28%28quote._~23~25kernel%29._syntax-local-introduce%29%29
for
an example program that requires a library via a macro.

On Thu, Nov 12, 2020 at 3:09 AM Veit Heller  wrote:

>
> Hello,
>
> I’m suspecting I’m getting a little turned around by phase levels and
> where `require` comes in: it seems to be impossible to write a macro that
> expands to a valid `require` (it doesn’t throw an error, but the functions
> aren’t defined either). What am I missing? At what phase level does
> `require` do its magic? And can I tap into this magic from within a macro?
>
> An example to illustrate my point:
>
> ```
> (define-syntax require-distributed ()
>   ((_)
> (require racket/place/distributed))) ; could be anything, really
> (require-distributed) ; expands and runs fine, but no symbols :(
> ```
>
> I know that this is somewhat of an odd thing to want, and I understand if
> it’s not possible.
>
> V
>
> --
> You received this message because you are 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/a49ab428-ae49-45ce-9d16-8a77d27f5a85n%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/CADcuegsm45NnAdw-yAqNUPKnytasXuvV0yoNQiW6cb-xu43tVw%40mail.gmail.com.


Re: [racket-users] cross-module `error` changed?

2020-11-06 Thread Sorawee Porncharoenwase
This is the same problem as https://github.com/racket/racket/issues/3355.
It's already been fixed in Racket 7.9.

On Fri, Nov 6, 2020 at 5:30 AM Shriram Krishnamurthi 
wrote:

> Has something changed in how `error` works across modules? This code that
> I used last year without trouble seems to run into trouble now.
>
> Here's the code all in one module:
>
> #lang racket
>
> (provide yield resume)
>
> (define resumer #f)
>
> (define (yield)
>   (let/cc k
> (set! resumer k)
> (error 'yield "yielding computation")))
>
> (define (resume)
>   (resumer 'dummy))
>
> (define (fact n)
>   (if (= n 0)
>   1
>   (begin
> (when (= (remainder n 10) 0)
>   (yield))
> (* n (fact (- n 1))
>
> It results in the following (desired) interaction:
>
> > (fact 10)
> . . yield: yielding computation
> > (resume)
> 3628800
>
> But now I'm going to remove the definition of `fact` and put it in another
> module, saving the remainder as `yielder.rkt`:
>
> #lang racket
>
> (require "yielder.rkt")
>
> (define (fact n)
>   (if (= n 0)
>   1
>   (begin
> (when (= (remainder n 10) 0)
>   (yield))
> (* n (fact (- n 1))
>
> Now I get the following error. What should I be doing instead?
>
> > (fact 10)
> -- #(struct:exn:fail:contract "vector-ref: contract violation\n
> expected: vector?\n  given: '((error 'yield \"yielding computation\")
> # 10 4 113 37)\n  argument position:
> 1st\n  other arguments...:\n   0" #)
>   (errortrace-stack-item->srcloc . #(struct:srcloc
> # v7.8/share/pkgs/drracket/drracket/private/stack-checkpoint.rkt> 168 0 6297
> 203))
>   (pick-first-defs . #(struct:srcloc # v7.8/share/pkgs/drracket/drracket/private/stack-checkpoint.rkt> 331 0 13000
> 425))
>   (get-exn-source-locs . #(struct:srcloc # v7.8/share/pkgs/drracket/drracket/private/stack-checkpoint.rkt> 585 0 23184
> 391))
>   (#f . #(struct:srcloc # v7.8/collects/racket/contract/private/arrow-val-first.rkt> 486 18 20735 32))
>   (error-display-handler/stacktrace . #(struct:srcloc
> # v7.8/share/pkgs/drracket/drracket/private/debug.rkt> 362 2 15076 2612))
>   (call-with-exception-handler . #(struct:srcloc
> #
> 266 2 9251 256))
>   (fact . #(struct:srcloc # 5 0 40 139))
>   (eval-one-top . #f)
>   (call-with-exception-handler . #(struct:srcloc
> #
> 266 2 9251 256))
>   (loop . #(struct:srcloc # v7.8/share/pkgs/drracket/drracket/private/rep.rkt> 1210 24 50804 979))
>   (call-with-break-parameterization . #(struct:srcloc
> #
> 148 2 4909 517))
>   (#f . #(struct:srcloc # v7.8/share/pkgs/drracket/drracket/private/rep.rkt> 1180 9 49153 5062))
>   (#f . #(struct:srcloc # v7.8/share/pkgs/drracket/drracket/private/rep.rkt> 1493 15 64385 1548))
>   (#f . #(struct:srcloc # v7.8/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt> 435 6 19067 1056))
>   (#f . #(struct:srcloc # v7.8/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt> 486 32 21054 120))
>   (call-with-break-parameterization . #(struct:srcloc
> #
> 148 2 4909 517))
>   (eventspace-handler-thread-proc . #(struct:srcloc
> # v7.8/share/pkgs/gui-lib/mred/private/wx/common/queue.rkt> 370 11 16515 690))
> exception raised by error display handler: vector-ref: contract violation
>   expected: vector?
>   given: '((error 'yield "yielding computation")
> # 10 4 113 37)
>   argument position: 1st
>   other arguments...:
>0; original exception raised: yield: yielding computation
>
> --
> You received this message because you are 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/6aa1ad8a-9f1a-4c11-8b75-5ed3ca09797dn%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/CADcueguC-yYNcqx13JA_zqEopn_fzUX%2BzFPq_L3NnDvgK1xMNA%40mail.gmail.com.


Re: [racket-users] bf program benchmark

2020-11-04 Thread Sorawee Porncharoenwase
You might want to take a look at Danny’s original bf article
, which includes optimizations.
By the end of the article, he reduces the running time of one benchmark
program from “thirty-seven seconds to just over one”.

On Wed, Nov 4, 2020 at 1:40 AM sleepnova  wrote:

> I'm benchmarking the bf language implementation[1] take from Beautiful
> Racket with mandelbrot.bf example[2].
>
> I slightly modified the expander to gain performance.[3]
>
> And it took about 72s to finish.
>
> Then I try to benchmark the same program in a Java implementation which I
> implemented years ago. A simple bf runner simply translate bf program to
> JVM byte-code and run.
>
> It took about 27s.
>
> Is there any way to improve the performance of the Racket implementation
> to make it close to Java one? Any tip and trick to help the Racket VM
> generate more efficient code?
>
> [1] https://beautifulracket.com/bf/an-imperative-expander.html
> [2]
> https://github.com/herrjemand/BFNutshell/blob/nutshell/samples/mandelbrot.bf
> [3] https://gist.github.com/sleepnova/637bdf1b04df963286f6c0a837d51fc5
> [4] https://code.google.com/archive/p/bfj/
>
> --
> - sleepnova
> Founder of FindTaxi
>
> --
> You received this message because you are 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-7OFLh8YUfXvTNFe%2BmJ%3Dyb5rw0hB2KU8_ojCjVmvVbEQ7A%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/CADcueguGLUJubjADJxRZGFv391E_rt2V%2BC_BULgNr8G8yjPMaw%40mail.gmail.com.


Re: [racket-users] Should I enter racket questions here: https://groups.google.com/g/racket-users

2020-11-01 Thread Sorawee Porncharoenwase
You can certainly ask questions here, but please keep in mind that it is
also a mailing list. If you have many related questions, it would be nice
to create only one thread to ask all related questions, to avoid spamming
emails to the mailing list recipients.

Another place to ask questions is Slack channel (sign up at
https://racket-slack.herokuapp.com/, visit the channel at
https://racket.slack.com/). Slack has a chat interface, so it might be more
suitable for several short questions.

On Sun, Nov 1, 2020 at 1:11 PM infodeveloperdon 
wrote:

>
> Should I enter racket questions here:
> https://groups.google.com/g/racket-users
>
> --
> You received this message because you are 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/8ebd713e-eb8f-422d-80d9-2c7b3edb55dbn%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/CADcuegv1d3WiZ98qn%2BKFk43aFpg5CeWa8JvTjkE_g%2B51HFqYxA%40mail.gmail.com.


Re: [racket-users] [racket users] Pollen tag question

2020-10-29 Thread Sorawee Porncharoenwase
Whoops. I meant:

#lang pollen

◊(define (vb . s) s)

◊vb{ A B
   C D}

and the output is:

'(" A B" "\n" "   " "C D")


On Thu, Oct 29, 2020 at 9:19 PM Sorawee Porncharoenwase <
sorawee.pw...@gmail.com> wrote:

> I think the issue is with vb. How does it work?
>
> If you try
>
> #lang pollen
>
> @(define (vb . s) s)
>
> ◊vb{ A B
>C D}
>
> you will find that it outputs:
>
> '(vb " A B"
>  "\n"
>  "   "
>  "C D")
>
> The third element is the space before “C”. It's not discarded.
>
> Also notice that the "start" of the line is at the marker shown below
>
> #lang pollen
>
> @(define (vb . s) s)
>
> ◊vb{ A B
>  >>>   C D}
>
> This is due to how @ syntax
> <https://docs.racket-lang.org/scribble/reader.html#%28part._.Spaces__.Newlines__and_.Indentation%29>
> works.
>
> On Thu, Oct 29, 2020 at 9:04 PM Kevin Forchione  wrote:
>
>> Hi guys,
>> I’ve noticed that the elements being sent to a pollen tag don’t preserve
>> the spacing when the text spans multiple lines for any space occurring
>> before characters on the subsequent line, although does preserve the
>> spacing between characters on that line.Is thes intentional?
>>
>> For example: Racket 7.8 [cs], latest pollen version:
>>
>> ◊vb{ A B
>>  C D}
>>
>> Regardless of how many spaces are before the C, the tag elements will
>> only return a single space, although it preserves the spacing between C and
>> D.
>>
>> Is that the expected result? It seems counter intuitive, as the spacing
>> before A is preserved.
>>
>> 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/2ECCF698-BD5D-4421-B28A-EC74471715B6%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/CADcuegsM3io_ZuY9pR8yOcf-UtGS4r57gYSn3R-OTJS1xEW23A%40mail.gmail.com.


Re: [racket-users] [racket users] Pollen tag question

2020-10-29 Thread Sorawee Porncharoenwase
I think the issue is with vb. How does it work?

If you try

#lang pollen

@(define (vb . s) s)

◊vb{ A B
   C D}

you will find that it outputs:

'(vb " A B"
 "\n"
 "   "
 "C D")

The third element is the space before “C”. It's not discarded.

Also notice that the "start" of the line is at the marker shown below

#lang pollen

@(define (vb . s) s)

◊vb{ A B
 >>>   C D}

This is due to how @ syntax

works.

On Thu, Oct 29, 2020 at 9:04 PM Kevin Forchione  wrote:

> Hi guys,
> I’ve noticed that the elements being sent to a pollen tag don’t preserve
> the spacing when the text spans multiple lines for any space occurring
> before characters on the subsequent line, although does preserve the
> spacing between characters on that line.Is thes intentional?
>
> For example: Racket 7.8 [cs], latest pollen version:
>
> ◊vb{ A B
>  C D}
>
> Regardless of how many spaces are before the C, the tag elements will only
> return a single space, although it preserves the spacing between C and D.
>
> Is that the expected result? It seems counter intuitive, as the spacing
> before A is preserved.
>
> 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/2ECCF698-BD5D-4421-B28A-EC74471715B6%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/CADcuegsS6gmBndmQ-xjtKjN8L_E1JsVpU4NKrBO3Fhogr8gFxg%40mail.gmail.com.


Re: [racket-users] Why ~a, ~s, and ~v?

2020-10-26 Thread Sorawee Porncharoenwase
I had this question too. It looks like they are inherited from Scheme.

~a = any
~s = s-expression

See http://wiki.call-cc.org/eggref/5/format#documentation.

There's no ~v. IIUC, there's no `print` in Scheme.

On Mon, Oct 26, 2020 at 5:50 PM primer  wrote:

>
> I'm reading the documentation about formatted output where it says:
> ~a or ~A displays the next argument
> ~s or ~S writes the next argument
> ~v or ~V prints the next argument
>
> I can't help thinking these would be more intuitive if they were spelled
> ~d, ~w, and ~p.
>
> Perhaps I can remember them better if someone could explain where the
> letters come from.  Can anyone explain?
>
>
> --
> You received this message because you are 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/979731d3-0a48-484c-8269-f10a807fe6aan%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/CADcuegvoXQCZDCJhwZa9rfvJrfWWw6OfvMy9atpvpx2vggnJDA%40mail.gmail.com.


Re: [racket-users] [scribble] Are nested lists possible?

2020-10-13 Thread Sorawee Porncharoenwase
apparently it doesn’t like having an itemlist inside of a {} block at all

I’m not sure if I totally understand it, but this doesn’t appear to be
true. The below doc renders correctly as I expect.

#lang scribble/manual

@itemlist[
  @item{foo
@itemlist[
  @item{bar}
  @item{baz}]
hello
@itemlist[
  @item{world}]}
 @item{foo2
@itemlist[
  @item{bar2}
  @item{baz2}]
hello2
@itemlist[
  @item{world2}]}]


On Tue, Oct 13, 2020 at 10:09 AM David Storrs 
wrote:

> Okay, apparently it doesn't like having an itemlist inside of a {} block
> at all, but as long as it's outside of one then nested lists are fine.
> Ugh.  I know Scribble is super good because it makes beautiful
> documentation and does cross-linking and examples and all that, but it's
> also a complete pain in the ass unless you're expert with it.
>
> Sorry for wasting everyone's time.
>
> On Tue, Oct 13, 2020 at 1:02 PM David Storrs 
> wrote:
>
>> Argh.  Wrong code.  Please ignore prior message.
>>
>> On Tue, Oct 13, 2020 at 12:57 PM David Storrs 
>> wrote:
>>
>>>
>>>
>>> On Tue, Oct 13, 2020 at 12:48 PM Ben Greenman <
>>> benjaminlgreen...@gmail.com> wrote:
>>>
 On 10/13/20, David Storrs  wrote:
 > @itemlist[
 >   @item{The size cage needed depends on the type of dog
 >   @itemlist[
 > @item{Pug:  Small}
 > @item{Collie: Medium}
 > @item{Mastiff:  Large}]}]
 >
 > I would like to produce something that looks like this:
 >
 >- The size cage needed depends on the type of dog
 >   - Pug: Small
 >   - Collie: Medium
 >   - Mastiff: Large
 >
 > Is there a correct way to do this?

 What you have looks good to me in #lang scribble/manual


>>> Here's the actual code:
>>>
>>> @defproc[(trie-add-item+data! [arg trie?][item (listof any/c)][#:combine
>>> combine-method (or/c 'keep 'replace 'meld/current 'meld/new (-> trie-node?
>>> trie-node? trie-node?)) 'meld/new]) trie?]{Adds one item to the trie where
>>> the elements of the list are considered to be elements of the item.  If an
>>> item is a @racket[cons] pair where the @racket[cdr] is a
>>> @racket[trie-node?] then the @racket[car] will be used as the element and
>>> the @racket[cdr] will be the data attached to that node.  The final node is
>>> marked as terminal regardless of whether it already existed.
>>>
>>> If an element of the item already exists in the trie then that element
>>> will be updated based on the combine method specified via the
>>> @racket[#:combine] keyword.  Specifically:
>>>
>>> @itemlist[
>>> @item{test}
>>> ]
>>> }
>>>
>>> Here's the error output:
>>>
>>> trie.scrbl:165:0: item: misuse of an identifier (not in `racket', etc.)
>>> that is bound as a code-typesetting variable
>>>   in: (item "test")
>>>   location...:
>>>trie.scrbl:165:0
>>>   context...:
>>>do-raise-syntax-error
>>>apply-transformer-in-context
>>>apply-transformer
>>>dispatch-transformer
>>>for-loop
>>>[repeats 2 more times]
>>>finish-bodys
>>>lambda-clause-expander
>>>for-loop
>>>[repeats 1 more time]
>>>finish-bodys
>>>for-loop
>>>finish-bodys
>>>loop
>>>for-loop
>>>[repeats 3 more times]
>>>
>>>
>>> It works fine if I remove the inner @itemlist.  What should I do
>>> differently?
>>>
>>> --
 You received this message because you are 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/CAFUu9R4-4BO3Gi2PDxZ%3D2BbQCrJP4O%2BkAWT1f7DJJtFapFdYTA%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/CAE8gKocp9RQ0cV1OL1dAAH%2B4CevDVTfHvd8Xf5o%3DP5KGeUZwjg%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/CADcuegs-94OYHQi9JMx%2BsdqQdA2RM_Fg2sCLRxYQdLycJsvjcQ%40mail.gmail.com.


Re: [racket-users] Clearer code in DrRacket?

2020-10-10 Thread Sorawee Porncharoenwase
>
> Looks interesting. Do you know any package of this type for DrRacket (or
> another program) that works semantically while you program? (not just as a
> checking tool like View Syntax)
>

I think it would be difficult.

Racket has macros, and it allows shadowing on anything. The attached image
shows how `(if 1 2 3)` is colored differently by Check Syntax due to the
interaction with macros and shadowing.

[image: Screen Shot 2020-10-10 at 10.07.00.png]

To identify which context `(if 1 2 3)` is in, you need to macro-expand the
program and then analyze the expanded program (this is exactly what the
Check Syntax button does). However, macro expansion could be very
expensive. Syntax highlighting on the other hand is supposed to be very
cheap and done immediately as you edit the program. I believe this is why
DrRacket doesn't support syntax highlighting that you described.

If you are OK with a delay (you type something and it's colored, say, 10
seconds later), I think it's possible to use the result from the online
Check Syntax, which macro-expands your program continuously in the
background, to color the program.

-- 
You received this message because you are 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/CADcuegsmhJdts%3DmvtAAOk%2B1uQ13o_2dTSQEKMBKt0hLrHfVDVA%40mail.gmail.com.


Re: [racket-users] [racket users] scribble using @ as text?

2020-09-24 Thread Sorawee Porncharoenwase
I think you meant `@"@"`? `@["@"]` is an application.

On Thu, Sep 24, 2020 at 2:31 PM Jay McCarthy  wrote:

> @["@"]
>
> --
> Jay McCarthy
> Associate Professor @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> Vincit qui se vincit.
>
>
> On Thu, Sep 24, 2020 at 5:26 PM Kevin Forchione  wrote:
>
>> Hi guys,
>> I’ve been racking my brains and going through scribble manuals trying to
>> figure out how to do something as simple as proceed a sentence like: The @
>> is used in a scribble command. I’m sure I’m overlooking something very
>> basic, since the @ is referenced all over scribble documentation.
>>
>> Any help is appreciated!
>>
>> 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/8187F519-D648-472C-8B99-45B28DFD4BC0%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/CAJYbDa%3DhPr-cLA1-9t0oVdC2y1sGRa4RWh_UmOudzj%2BNHLAmSg%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/CADcuegsM2X8Q9bYFqu0hK3sc8bKPvEv4wiCtWaT%3DoxOoN75jTw%40mail.gmail.com.


Re: [racket-users] [racket users] scribble using @ as text?

2020-09-24 Thread Sorawee Porncharoenwase
See
https://docs.racket-lang.org/scribble/reader.html#%28part._.The_.Scribble_.Syntax_at_a_.Glance%29

On Thu, Sep 24, 2020 at 2:26 PM Kevin Forchione  wrote:

> Hi guys,
> I’ve been racking my brains and going through scribble manuals trying to
> figure out how to do something as simple as proceed a sentence like: The @
> is used in a scribble command. I’m sure I’m overlooking something very
> basic, since the @ is referenced all over scribble documentation.
>
> Any help is appreciated!
>
> 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/8187F519-D648-472C-8B99-45B28DFD4BC0%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/CADcuegsHZ_DOazYruMiB3Pjr%2Bjis4K4wvVQOAC4DntWZZRqeNQ%40mail.gmail.com.


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.


  1   2   >