[racket-users] Output out of order when using system procedure

2020-05-19 Thread Rock Nie
I am running the system procedure in drracket's interactive window
(system "test.py")

where test.py is
#!/home/utils/Python-3.8.0/bin/python3
import os

print("Running cmd: date1")
print("Running cmd: date2")
os.system("date")
print("Running cmd: date3")
os.system("date")

and the output is
Tue May 19 22:14:19 PDT 2020
Tue May 19 22:14:19 PDT 2020
Running cmd: date1
Running cmd: date2
Running cmd: date3
#t

which is different from my expectation, can anyone help explain why?

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


Re: [racket-users] Re: Is there an easy way to daemonize a thread?

2020-05-19 Thread David Storrs
Perfect, thank you.

On Tue, May 19, 2020 at 5:28 PM George Neuner  wrote:

> On Tue, 19 May 2020 12:01:54 -0400, David Storrs
>  wrote:
>
> >I'm using the file-watchers module to keep an eye on a directory tree and
> >trigger various actions whenever something changes.  I had an issue where
> >an exception was thrown, the thread died, and file watching therefore
> >stopped.  The immediate solution is to wrap a with-handlers around it so
> it
> >doesn't end up killing the thread, but this made me wonder if there's an
> >easy way to do this automatically?
> >
> >What I'm thinking of is "Create a thread that will do something in a loop.
> >Ensure that the thread remains running and restart it if it dies for any
> >reason.  Also, make sure that it runs periodically."  I can think of a
> >solution involving multiple threads, channels, and polling to ensure that
> >the 'daemonized' threads are running, but I was wondering if there's a
> >built-in or existing answer.
>
> There is a package called "thread-utils" which claims error safe
> looping threads.
> https://pkgs.racket-lang.org/package/thread-utils
>
> *Disclaimer*  I have never tried it.
>
>
> I can think of a some possible implementations, but they all involve
> monitoring by a separate thread (which could be the main thread).
> Channels aren't necessary - monitoring can be done using events.
>
> Restarting a (possibly failed) computation IN a running thread is
> relatively simple - if you know what errors or events might occur. The
> problem is that a thread can't restart itself if somehow it gets
> suspended or killed.
>
> 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/uvi8cftuuvfkq0cqm27m0icvhhq5mpupuo%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/CAE8gKodqJQs__Mj%3DFo9wY77eanS4ReNwrL0zKED1A4_FAFNqBQ%40mail.gmail.com.


[racket-users] Re: Is there an easy way to daemonize a thread?

2020-05-19 Thread George Neuner
On Tue, 19 May 2020 12:01:54 -0400, David Storrs
 wrote:

>I'm using the file-watchers module to keep an eye on a directory tree and
>trigger various actions whenever something changes.  I had an issue where
>an exception was thrown, the thread died, and file watching therefore
>stopped.  The immediate solution is to wrap a with-handlers around it so it
>doesn't end up killing the thread, but this made me wonder if there's an
>easy way to do this automatically?
>
>What I'm thinking of is "Create a thread that will do something in a loop.
>Ensure that the thread remains running and restart it if it dies for any
>reason.  Also, make sure that it runs periodically."  I can think of a
>solution involving multiple threads, channels, and polling to ensure that
>the 'daemonized' threads are running, but I was wondering if there's a
>built-in or existing answer.

There is a package called "thread-utils" which claims error safe
looping threads.
https://pkgs.racket-lang.org/package/thread-utils

*Disclaimer*  I have never tried it.


I can think of a some possible implementations, but they all involve
monitoring by a separate thread (which could be the main thread).
Channels aren't necessary - monitoring can be done using events.

Restarting a (possibly failed) computation IN a running thread is
relatively simple - if you know what errors or events might occur. The
problem is that a thread can't restart itself if somehow it gets
suspended or killed.

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/uvi8cftuuvfkq0cqm27m0icvhhq5mpupuo%404ax.com.


Re: [racket-users] How do I properly set current-module-name-resolver for a process?

2020-05-19 Thread Matthew Flatt
At Tue, 19 May 2020 20:10:01 +, Sage Gerard wrote:
> I'm trying to figure out how to set current-module-name-resolver in
> advance of all other code for a process. I'm guessing this would
> require a custom launcher that does (for example) `racket -l
> foo/replace-resolver bar.rkt`.

That can work if

 * you either add a `-t` before `bar.rkt` to load it or
   `foo/replace-resolver` handles command-line arguments; and

 * you don't need to adjust resolution for any modules that are used in
   the implementation of `foo/replace-resolver`.

> In that sense, I expect that a `replace-resolver` of the form below
> wouldn't work because it runs at phase 0, after the expander resolved
> everything for `bar.rkt`.

If you go the route of adding `-t` before `bar.rkt`, the resolution
will not happen until after `foo/replace-resolver` runs.

> How do I do what I mean here across all phases, for all uses of 
> (dynamic-|local-)require everywhere in my program?

If you set the module name resolver, it applies to all phases.

(That's a hole in Racket's phase separation, and we don't like to talk
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/20200519144945.17d%40sirmail.smtp.cs.utah.edu.


[racket-users] How do I properly set current-module-name-resolver for a process?

2020-05-19 Thread Sage Gerard
I'm trying to figure out how to set current-module-name-resolver in advance of 
all other code for a process. I'm guessing this would require a custom launcher 
that does (for example) `racket -l foo/replace-resolver bar.rkt`.

In that sense, I expect that a `replace-resolver` of the form below wouldn't 
work because it runs at phase 0, after the expander resolved everything for 
`bar.rkt`.

How do I do what I mean here across all phases, for all uses of 
(dynamic-|local-)require everywhere in my program?

(let ([old (current-module-name-resolver)])

  (current-module-name-resolver

   (case-lambda

 [(declared-module-name src-namespace)

  (old declared-module-name src-namespace)]

 [(module-path source-module stx should-load?)

  (old (maybe-rewrite-module-path module-path source-module)

   source-module

   stx

   should-load?)

  r])))

~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/_cvEcFutv9gqlkwOX38uKhLoY-7MWpo24yP9DQLV-ml9bRLjiCG1aZmmIj5p3zeYxjyfPt0f65dei4MJcSUsuWX5lDcBSsO6QEW2wBlvFzI%3D%40sagegerard.com.


Re: [racket-users] running Racket inside gradescope

2020-05-19 Thread 'John Clements' via Racket Users
100% yes but no. I am a long-time gradescope user, and I’ve been very happy 
with it. However, my usage has been entirely with scanned paper exams. I like 
the work that Gradescope has been doing, but I haven’t engaged with any of 
their tools beyond the paper-scanning ones, so I definitely don’t have anything 
to contribute to your work beyond tips on how best to use a paper cutter to 
remove staples from student exams. Also, the last time I checked, their 
“complete” tier was a bit rich for my blood; I would have to find a way to get 
the students to pay for it themselves if I were to seriously consider it.

John



> On May 19, 2020, at 11:42 AM, Shriram Krishnamurthi  wrote:
> 
> We expect to use Racket with Gradescope [https://www.gradescope.com/] in the 
> fall. Gradescope will run an autograder for programming assignments, using 
> this specification:
> 
> https://gradescope-autograders.readthedocs.io/en/latest/
> 
> (It's manifest as a Docker container.)
> 
> Has anyone already set up Gradescope for use in their classes? 
> 
> If so, can you share your work with us?
> 
> If not, are you a potential user?
> 
> 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/24255ddf-7b2e-4563-a45a-92ff5fa07e6c%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/94c9ceaf-fc9d-4f48-b9ea-0f87994b4232%40mtasv.net.


[racket-users] Re: What does PLT stand for?

2020-05-19 Thread Shriram Krishnamurthi
Originally it was the Programming Languages Theory group at Rice University.

Then, around the time of creation of Racket, the team branched out beyond 
Theory, so we decided the T might stand also for Technology, Tools, etc.

Eventually we decided it just stood for Programming Languages Team.

Then we branched out of Rice, and created local PLT groups. By then, PLT 
had ceased to mean anything specific at all: all those child PLTs were in 
homage to the original one of that name.

These days, "PLT" seems to be widely used on the interwebs to mean 
"programming language theory" in a generic sense (not tied to any 
particular group), which I still find jarring. But many of us still call 
our groups PLT (https://www2.ccs.neu.edu/racket/, 
https://plt.eecs.northwestern.edu/, https://www.cs.utah.edu/plt/, 
https://cs.brown.edu/research/plt/, etc.).

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/022f8113-2b65-4c0f-b1f1-a058415cda24%40googlegroups.com.


[racket-users] running Racket inside gradescope

2020-05-19 Thread Shriram Krishnamurthi
We expect to use Racket with Gradescope [https://www.gradescope.com/] in 
the fall. Gradescope will run an autograder for programming assignments, 
using this specification:

https://gradescope-autograders.readthedocs.io/en/latest/

(It's manifest as a Docker container.)

Has anyone already set up Gradescope for use in their classes? 

If so, can you share your work with us?

If not, are you a potential user?

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/24255ddf-7b2e-4563-a45a-92ff5fa07e6c%40googlegroups.com.


[racket-users] Circuits

2020-05-19 Thread Jos Koot
Hi
Just for a hobby I made a syntax producing procedures that emulate simple 
electronic circuits.
But certainly there already are many more sophisticated systems that perform 
this task.
I did not find them with google.
I would appreciate very much some pointers to such procedures
(preferably in Racket or in a Scheme like or Lisp like language).
Best wishes for all, Jos Koot

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/5ec4112a.1c69fb81.80de.207d%40mx.google.com.


[racket-users] Is there an easy way to daemonize a thread?

2020-05-19 Thread David Storrs
I'm using the file-watchers module to keep an eye on a directory tree and
trigger various actions whenever something changes.  I had an issue where
an exception was thrown, the thread died, and file watching therefore
stopped.  The immediate solution is to wrap a with-handlers around it so it
doesn't end up killing the thread, but this made me wonder if there's an
easy way to do this automatically?

What I'm thinking of is "Create a thread that will do something in a loop.
Ensure that the thread remains running and restart it if it dies for any
reason.  Also, make sure that it runs periodically."  I can think of a
solution involving multiple threads, channels, and polling to ensure that
the 'daemonized' threads are running, but I was wondering if there's a
built-in or existing answer.

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


Re: [racket-users] What does PLT stand for?

2020-05-19 Thread Gary Schiltz
Thanks, that makes sense. Google search turned up "Persistent Lookup Table" 
(Erlang) and "Pretty Little Thing, and my quazi-dislexic brain at first 
turned it into PTL with even more stranger connotations :-)  I seem to have 
read somewhere that it might even have some sort of permutation of the 
latter. Maybe some questions are best left unanswered.

On Monday, May 18, 2020 at 9:50:19 AM UTC-5, Geoffrey Teale wrote:
>
> I believe it stands for "Programming Languages Team" - there was/is a 
> cross-university research group of that name.
> -- 
> Geoff 
>
> On Mon, 18 May 2020 at 16:12, Gary Schiltz  > wrote:
>
>> I thought it would be easy to find the answer to this (unimportant) 
>> question, but I haven't found one yet. Like a song I can't get out of my 
>> head, I keep looking, so please help satisfy my curiosity...
>>
>> -- 
>> You received this message because you are 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/261d24f6-ec53-4afb-85cf-60e75bd04909%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/ebe890fb-1fbe-4a44-a12b-a7d49797760a%40googlegroups.com.


Re: [racket-users] Inference for polymorphic functions not supported?

2020-05-19 Thread Hendrik Boom
On Mon, May 18, 2020 at 04:51:26PM -0400, Sam Tobin-Hochstadt wrote:
> The systematic way to do it is to use `inst`.
> 
> Here's the first example:
> 
> (define hash-list : (Listof (Pair Symbol Natural)) (list))
> ((inst sort (Pair Symbol Natural) String) hash-list string ((p : (Pair Symbol Natural))) (symbol->string (car p))) #:cache-keys?
> #t)
> 
> This program works already, but I wasn't sure what the `y` binding was
> doing in your second example:
> 
> (for*/list : (Listof (Pair Symbol Natural)) ((p : (Pair Symbol
> Natural) (in-list hash-list))
>  (k : Symbol (in-value (car p)))
>  (v : Natural (in-value (cdr p)))
>  #:when (not (= v 1))
>  )
>   (cons k v))

I got this second example to work, but it's still a black art to me.

 (printf "~s~%"
`(define pname-map (hasheqv
 ,@(for*/list : (Listof (List Symbol Natural))
 ((p  : (Pair Symbol Natural)(in-list 
(hash->sorted-list pname-map)))
  (k : Symbol (in-value (car p)))
  (v : Natural (in-value (cdr p)))
  #:when (not (= v 1))
  )
 (list k v) ; TODO: I changed this; 
original used a temporary variable 'y'.
 

I really had to get rid of the y variable.  Even providing an explicit type for 
that 
variable did not work.

It kept complaining about the overloaded function 'cons'.

Presumably I'd have to use inst on the 'cons' function to clear this up 
comprehensibly, 
but 'cons' does not appear explicitly in the code at all.

It's probably embedded in the code generated by quasiquote.  The 'inst' tril 
doesn't 
work very well on code generated by a macro when the macro itself doesn't 
generate 
'inst's.

I do not understand how eliminating the temporary variably 'y' made it all work.

-- hendrik

> 
> Sam
> 
> On Mon, May 18, 2020 at 4:33 PM Hendrik Boom  wrote:
> >
> > I keep getting the messages like
> >
> > Type Checker: Inference for polymorphic keyword functions not supported in: 
> > (sort hash-list string > (symbol->string (car p))) #:cache-keys? #t)
> >
> > or
> >
> > Type Checker: Polymorphic function `cons' could not be applied to arguments:
> > Types: a (Listof a) -> (Listof a)
> >a b -> (Pairof a b)
> > Arguments: (U Exact-Nonnegative-Integer Symbol) (Listof (Pairof Symbol 
> > Nonnegative-Integer))
> > Expected result: (Listof (Pairof Symbol Nonnegative-Integer))
> >  in: (for*/list : (Listof (Pair Symbol Natural)) ((p : (Pair Symbol 
> > Natural) (in-list (hash->sorted-list pname-map))) (k : Symbol (in-value 
> > (car p))) (v : Natural (in-value (cdr p))) #:when (not (= v 1)) (y (list k 
> > v))) y)
> >
> > Is there some systematic way to code this explicitly so it
> > doesn't have to try guesswork? (hich it refuses to do)
> >
> > And is it really unable to figure out that an
> > Exact-Nonnegative-Integer is a Nonnegative-Integer?
> >
> > -- 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/20200518203342.4vcvrsrvkmld4tmh%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/20200519105800.gwojekkthcexivbz%40topoi.pooq.com.