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

2021-10-02 Thread George Neuner



On 10/2/2021 7: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? --


Is the loop doing something else while it waits?  If not, you might as 
well use  filesystem-change-evt.


A polling loop /may/ respond faster than waiting on an event, but at the 
level of user applications that is /not/ guaranteed.  Is there some 
reason you (think you) need to respond very quickly when the file is 
created?


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/4eef5249-c55b-6585-f04a-3cd947d26a27%40comcast.net.


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] Looking to trigger the end of a loop by the creation of a file.

2021-10-02 Thread Don Green
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.


Re: [racket-users] Racket virtual meet-up in 50 minutes (8pm UTC) TODAY

2021-10-02 Thread Stephen De Gabrielle
Thank you to everyone who joined us today

I’m looking forward to seeing more of you at the next meet-up:

When: *First Saturday EVERY Month UTC: 20:00* (30 minutes but can overrun)
Calendar: Google

 , iCal


Where: https://gather.town/app/wH1EDG3McffLjrs0/racket-users

The link is free for all - so if you want to organise a meet-up at a time
that is better for your time zone please feel free!

stephen



On Sat, 2 Oct 2021 at 20:09, Stephen De Gabrielle 
wrote:

> All welcome
>
> starts in a little over 50 minutes
>
> Where: https://gather.town/app/wH1EDG3McffLjrs0/racket-users
>
> When: *First Saturday EVERY Month UTC: 20:00* (30 minutes but can overrun)
> Calendar: Google
> 
>  , iCal
> 
>
> stephen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/c97247c2-f989-44dc-a465-e65f847495ean%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/CAGHj7-J%2BaBGyq5pDHVcUoHOgiGCfN9uvCwuvCbWJg4U8yK-hCw%40mail.gmail.com.


Re: [racket-users] Re: Escape continuations for fussy code

2021-10-02 Thread jackh...@gmail.com
Here's my solution:

(define/guard (f x)
  (guard (foo? x) else
#false)
  (define y (bar x))
  (define z (jazz x y))
  (guard (loopy? z) else
#false)
  (define a (yowza z))
  (guard (string? a) else
(error 'ugh))
  (define b (bonkers a))
  (guard (number? (hoop x b)) else
(error 'um))
  (define ...))

It uses a `guard` macro I wrote and talked about in this thread 
.
On Friday, October 1, 2021 at 12:53:25 PM UTC-7 hen...@topoi.pooq.com wrote:

> On Fri, Oct 01, 2021 at 02:32:52PM -0400, David Storrs wrote:
> > On Fri, Oct 1, 2021 at 11:58 AM Hendrik Boom  
> wrote:
> > 
> > > On Fri, Oct 01, 2021 at 02:22:14PM +, Jesse Alama wrote:
> > > > Hello,
> > > >
> > > > Have you ever wished you could do a C-style return in the middle
> > > > of a block of Racket code? When you're in the heat of things with
> > > > a complicated problem where input values need a fair amount of
> > > > multi-stage extraction and validation, using cond quickly pulls
> > > > code to the right. My procedure is:
> > > >
> > > > * cond/case. In each branch:
> > > > * Define some new values safe in the knowledge of where you are
> > > > (extract) and perhaps check them, if necessasry (validate)
> > > > * Make sure you have an else branch.
> > > > * return to 1 and repeat as many times as necessary.
> > > >
> > > > The result:
> > > >
> > > > (cond [(foo? x)
> > > > (define y (bar x))
> > > > (define z (jazz x y))
> > > > (cond [(loopy? z)
> > > > (define a (yowza z))
> > > > (cond [(string? a)
> > > > (define b (bonkers a))
> > > > (cond [(number? (hoop x b))
> > > > (define ...)]
> > > > [else
> > > > (error 'um)])]
> > > > [else
> > > > (error 'ugh)])]
> > > > [else #f])]
> > > > [else #f])
> > >
> > >
> > I'm presuming that this code should either return #f, return a calculated
> > value, or raise an exception. If so, here's a version that runs in plain
> > racket that I find pretty easy to read. It has the advantage that the
> > 'return #f' parts aren't way far away from what causes them.
> > 
> > (with-handlers ([false? identity] ; return #f
> > [any/c raise]) ; re-raise everything else
> > (let* ([x (if (foo? x)
> > x
> > (raise #f))]
> > [z (jazz x (bar x))]
> > [a (if (loopy? z)
> > (yowza z)
> > (raise #f))]
> > [b (if (string? a)
> > (bonkers a)
> > (error 'ugh))])
> > (if (number? (hoop x b))
> > 'all-good
> > (error 'um
>
> Yes. But different semantics if bar, yowza, and bonkers have side effects.
> If they don't, they're quite equivalent.
>
> -- hendrik
>
> > 
> > If instead you want to return the exn that comes from error instead of
> > re-raising it then you can do that by removing the false? clause from the
> > with-handlers. NOTE: You should re-raise exn:break since otherwise the
> > user cannot ^C the program.
> > 
> > (with-handlers ([exn:break? raise]
> > [any/c identity])
> > ...put the let* code here...)
> > 
> > -- 
> > You received this message because you are subscribed 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/CAE8gKodxas7jtze%2BttcFA%2BG0ATKUFZD3rhK%2B%3Dn2U1md1zQPJSg%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/262c0b9d-6d51-4e03-adcf-0efa3fb76f61n%40googlegroups.com.


[racket-users] Racket virtual meet-up in 50 minutes (8pm UTC) TODAY

2021-10-02 Thread Stephen De Gabrielle
All welcome

starts in a little over 50 minutes

Where: https://gather.town/app/wH1EDG3McffLjrs0/racket-users

When: *First Saturday EVERY Month UTC: 20:00* (30 minutes but can overrun)
Calendar: Google 

 , iCal 


stephen 

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


Re: [racket-users] Racket meeting tomorrow?

2021-10-02 Thread Stephen De Gabrielle
All welcome

starts in a little over 50 minutes

Where: https://gather.town/app/wH1EDG3McffLjrs0/racket-users

When: *First Saturday EVERY Month UTC: 20:00* (30 minutes but can overrun)
Calendar: Google 

 , iCal 


stephen 


On Friday, October 1, 2021 at 8:56:08 PM UTC+1 hen...@topoi.pooq.com wrote:

> On Fri, Oct 01, 2021 at 12:31:27PM -0700, Sam Phillips wrote:
> > October 2, 2021
> > 1 PM PDT
> > 4 PM EDT
> > 8 PM UTC
> > 10 PM CEST
> > 
> > Should be the same URL as previous meetups.
> > 
> > https://gather.town/app/wH1EDG3McffLjrs0/racket-users
>
> I'll try to be there even though I haven't been doing much Racketting 
> lately.
> I didn't see it announced in Racket News, so I asked.
>
> -- hendrik
>
> > 
> > Cheers,
> > Sam
> > 
> > On Fri, Oct 1, 2021 at 9:49 AM Hendrik Boom  
> wrote:
> > >
> > > Is there going to be a Racket online meeting at the gather site 
> tomorrow
> > > on October 2? There have been on previous
> > > first-Saturdays-in-the-month.If so, at what time, and what's the URL?
> > >
> > > -- 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...@googlegroups.com.
> > > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/20211001164939.xrugfg7xlkj4pmfo%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...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAHsjV0z50cCKJ8FkvG2fz%2BDnQ34CuWj6R1ML2_d80VmvEYG2eQ%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/999f48dc-e6b3-4171-9821-e1387691cfd8n%40googlegroups.com.