[racket-users] matching M-N instances

2020-09-13 Thread David Storrs
Using the 'match' form, is there a straightforward way to have optional
items in a pattern?  For example:

(match records [(list (? string? name) 0..1  phone-numbers ..1) 'ok])

This would match a list of phone numbers that might or might not have the
owner's name (either as a single string or as two strings) on the front.

I know that I could do it with an 'or' pattern, or by having multiple
clauses in the match, but those get repetitive and verbose when part of the
pattern is a struct* used for decomposing multiple fields of a (potentially
nested) struct, which is a thing I do a lot.

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


Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-03 Thread David Storrs
For the record, a self-plug:

#lang racket

(require struct-plus-plus)

(struct foo-guard (bar baz)
  #:guard (struct-guard/c any/c list?))


(struct/contract foo-contract ([bar any/c]
   [baz list?]))

(struct++ foo-spp  ([bar any/c]
[baz list?]))

(display "#:guard: ")

(time
 (for ([i 100])
   (foo-guard 'yeah '(buddy

(display "struct/contract: ")
(time
 (for ([i 100])
   (foo-contract 'yeah '(buddy

(display "struct++:")
(time
 (for ([i 100])
   (foo-spp++ #:bar 'yeah #:baz '(buddy

#:guard: cpu time: 3335 real time: 3361 gc time: 90
struct/contract: cpu time: 217 real time: 218 gc time: 3
struct++:cpu time: 1255 real time: 1262 gc time: 23

The struct++ version is slower at creation but gives you more security
guarantees later on in the form of functional setters, business rules, and
wrapper functions to normalize data.  For example:


; This accepts a symbol or string and forces it to string.

(struct++ baz-spp ([foo (or/c symbol? string?) ~a]) #:transparent)
(display "Result: ") (println (baz-spp++ #:foo 'bob))
Result: (baz-spp "bob")

; Any struct++ struct will throw an exception if given invalid data

(struct++ bar-spp ([foo integer?]))
(display "Throws: ") (bar-spp++ #:foo 'bob)
Throws:
; bar-spp++: contract violation

;   expected: integer?

;   given: 'bob

;   in: the #:foo argument of

;   (-> #:foo integer? bar-spp?)

;   contract from: (function bar-spp++)

;   blaming: /Users/dstorrs/bmtc_dev/app/test.rkt

;(assuming the contract is correct)

;   at: /Users/dstorrs/bmtc_dev/app/test.rkt

; Context:

;  "/Users/dstorrs/bmtc_dev/app/test.rkt":1:1 [running body]



; Example of more heavily verified struct.  It will accept a string or

; symbol for name and force it to string.  It will round the age down

; so it shows only years. It will default the 'gender' field to the

; symbol 'unknown.  It will make a database connection and verify that

; the department ID is valid.  (In practice you would want to check

; this against an in-RAM table instead of going to disk.)
;
(define (dbh) "mock function that should return a database handle")

(struct++ person ([name (or/c symbol? string?) ~a]
  [age  positive? (compose inexact->exact floor)]
  [(gender 'unknown) (or/c 'male 'female 'other 'unknown)]
  [user-id exact-positive-integer?])
  (#:rule ("department-id exists in the database"
   #:check (user-id)
   [(not (null? (query-rows (dbh) ; get database handle

"SELECT id FROM users WHERE
id=$1"
user-id)))]))
  #:transparent)
(display "Result: ")(println (person++ #:name 'bob #:age 18.5 #:user-id 2))

Result: (person "bob" 18 'unknown 2)

It also provides reflection, functional setters (dotted and dashed
versions), transformation rules, and other things.
https://docs.racket-lang.org/struct-plus-plus/index.html





On Wed, Sep 2, 2020 at 10:43 PM Christopher Lemmer Webber <
cweb...@dustycloud.org> wrote:

> Philip McGrath writes:
>
> > On Wed, Sep 2, 2020 at 3:41 PM Christopher Lemmer Webber <
> > cweb...@dustycloud.org> wrote:
> >
> >> Unfortunately I can't use #:methods with struct/contract so I'm stuck
> >> with the slow one if I want a contract on the struct?
> >>
> >
> > For another option (though you may already know this), I'd advocate for
> > using the `struct` sub-form of `contract-out` and drawing the module
> > boundary as tightly as needed to make it a sensible boundary for trust,
> > potentially by using submodules.
>
> Yes... probably what I should do in the future.
>
> > Since you mention `#:methods` in particular, you should be aware of some
> > subtle corners that make it tricky (and potentially expensive at runtime)
> > to protect  `racket/generic` methods comprehensively with contracts.
> (Here's
> > a pointer to some discussions.
> > ) I think just working
> with
> > struct-type properties can make sense when you don't really need most of
> > the features `racket/generic` gives you.
>
> :O
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/87wo1ba8c1.fsf%40dustycloud.org
> .
>

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


Re: [racket-users] new racket-lang.org website

2020-08-26 Thread David Storrs
Wow!  That's beautiful.  Also, I'm on it which is a nice bit of egoboo.
Thank you for all your hard work.

On Tue, Aug 25, 2020 at 1:51 PM Robby Findler 
wrote:

> Hi all: as you may know if you follow dev@, we've been revising the
> website. The new version went live last night; please have a look:
> https://www.racket-lang.org/
>
> A big Thank You to Matthew Butterick for the previous design which, as you
> can tell, inspired the current visual design.
>
> Matthew, Robby, Sam, Jay, John, and Matthias
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAL3TdONYQPWY8OsnB2dpto%3D56mytQgtpKKQbVT%2BObV8iwpoNxQ%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/CAE8gKodSPxtpzFWTcZfVLkvmFpSsxmYu8%3DLWkf6cDpjWvFdfTg%40mail.gmail.com.


Re: [racket-users] slideshow -> google slides?

2020-08-07 Thread David Storrs
On Thu, Aug 6, 2020, 10:34 PM Hendrik Boom  wrote:

> On Thu, Aug 06, 2020 at 06:58:28PM -0400, 'John Clements' via Racket Users
> wrote:
> > Has anyone here developed a reasonable workflow for exporting slideshow
> presentations to google slides? It appears that google slides cannot import
> PDFs or SVGs. It looks like it has support for importing PPT files,
> unsurprisingly, but AFAIK slideshow won’t export ppt files. I have no idea
> how nasty the PPT format is.
> >
> > Right now I’m looking into PDFelement, a mac program, but I’d love to
> hear about other options.
>
> Have you tried libreoffice or openoffice?  (They're not the same, so one
> might work
> if the other doesn't.)  My wife used to make presentations from one of
> them a few
> years ago, and as far as I know, they were powerpoint compatible.
> Unfortunately
> she's not around to ask any more.
>
> -- hendrik
>

I'm very sorry for your loss, Hendrik. My father died in 2019 and it's been
agonizing, but I didn't live with him on a daily basis. I don't know how
long it's been for you but I hope you're all right.

Dave



> >
> > Thanks!
> >
> > John
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/7a2b8538-91f9-45e2-9006-5e8047d39973%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/20200807023356.ljyhfbzlvdtfbhxl%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/CAE8gKoddavs-uHiJwCTmxzwK3jhH6Pxx_fDh4%3D1xb0fFRFbvog%40mail.gmail.com.


Re: [racket-users] Removing duplicates from a list while still maintaining order in Dr. Racket.

2020-07-20 Thread David Storrs
"double post", not "dinner post".  Damn. Email needs an edit function and
no autocorrect.

On Mon, Jul 20, 2020, 1:09 PM David Storrs  wrote:

> First off, if this was an intentional dinner post, well played. :>
>
>
> If you don't want to use built-in functions, I would look at using a hash
> to track what you've already seen and then cons things together depending
> on if they're in the hash.
>
> For the second, maybe recur through the list using a hash to track the
> most recent index of each item, then pop back up through the recursion
> consing things together based on whether you're at the specified index.
> That's my first thought, anyway.
>
>
> On Mon, Jul 20, 2020, 12:04 PM JJ C  wrote:
>
>> In Beginning Student with List Abbreviations
>>
>> I am struggling to come up with functions to remove duplicates from a
>> list while maintaining the order of the list.
>>
>> one function to remove duplicates from the left,
>>
>> i.e. 1 2 1 3 2 4 5 -> 1 2 3 4 5
>>
>> and one from the right.
>>
>> i.e. 1 2 1 3 2 4 5 -> 1 3 2 4 5
>>
>> What are the functions for removing duplicates from each left and right
>> side? If you need to, use helper functions and append, cond, cons, equal?,
>> etc but not using reverse or any built-in functions.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/6049507b-094e-43c9-9dda-28237fcb57d8n%40googlegroups.com
>> <https://groups.google.com/d/msgid/racket-users/6049507b-094e-43c9-9dda-28237fcb57d8n%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/CAE8gKoepLmKVqm1hJWun5eQDmCWTJYFzQB59tukgaOvufGOAzw%40mail.gmail.com.


Re: [racket-users] Removing duplicates from a list while still maintaining order in Dr. Racket.

2020-07-20 Thread David Storrs
First off, if this was an intentional dinner post, well played. :>


If you don't want to use built-in functions, I would look at using a hash
to track what you've already seen and then cons things together depending
on if they're in the hash.

For the second, maybe recur through the list using a hash to track the most
recent index of each item, then pop back up through the recursion consing
things together based on whether you're at the specified index. That's my
first thought, anyway.


On Mon, Jul 20, 2020, 12:04 PM JJ C  wrote:

> In Beginning Student with List Abbreviations
>
> I am struggling to come up with functions to remove duplicates from a list
> while maintaining the order of the list.
>
> one function to remove duplicates from the left,
>
> i.e. 1 2 1 3 2 4 5 -> 1 2 3 4 5
>
> and one from the right.
>
> i.e. 1 2 1 3 2 4 5 -> 1 3 2 4 5
>
> What are the functions for removing duplicates from each left and right
> side? If you need to, use helper functions and append, cond, cons, equal?,
> etc but not using reverse or any built-in functions.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/6049507b-094e-43c9-9dda-28237fcb57d8n%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/CAE8gKoe_9sPOesQHm6H-C1WPiGW5oNnd4LFxB-urSqSW9SRkmA%40mail.gmail.com.


Re: [racket-users] Best data structure for ordered data set with insertion and reordering?

2020-07-17 Thread David Storrs
Thanks George.  Much appreciated.

On Thu, Jul 16, 2020 at 11:21 PM George Neuner  wrote:

>
> Hi David,
>
> On 7/16/2020 11:44 AM, David Storrs wrote:
>
> On Thu, Jul 16, 2020 at 10:09 AM George Neuner 
> wrote:
>
>>
>> The problem seems under-specified.  Can you say more about the real
>> purpose?
>>
>
> Basic version:  It's a peer-to-peer encrypted swarmed file sharing system
> that presents like Dropbox on the front end (i.e. "make a change to the
> filesystem on peer A and peers B-Z will replicate that change") and works
> something like Bittorrent on the back end in that files are sent in chunks
> but it offers functionality that Bittorrent does not, such as encrypted
> transfer, WoT authentication, etc.
>
>
> Interesting.  So I'm guessing your problem is to (compactly) represent the
> state of the shared space.
>
> Do you plan on having index servers, or are you aiming for a fully
> distributed solution?  And, if distributed, do you want each node to
> maintain its own state picture of the shared space, or were you thinking
> that nodes could just snoop admin broadcasts looking for mention of data
> they don't currently have?  [Your question about how to pair / collapse
> messages suggests you might be considering a snoopy solution.]
>
> Asking because keeping a state picture has scalability issues, a snoopy
> solution has complexity issues, and (depending on latency) both have issues
> with performing unnecessary work.  In any event, I have some suggestions.
>
>
>
> Snoopy is the more interesting case.  You start with a queue of file
> operations to be done as gleaned from the admin messages - mkdir, rmdir,
> fetch a file, delete a file, etc. - in whatever order the messages were
> received.
>
> Separately, you maintain a (hash table) mapping from pathnames to a list
> of queue nodes that operate on that object.  The map should use weak
> references so that nodes can safely be removed from the queue and discarded
> without also needing to update the map.  If queue processing gets to some
> operation first, any map reference to it will dissolve (be replaced by
> #f).
>
> When a message is received, you lookup the pathname in the map, and if a
> complementary operation is found in the queue, you remove and discard it.
> [You can also remove references in the map or just let them dissolve
> depending on your handling.]   Then simply discard the message.
>
> Otherwise you queue whatever operation the message indicates and add a
> reference to the queue node under the object's pathname in the map.
>
> Extra complexity comes in having to notice that map entries (pathnames)
> have no operations left in the queue.  Weak references don't just disappear
> - they are changed to #f when the referenced object is no longer reachable
> - however AFAICT there is no hashtable variant that permits weak reference
> values, so you have to use weak-boxes and those continue to exist even if
> the objects they reference are gone.   Useless map entries will need to be
> identified and removed somehow.
>
>
> Modeling the filesystem can be done rather simply with a trie in which
> folders are represented by mutable hash tables and files by structures.
> You can combine this with the operation queue above, but in this case
> lookups can be done in the trie and queue references kept in the trie
> nodes.  And the trie provides a snapshot of the current state which may be
> useful for other purposes.
>
>
> The trick in either case is processing latency: you don't want to wait too
> long, but if you really want to avoid unnecessary work you need to delay
> performing file operations long enough that complementary messages are
> likely to be received.
>
>
>
> What if messages are lost permanently, e.g., due to hardware crash?
>>
>
>> What it you receive a create but a corresponding delete or update is
>> lost - then your information / picture of the file system state is wrong.
>>
>> What if you receive a file delete without a corresponding create? In the
>> absence of other information, can you even assume there *was* a create?
>> If these messages are sent in response to user actions, can they ever be
>> sent mistakenly?
>>
>>
> The ultimate answer to these questions is "If things get out of sync in a
> way that the system cannot resolve, it will be flagged for a human to
> resolve." There are things we do that mitigate them -- for example, a
> write-ahead log for messages received from peers -- but we acknowledge that
> we cannot resolve 100% of situations automatically.  Neither can any other
> file replication service.  (Dropbox, Box.com, etc)
>
> Also relevantly,

Re: [racket-users] Best data structure for ordered data set with insertion and reordering?

2020-07-16 Thread David Storrs
On Thu, Jul 16, 2020 at 10:09 AM George Neuner  wrote:

>
> On 7/16/2020 4:29 AM, David Storrs wrote:
>
> The problem seems under-specified.  Can you say more about the real
> purpose?
>

Basic version:  It's a peer-to-peer encrypted swarmed file sharing system
that presents like Dropbox on the front end (i.e. "make a change to the
filesystem on peer A and peers B-Z will replicate that change") and works
something like Bittorrent on the back end in that files are sent in chunks
but it offers functionality that Bittorrent does not, such as encrypted
transfer, WoT authentication, etc.

What if messages are lost permanently, e.g., due to hardware crash?
>

> What it you receive a create but a corresponding delete or update is
> lost - then your information / picture of the file system state is wrong.
>
> What if you receive a file delete without a corresponding create? In the
> absence of other information, can you even assume there *was* a create?
> If these messages are sent in response to user actions, can they ever be
> sent mistakenly?
>
>
The ultimate answer to these questions is "If things get out of sync in a
way that the system cannot resolve, it will be flagged for a human to
resolve." There are things we do that mitigate them -- for example, a
write-ahead log for messages received from peers -- but we acknowledge that
we cannot resolve 100% of situations automatically.  Neither can any other
file replication service.  (Dropbox, Box.com, etc)

Also relevantly, differences are reconciled across multiple peers.  If
there's 5 peers in your replication set and the other 4 agree that there
should be a file at path P but you don't have one then it's safe to assume
that you missed a File-Create message.  And yes, that comes with issues of
its own (Q: What if it was deleted on your machine and none of the others
got your File-Delete because you crashed before sending it? A: Worst case,
the file gets recreated and the user deletes it again.  Also, move files to
a Trash folder in response to a File-Delete, don't actually delete them for
a certain period of time) but again we fall back to human resolution.

>

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


Re: [racket-users] Re: Best data structure for ordered data set with insertion and reordering?

2020-07-16 Thread David Storrs
On Thu, Jul 16, 2020, 5:23 AM evdubs  wrote:

> Do you think you'll need to try to identify the order that the events were
> created in?
>
> What if user A does:
>
> $ touch file.txt
> $ rm file.txt
>
> And what if user A had separately done:
>
> $ rm file.txt
> Error: file not found
> $ touch file.txt
>

You meant for those to be user A and user B, right?


> Would those operations both potentially create File-Create P H1 ;
> File-Delete P H1 events when things are allowed to be out of order? Don't
> they result in different states for the filesystem? If you also sent along
> the time of the operation (or maybe some sequence number), won't that let
> you keep things ordered and not make decisions that might be ambiguous?
>

Fair question. Yes, time will be sent along with the message. I was trying
to boil things down as far as possible and perhaps I boiled too long.

Of course, that raises its own issues about different timezones etc, but
those are separate from the issue at hand.

To answer your specific question: That sequence of events results in a
conflict that will be flagged for human review.

On Wednesday, July 15, 2020 at 10:29:36 PM UTC-10 david@gmail.com wrote:
>
>> tl;dr
>> Can anyone recommend a data structure that is ordered and supports
>> efficient reordering, insertion at arbitrary location, and deletion?
>>
>> Long form:
>>
>> I'm working on an operation-log reconciliation problem, where each
>> operation is one of:
>>
>>   File-CreateP H
>>   File-Update   P H
>>   File-DeleteP H
>>   Folder-Create P
>>   Folder-Delete P
>>
>> P = path
>> H = hash of the file (e.g. md5)
>>
>> Operation messages travel over the network, meaning that they could
>> arrive out of order.  (They could also be missed entirely, but that's a
>> separate problem that I'm not working on yet.)
>>
>> Specifically, I want to be able to take a series of messages and collapse
>> them where appropriate.  For example:
>>
>>   File-Update P H1 -> H2
>>   File-Create P1 H1
>> Result after collapse:
>>   '(File-Create P1 H2)
>>
>>   File-Create P H1
>>   File-Delete P H1
>> Result after collapse:
>>   '()
>>
>>   File-Delete P X
>>   File-Create P X
>> Result after collapse:
>>   '()
>>
>>   File-Delete P1 H1
>>   File-Create P2 H2
>>   File-Create P1 H1
>> Result after collapse:
>>   '(File-Create P2 H2)
>>
>> I've been mulling over various ways to handle all of this and digging
>> around to find examples of other people doing it, but I'm wondering if
>> there's a data structure or existing algorithm that will handle it
>> cleanly.  Does anyone know of such a thing?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/f03b33d8-e286-4cc2-afa5-4aefd0050bd5n%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/CAE8gKofT_R%3D-d8QEinouq8id16f7WJE2jpn5SE%2BqXPCgmODaXw%40mail.gmail.com.


[racket-users] Best data structure for ordered data set with insertion and reordering?

2020-07-16 Thread David Storrs
tl;dr
Can anyone recommend a data structure that is ordered and supports
efficient reordering, insertion at arbitrary location, and deletion?

Long form:

I'm working on an operation-log reconciliation problem, where each
operation is one of:

  File-CreateP H
  File-Update   P H
  File-DeleteP H
  Folder-Create P
  Folder-Delete P

P = path
H = hash of the file (e.g. md5)

Operation messages travel over the network, meaning that they could arrive
out of order.  (They could also be missed entirely, but that's a separate
problem that I'm not working on yet.)

Specifically, I want to be able to take a series of messages and collapse
them where appropriate.  For example:

  File-Update P H1 -> H2
  File-Create P1 H1
Result after collapse:
  '(File-Create P1 H2)

  File-Create P H1
  File-Delete P H1
Result after collapse:
  '()

  File-Delete P X
  File-Create P X
Result after collapse:
  '()

  File-Delete P1 H1
  File-Create P2 H2
  File-Create P1 H1
Result after collapse:
  '(File-Create P2 H2)

I've been mulling over various ways to handle all of this and digging
around to find examples of other people doing it, but I'm wondering if
there's a data structure or existing algorithm that will handle it
cleanly.  Does anyone know of such a thing?

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


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

2020-07-02 Thread David Storrs
Doh, just realized I never responded to this. Thank you guys so much. As
always, it's really appreciated.

On Tue, Jun 30, 2020, 7:21 PM Ryan Culpepper  wrote:

> Here's a function that creates a thread that waits until a port is closed
> and then prints a message:
>
>   (define (watch-for-port-close p)
> (thread (lambda () (sync (port-closed-evt out)) (eprintf "port
> closed\n"
>
> For example:
>
>   (define out (open-output-string))
>   (watch-for-port-close out) ;; => #
>   (close-output-port out) ;; prints "port closed"
>
> One reason a port can get closed is because of a custodian shutdown, and
> in that case you'd need to make sure that the watcher thread and its
> current-error-port are not managed by the same custodian. Here's a version
> that creates an unkillable thread (generally a bad idea, but probably okay
> for debugging):
>
>   (require ffi/unsafe/custodian)
>   (define (watch-for-port-close p)
> (parameterize ((current-custodian (make-custodian-at-root)))
>   (thread (lambda () (sync (port-closed-evt out)) (eprintf "port
> closed\n")
>
> Ryan
>
> On Wed, Jul 1, 2020 at 1:08 AM Matthew Flatt  wrote:
>
>> At Tue, 30 Jun 2020 16:27:56 -0400, David Storrs wrote:
>> > I have a port that (my current theory says) is being closed when it
>> > shouldn't, but I'm having trouble isolating exactly where and when.  I
>> > thought maybe I could do something Rackety to say "as soon as this port
>> > gets closed, run this function".  I went digging through Wills and
>> Plumbers
>> > but I'm having trouble grokking it.  Am I headed in the right
>> direction, or
>> > is there a better way?
>>
>> Wills and plumbers will not help.
>>
>> Do you have control over where the port is used to that you can
>> substitute another port? In that case, you could wrap the port with
>> `make-input-port` or `make-output-port`, and then you have control over
>> the close method.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/20200630164403.17c%40sirmail.smtp.cs.utah.edu
>> .
>>
>

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


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

2020-06-30 Thread David Storrs
I have a port that (my current theory says) is being closed when it
shouldn't, but I'm having trouble isolating exactly where and when.  I
thought maybe I could do something Rackety to say "as soon as this port
gets closed, run this function".  I went digging through Wills and Plumbers
but I'm having trouble grokking it.  Am I headed in the right direction, or
is there a better way?

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


Re: [racket-users] How to handle conflicts in packages?

2020-06-05 Thread David Storrs
Got it. I'll change that, and thank you.

On Fri, Jun 5, 2020 at 11:28 AM Sam Tobin-Hochstadt 
wrote:

> This most likely means that your documentation is in a file with a generic
> name like manual.scrbl which those packages also use.
>
> Sam
>
> On Fri, Jun 5, 2020, 11:20 AM David Storrs  wrote:
>
>> I uploaded a new module, 'thread-with-id', and the package server tells
>> me that there are conflicts.  The message is:
>>
>> https://pkg-build.racket-lang.org/conflicts.txt
>>
>>  doc "main":
>>   ekans lti-freq-domain-toolbox protobuf thread-with-id
>>
>> I'm not sure what this means -- I've looked through the ekans,
>> lti-freq-domain, and protobuf modules and none of them have a
>> thread-with-id function listed in the docs.
>>
>> Is there anything I can do to resolve this?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAE8gKofxWjWhHMs1EReWOxw3ZNXCsLi5WOWgHzKVrbbRXFwWPQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAE8gKofxWjWhHMs1EReWOxw3ZNXCsLi5WOWgHzKVrbbRXFwWPQ%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/CAE8gKoeC%2BJ%2Bnz9O6s0Kn3Frfpxt%3Da5sF1KtwK6ECrzx95vaEnQ%40mail.gmail.com.


[racket-users] How to handle conflicts in packages?

2020-06-05 Thread David Storrs
I uploaded a new module, 'thread-with-id', and the package server tells me
that there are conflicts.  The message is:

https://pkg-build.racket-lang.org/conflicts.txt

 doc "main":
  ekans lti-freq-domain-toolbox protobuf thread-with-id

I'm not sure what this means -- I've looked through the ekans,
lti-freq-domain, and protobuf modules and none of them have a
thread-with-id function listed in the docs.

Is there anything I can do to resolve this?

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


Re: [racket-users] Re: rackunit and logging

2020-05-24 Thread David Storrs
On Sat, May 23, 2020 at 9:54 AM Shriram Krishnamurthi 
wrote:

> Thank you all!
>
> *Dave*, the documentation style is fine, it's sometimes easier to read
> the doc right next to the implementation. (-:
>
> However, I'm not quite sure how even your example works. Maybe someone can
> check my logic? For instance, you say you want to write tests like
>
> (unless (is os 'windows) (ok test-that-won't-pass-on-windows))
>
> However, `is` seems to return the same value no matter whether the test
> passed or failed: it returns the first argument, *irrespective* of the
> outcome of the test. So in the above test, the returned value is going to
> be that of `os`, which is presumably some non-false value. That means the
> guarded test will *never* be run, on any OS.
>

You're absolutely right -- that should have been an `ok`, not an `is`.


> [Separately, I'm not sure why one would use a testing utility in that
> conditional, rather than just a standard conditional, but that's a
> different matter.]
>

A standard conditional would say "If we are being run on Windows...", where
the `ok` is saying "I expect that this test file is being run on Windows".


> In general, this seems to be a property of your underlying function,
> `test-more-check`: it returns either the return value sent in through
> #:return or the value in the checked position (#:got). But in either case,
> this is independent of the success of the test. The only difference is in
> the *message*, which is printed as output. I suppose I could parameterize
> where it's printed and capture it — but then I have to parse all the
> information back out. I'm just not seeing how to compositionally use your
> testing primitives?
>

Number of success and failures is available through (tests-passed) and
(tests-failed), so that's one option. (current-test-num), (inc-test-num!),
and (next-test-num) allow you to determine and modify the number of tests
that will be reported, so you can conditionally run a test and then pretend
it didn't happen if you don't like the outcome.   `ok` returns a boolean so
it can be used to conditionally run groups of tests.  The other functions
return their argument so you can chain it through a series of tests.

I'd be delighted to add more options if I knew that other people were using
the package -- just let me know.


> As an aside, when trying to install the package in a Docker container
> running Ubuntu 18.04 with Racket 7.7 installed, I got this error:
>
> raco setup: docs failure: query-exec: unable to open the database file
>   error code: 14
>   SQL: "ATTACH $1 AS other"
>   database: #
>   mode: 'read-only
>   file permissions: (write read)
>
> which I didn't get on macOS Catalina. The package certainly has a … lot of
> stuff! Even links to EDGAR filings. (-:
>

Yeah, it's an absolute junkpile.  When I was learning Racket I wrote all
these things but didn't have the sense to put them in separate modules.
Now that I'm older and hopefully wiser, in my Copious Free Time I'm working
on splitting it all into stand-alone modules and documenting everything,
but that's going slowly.  If test-more looks like something you might use
then I'll prioritize it so that you aren't stuck with the rest of the
kitchen sink.



> Thanks,
> 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/CAJUf2yS7%2B2OSq899U5%2BQrgZwFNwdowQNdByU4AkxxwK%3Dby5wOQ%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/CAE8gKod8%3DjzYFbbtz5_mp15cYxUq3gOQhf9UWmZtPo5z5a-pXw%40mail.gmail.com.


Re: [racket-users] rackunit and logging

2020-05-23 Thread David Storrs
Hi Shriram,

I have a module, handy/test-more (https://pkgs.racket-lang.org/package/handy),
that I think does everything you want; the downside is that the
documentation is thorough but it's in the form of essay-style comment
sections instead of Scribble.  Breaking that out into actual Scribble is on
my todo list but hasn't happened yet.  You can read it on GitHub here
https://github.com/dstorrs/racket-dstorrs-libs/blob/master/test-more.rkt

If you think you would find this useful, I'll make a point to do the
Scribble this weekend.

Here's the synopsis statement:

;;==

;;The racket testing module has a few things I wish it did differently:

;;

;; 1) The test function names are verbose and redundant.  check-this,
check-that, etc
;;

;; 2) The test functions display nothing on success.  There's no way

;; to tell the difference between "no tests ran" and "all tests

;; succeeded"

;;

;; 3) The tests return nothing.  You can't do conditional tests like:

;;(unless (is os 'windows) (ok test-that-won't-pass-on-windows))




Some quick examples; there's quite a lot more that can be done with it if
this looks useful.   The output is shown after the code.


#lang racket

(require handy/test-more)

(expect-n-tests 4)
(test-suite
 "examples"

 (struct person (name age) #:transparent)
 (define people (hash 'alice (person "alice" 19)  'bob (person "bob" 17)))

 ; basic equality testing
 (is   (* 1 2) 2 "(* 1 2) = 2")
 (is-false (hash-has-key? people 'charlie) "as expected, don't know
charlie")
 (isnt (hash-has-key? people 'charlie) "same as above")

 ; Tests return values so you can chain them or nest them
 (lives
  (thunk
   (and (ok (hash-has-key? people 'alice) "we have an entry for alice")
(let ([alice (hash-ref people 'alice)])
  (is (person-age alice) 19 "alice is 19")
  (like (person-name alice) #px"^alice$" "alice's name is string,
lowercase, trimmed"
  "alice-related tests did not raise exception")

 ; exceptions
 (define thnk (thunk (+ 1 "foo")))
 (dies   thnk "it died, that's all I care about")
 (throws thnk exn:fail:contract? "match against an arbitrary predicate")
 (throws thnk #px"expected: number.+\"foo\"" "match against a regex")
 (is (throws thnk (lambda (e) 'ok) "throws can pass exn to arbitrary
one-arg proc for testing")
 'ok
 #:op (lambda (got expected)
(if (exn? got) 'ok 'nope))
 "tested 'throws' with hand-rolled predicate, then chained into `is`
using hand-rolled equality testing (the equality test is illustrative but
not sensible)")
 )

When you run the above code, the following will be sent to STDOUT.  Note
that it tracks the number of tests it runs, numbers them, and warns you
that you didn't run the expected number.

 (START test-suite:  examples)
ok 1 - (* 1 2) = 2
ok 2 - as expected, don't know charlie
ok 3
ok 4 - we have an entry for alice
ok 5 - alice is 19
ok 6 - alice's name is string, lowercase, trimmed
ok 7 - alice-related tests did not raise exception
ok 8 - it died, that's all I care about
ok 9 - match against an arbitrary predicate
ok 10 - match against a regex
ok 11 - throws can pass exn to arbitrary one-arg proc for testing
ok 12 - tested 'throws' with hand-rolled predicate, then chained into `is`
using hand-rolled e$
ok 13 - test-suite completed without throwing uncaught exception

Total tests passed so far: 13
Total tests failed so far: 0
 (END test-suite:  examples)

!!ERROR!!:  Expected 4 tests, actually saw 13

On Fri, May 22, 2020 at 7:47 PM Shriram Krishnamurthi 
wrote:

> I'm trying to understand the design of the logging portion of rackunit:
>
>
> https://docs.racket-lang.org/rackunit/Testing_Utilities.html#%28part._.Logging_.Test_.Results%29
>
>1. The "log" seems to only be a *count*, not the actual rackunit
>output (as the term "log" would suggest). Since I want to show a summary of
>tests — including output — on a different medium, after the test suite has
>run, it looks like I need to essentially create my own logging support?
>(Perhaps the "check-info stack" is useful here, but I don't think so.)
>2. Why do the check-… procedures not return any value? It would seem
>natural for them to return, say, false in case of passing and a failure
>information structure in case of failing (or a structure in both cases).
>But they seem to only return void, so I'm not entirely sure how else to
>extract the information for the log without rewriting the check's.
>3. As an aside, I'm not entirely sure what `test-log!` is there for.
>Presumably it's to record in the log "tests" run by operations that are not
>part of rackunit? I'm curious how people have used it.
>
> TL;DR: If I want to record what happened on all the checks for
> post-execution processing, do I need to (a) create my own log and, to do
> so, (b) rewrite all the checking predicates to provide the 

[racket-users] Structs that masquerade as channels

2020-05-22 Thread David Storrs
Is there a way to make a struct that can seamlessly pretend to be a channel
the same way one can pretend to be an output-port?  I'm pretty sure the
answer is no but wanted to confirm.

Example:

(struct person (name to) #:property prop:output-port (struct-field-index
to))
(displayln "yay" (person 'bob (current-output-port)) )
"yay"  ;< actual result

(struct animal (name to) #:property ??? (struct-field-index to))
(define fido (animal 'dog (make-channel)))
(channel-put fido 'yay)
(channel-get (animal-to fido))
'yay  ; <=== desired result

Is there something that can go in ??? to make this work, or some other way
of doing it?  I looked at impersonators but those don't seem to be 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/CAE8gKofb8tHA3Din5qV5hBohsxGNeDDQ54nx9wnr2YYS%2B6qAvQ%40mail.gmail.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] 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] Button click callback syntax

2020-05-12 Thread David Storrs
Hi Philip,

The essence here is when evaluation happens:

;  All of these are equivalent:
(define foo (lambda () 7)
(define foo (thunk 7))  ; 'thunk' is a term of art meaning "function
of 0 arguments"
(define (foo) 7)

Try running the following code in the repl:
; start code
(define (general-callback msg-name msg-text message-box-text) ;
function of 3 arguments
  'result-of-general-callback)
general-callback
(general-callback "name" "text" "msg box text")
; end code

You'll see that 'general-callback' returns:
#, which is the actual function
and (general-callback ...) returns 'result-of-general-callback, which
is the result of invoking the function.


In your GUI code, you want to be passing the function itself, not the
result of invoking the function.

Does that make sense?


On Tue, May 12, 2020 at 12:34 PM Philip Benade  wrote:
>
> Hi All
>
> I am new to Racket and I have found a situation where I'm not certain why 
> Racket works the way it does. Unfortunately I am not sure of the vocabulary 
> so I will describe the situation with some code:
>
>
> ; A button made this way works as I would expect, it waits for 30 minutes and 
> then shows a message-box and plays a sound.
> (new button% [parent long-break-panel]
>  [label "Long Break"]
>  ; Callback procedure for a button click:
>  [callback (lambda (button event)
>  (send long-break-msg set-label "Long break timer 
> started")
>  (general-timer 30 long-break-callback))])
>
> ; A button made this way immediately shows the message box and plays the 
> sound.
> (new button% [parent long-break-panel]
>  [label "Long Break"]
>  ; Callback procedure for a button click:
>  [callback (lambda (button event)
>  (send long-break-msg set-label "Long break timer 
> started")
>  (general-timer 30 (general-callback long-break-msg 
> "Not on long break" "30 Minutes have passed, back to work.")))])
>
> ; A button made this way also immediately shows the message box and plays the 
> sound. Why is it different when the function name is surrounded by 
> parentheses?
> (new button% [parent long-break-panel]
>  [label "Long Break"]
>  ; Callback procedure for a button click:
>  [callback (lambda (button event)
>  (send long-break-msg set-label "Long break timer 
> started")
>  (general-timer 30 (long-break-callback)))])
>
> ; The documentation for buttons say they require a callback. I interpreted 
> this to mean a function that will execute when the button is clicked.
> (define general-callback
>   (lambda (msg-name msg-text message-box-text)
> (time-expired-sound)
> (send msg-name set-label msg-text)
> (message-box "Timer expired" message-box-text frame)))
>
> ; Why does wrapping the function so that it takes no parameters change how it 
> gets executed?
> (define long-break-callback
>   (lambda ()
> (general-callback long-break-msg "Not on long break" "30 Minutes have 
> passed, back to work.")))
>
>
> Is anyone able to explain why I am getting these different behaviors from 
> these buttons?
>
> Regards
> Philip
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/3a6effce-915e-42c8-aff7-56fc23524e4c%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/CAE8gKodGj1dFEcjW-ED9GdXsy37F0gCsxfHbhPuFxOCXwWgToQ%40mail.gmail.com.


[racket-users] Question about positive vs negative blame

2020-05-11 Thread David Storrs
If I understand correctly, "positive blame" refers to servers and "negative
blame" refers to clients.  I think this means:


(define/contract (add-10 x) (-> number? number?) "oops")
(add-10 7); Call-A
(add-10 "oops")   ; Call-B

`add-10` accepts a number and promises to return a number, but it actually
returns a string.  Therefore:

Call-A:   positive blame on add-10, no negative blame
Call-B:   negative blame on the (add-10 "oops") call, no positive blame.

Do I have this right, or does every exception carry both positive and
negative blame?

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


Re: [racket-users] Matching groups of optional elements

2020-05-04 Thread David Storrs
Thanks, Phillip.

On Mon, May 4, 2020 at 10:44 PM Philip McGrath 
wrote:

> Depending on your requirements, I would consider using `syntax-parse` at
> runtime: this is easily written with its `~seq` patterns, and you get nicer
> error reporting.
>
> Here's an example—I use syntax classes for clarity, but they aren't
> necessary, if you prefer to be more concise:
>
> #lang racket
>
> (require syntax/parse
>  rackunit)
>
> (define-splicing-syntax-class person-cols
>   (pattern (~seq "Name" "Age" "First" "Last")))
>
> (define-syntax-class csv-header
>   (pattern ("RequiredA" "RequiredB" person:person-cols ...)))
>
> (define valid-header?
>   (syntax-parser
> [:csv-header
>  #t]
> [_
>  #f]))
>
> ;; legal column arrangements:
> (check-true
>  (valid-header? #'("RequiredA" "RequiredB")))
> (check-true
>  (valid-header? #'("RequiredA" "RequiredB" "Name" "Age" "First" "Last")))
> (check-true
>  (valid-header?
>   #'("RequiredA" "RequiredB" "Name" "Age" "First" "Last" "Name" "Age"
> "First" "Last")))
>
> ;; illegal:  if an optional group is present, it must have all 4 columns
> (check-false
>  (valid-header?
>   #'("RequiredA" "RequiredB" "Name" "Age" "First" "Last" "Name")))
>
>
> On Mon, May 4, 2020 at 10:39 PM Michael MacLeod 
> wrote:
>
>> I'm not sure this is possible with only using `match` patterns. A
>> combination of the `list-rest` and `app` patterns as well as the `in-slice`
>> procedure from `racket/sequence` should do the trick, though:
>>
>> #lang racket
>>
>> (require racket/match)
>>
>> (define (collect-optional-vals x)
>>   (for/list ([y (in-slice 4 x)])
>> y))
>>
>> (match '(req-a req-b name1 age1 first1 last1 name2 age2 first2 last2)
>>   [(list-rest req-a req-b (app collect-optional-vals optional-vals))
>>(list req-a req-b optional-vals)])
>>
>> On Mon, May 4, 2020 at 7:16 PM David Storrs 
>> wrote:
>>
>>> I'm trying to write a parser for a CSV file with optional columns.
>>> Simplified version:  There are 2 mandatory columns, after which there can
>>> be 0+ 4-column groups describing a person.  Each group has the same column
>>> headers.
>>>
>>> ; legal column arrangements:
>>> RequiredA RequiredB
>>> RequiredA RequiredB Name Age First Last
>>> RequiredA RequiredB Name Age First Last Name Age First Last
>>>
>>>
>>> ; illegal:  if an optional group is present, it must have all 4 columns
>>> RequiredA RequiredB Name Age First Last Name
>>>
>>> I thought I could do this straightforwardly with `match`, but I'm
>>> wrong.  Can someone point me to the way to write such a match clause?
>>>
>>>
>>> Various failed attempts:
>>> (list reqA reqB (opt1 opt2 opt3 opt4) ...)   ; syntax error. matching
>>> clauses do not do grouping like this
>>> (list reqA reqB (list opt1 opt2 opt3 opt4) ...) ; didn't expect this to
>>> work since it would specify an embedded list.  I was right.
>>>
>>> This one surprised me:
>>> (match row
>>>   [(list required1 required2 (and opt1 opt2 opt3 opt4) ...)
>>>(list opt1 opt2 opt3 opt4)])
>>>
>>> This distributes the ... over the four items inside the 'and' clause
>>> such that each of the 'optionalN' identifiers matches all remaining
>>> elements.
>>> '(("Name" "Age" "First" "Last")
>>> ("Name" "Age" "First" "Last")
>>> ("Name" "Age" "First" "Last")
>>> ("Name" "Age" "First" "Last"))
>>>
>>> In hindsight it makes sense -- the 'and' causes it to match the element
>>> across all four patterns.  They all match because they are identifiers and
>>> therefore match anything.  Then the '...' causes it to do that for all
>>> remaining elements, generating lists into each of the identifiers because
>>> that's what '...' does.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>

Re: [racket-users] Matching groups of optional elements

2020-05-04 Thread David Storrs
Fantastic.  Thanks, Michael.

On Mon, May 4, 2020 at 10:39 PM Michael MacLeod 
wrote:

> I'm not sure this is possible with only using `match` patterns. A
> combination of the `list-rest` and `app` patterns as well as the `in-slice`
> procedure from `racket/sequence` should do the trick, though:
>
> #lang racket
>
> (require racket/match)
>
> (define (collect-optional-vals x)
>   (for/list ([y (in-slice 4 x)])
> y))
>
> (match '(req-a req-b name1 age1 first1 last1 name2 age2 first2 last2)
>   [(list-rest req-a req-b (app collect-optional-vals optional-vals))
>(list req-a req-b optional-vals)])
>
> On Mon, May 4, 2020 at 7:16 PM David Storrs 
> wrote:
>
>> I'm trying to write a parser for a CSV file with optional columns.
>> Simplified version:  There are 2 mandatory columns, after which there can
>> be 0+ 4-column groups describing a person.  Each group has the same column
>> headers.
>>
>> ; legal column arrangements:
>> RequiredA RequiredB
>> RequiredA RequiredB Name Age First Last
>> RequiredA RequiredB Name Age First Last Name Age First Last
>>
>>
>> ; illegal:  if an optional group is present, it must have all 4 columns
>> RequiredA RequiredB Name Age First Last Name
>>
>> I thought I could do this straightforwardly with `match`, but I'm wrong.
>> Can someone point me to the way to write such a match clause?
>>
>>
>> Various failed attempts:
>> (list reqA reqB (opt1 opt2 opt3 opt4) ...)   ; syntax error. matching
>> clauses do not do grouping like this
>> (list reqA reqB (list opt1 opt2 opt3 opt4) ...) ; didn't expect this to
>> work since it would specify an embedded list.  I was right.
>>
>> This one surprised me:
>> (match row
>>   [(list required1 required2 (and opt1 opt2 opt3 opt4) ...)
>>(list opt1 opt2 opt3 opt4)])
>>
>> This distributes the ... over the four items inside the 'and' clause such
>> that each of the 'optionalN' identifiers matches all remaining elements.
>> '(("Name" "Age" "First" "Last")
>> ("Name" "Age" "First" "Last")
>> ("Name" "Age" "First" "Last")
>> ("Name" "Age" "First" "Last"))
>>
>> In hindsight it makes sense -- the 'and' causes it to match the element
>> across all four patterns.  They all match because they are identifiers and
>> therefore match anything.  Then the '...' causes it to do that for all
>> remaining elements, generating lists into each of the identifiers because
>> that's what '...' does.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAE8gKocCPSgVQG_aMSC%3DQJAmAtxvmCN8vqpwsankKnCJZAOotw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAE8gKocCPSgVQG_aMSC%3DQJAmAtxvmCN8vqpwsankKnCJZAOotw%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/CAE8gKocyrT%3DAUAzvkiWs6AxP118LrxX89CFNOzHf%2BJKj4pdGLQ%40mail.gmail.com.


[racket-users] Matching groups of optional elements

2020-05-04 Thread David Storrs
I'm trying to write a parser for a CSV file with optional columns.
Simplified version:  There are 2 mandatory columns, after which there can
be 0+ 4-column groups describing a person.  Each group has the same column
headers.

; legal column arrangements:
RequiredA RequiredB
RequiredA RequiredB Name Age First Last
RequiredA RequiredB Name Age First Last Name Age First Last


; illegal:  if an optional group is present, it must have all 4 columns
RequiredA RequiredB Name Age First Last Name

I thought I could do this straightforwardly with `match`, but I'm wrong.
Can someone point me to the way to write such a match clause?


Various failed attempts:
(list reqA reqB (opt1 opt2 opt3 opt4) ...)   ; syntax error. matching
clauses do not do grouping like this
(list reqA reqB (list opt1 opt2 opt3 opt4) ...) ; didn't expect this to
work since it would specify an embedded list.  I was right.

This one surprised me:
(match row
  [(list required1 required2 (and opt1 opt2 opt3 opt4) ...)
   (list opt1 opt2 opt3 opt4)])

This distributes the ... over the four items inside the 'and' clause such
that each of the 'optionalN' identifiers matches all remaining elements.
'(("Name" "Age" "First" "Last")
("Name" "Age" "First" "Last")
("Name" "Age" "First" "Last")
("Name" "Age" "First" "Last"))

In hindsight it makes sense -- the 'and' causes it to match the element
across all four patterns.  They all match because they are identifiers and
therefore match anything.  Then the '...' causes it to do that for all
remaining elements, generating lists into each of the identifiers because
that's what '...' does.

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


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

2020-05-01 Thread David Storrs
On Fri, May 1, 2020, 11:25 PM Raoul Duke  wrote:

> $0.02, whitespace sensitivity is just bad ux in the long run. haskell can
> get away with it more than python because haskell can be written more
> concisely i feel than python. but even in H it is sorta unfortunate.
>
> i like how iirc clojure uses sexprs but allows other kinds of parens,
> fairly arbitrarily.
>
> (foo '{2 3 4} '[a b c])
> same thing as
> (foo '(2 3 4) '(a b c))
>
> so humans can make some parts stand out a little bit differently.
>

Racket does the same thing. (), [], and {} are all equivalent as long as
they match consistently. (i.e. you can't do '(] because that doesn't match
consistently.)

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


Re: [racket-users] a minor regexp question (and a how-could-I-answer-it-myself? question)

2020-05-01 Thread David Storrs
For the record, it's probably better to stick with #px in all cases.  The
vast majority of non-Racket code is based off the pcre library, which
stands for "Perl-compatible regular expressions" so if you stick with #px
the regex will be more familiar to more people.  Plus, standardizing on one
notation will eliminate bugs like the one you're seeing.

On Fri, May 1, 2020 at 9:50 AM Tim Hanson  wrote:

> Thanks, Jens, much appreciated. I suspect I even knew this once and had
> since forgotten it.
>
> (I even glanced at the docs, saw the two kinds, but didn’t pause long
> enough to wonder if it mattered to me.)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/69320674-8272-4751-a6ce-40c140a7358c%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/CAE8gKocP1FP4ufrQW%2BVyKYKHSmC3i-LWPvM9C0jekHLj1fqj3Q%40mail.gmail.com.


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

2020-04-30 Thread David Storrs
On Thu, Apr 30, 2020 at 11:16 AM Hendrik Boom 
wrote:

> On Thu, Apr 30, 2020 at 09:36:15AM +0200, Dexter Lagan wrote:
> >   There’s one thing I noticed: if debugging is disabled, then
> parenthesis highlighting is also disabled (as well as other visual aids, if
> I remember well?). The editor also feels faster because of this, but
> navigating parentheses becomes slightly more tedious without it.
>
> And that's exactly the parenthesis problem.  For a language as
> parenthesis-heavy as Scheme or Lisp, you need a
> parenthesis-oriented editor.  DrRacket does this very well bu
> shading the background (but apparently not all the time).  Emacs
> does it too, in principle, but isn't reaally great at it.
>

Not to minimize your experience but I'm speaking up simply as a
counterpoint:  I haven't had this issue, even without Racket's equivalence
between () [] and {}.

Also is there a programming editor that *won't* do parenthesis matching?

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


Re: [racket-users] Should I stop sending packages to the catalog?

2020-04-29 Thread David Storrs
On Wed, Apr 29, 2020 at 12:47 PM Sage Gerard  wrote:

> April 9th in the #general Slack channel taught me that there was no clean
> way to
> release a breaking change in a package. I'm open to working on version
> pinning
> support in raco pkg provided that a maintainer can walk me through some
> code.
>
> In the meantime, as much as I appreciate the efforts made in the current
> system,
> I'm considering stopping my contributions to the package catalog until
> further notice.
> I'm open to submitting packages if I am confident in their longevity, but
> I don't want
> to end up in the position I've been in for the last few weeks when
> planning a release.
> That position being an inability to release an edition that is not in some
> way "aware"
> of a prior edition. In my view, changing the package/collection name is an
> example of that problem, not a solution to it.
>
> I'm considering asking my users to specify different package sources in
> their info.rkt
> files when dealing with my work. Before I commit to that decision, I
> wanted to tap into
> those of you who have already been here. How have you handled breaking
> changes
> for your projects? How have you communicated with your users to make sure
> they
> were adequately prepared? Am I being too black-and-white about this?
>
> *~slg*
>

+1 on this.  I'm having the same issue.


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


Re: [racket-users] Rhombus project plan

2020-04-29 Thread David Storrs
On Wed, Apr 29, 2020 at 11:15 AM Jeffrey Edgington 
wrote:

>
> Greetings,
>
> I would be interested as well.
>
> Thanks,
>
> Jeff
>
>
Sam and I started to do this on Slack and will connect again later to do
more.  I'm taking thorough notes and will pass them along once I've got
something worked out.


In related news, a question for the list:  Once I have a handle on this, I
would like to write a "How to Contribute to Racket Documentation" guide.
Where would be the right place for this?  Should it be an expansion to an
existing document (if so, which), an entirely new one, or...?


On Apr 29, 2020, at 8:27 AM, Sam Tobin-Hochstadt 
> wrote:
>
> Hi David,
>
> If you ping me on Slack, I'll be happy to walk you through how to make
> changes to the docs. And maybe you can lend a hand to finally
> completing
> https://urldefense.com/v3/__https://github.com/racket/racket/pull/874__;!!NCZxaNi9jForCP_SxBKJCA!E1HW0DYeDaBURU0NVZ0qTBoXcScUGqgl1F962-iW9Qn3LDAl5HBdsyRd6LAwe2w$
>   which I think is
> mostly a matter of JavaScript programming now.
>
> Sam
>
> On Wed, Apr 29, 2020 at 9:35 AM David Storrs 
> wrote:
>
>
>
>
> On Wed, Apr 29, 2020 at 8:21 AM Matthew Flatt  wrote:
>
>
> At Wed, 29 Apr 2020 11:14:47 +0200, Dexter Lagan wrote:
>
>  To the point: what would make Racket2 the ultimate tool (for me):
> Performance. Faster startup times, shorter execution times in general.
> Optionally, a ‘lite’ version of Racket that compiles directly to no-deps
> binaries, bypassing the JIT altogether, would be a game-changer. As far as
> high levels languages with functional concepts and metaprogramming
> facilities
> that compiles to tiny, fast bins, Nim comes dangerously close, but it’s
> not a
> Lisp, and it’s not Racket.
> Production-quality, modern and fast GUI facilities. I’ll take properly
> documented, complete Qt bindings. Racket/GUI is great for internal tools,
> but
> it quickly becomes slow, tedious and limited for more complex client-facing
> UIs.
> One complete, commercial-grade Web framework, inspired from Symphony or
> Laravel. Security and ease of use first, continuations later.
> Better documentation: Racket docs are aesthetically very pleasing, complete
> and detailed. However some parts are still very obscure and lacking simple
> examples (if only the part about Continuations included just one basic
> example, such as a ‘return’ implementation, on the very first page. If only
> the Macros documentation started with define-simple-macro and a few very
> basic, practical examples. Instead we’re greeted with pattern-based macros,
> which although very powerful, are very hard to comprehend for newcomers).
>
>
> Which of these things will you be working on?
>
>
>
> I'll step up.
>
> Matt, I need some help with Scribble and how to contribute to the Racket
> docs.  I'd be willing to pay for a couple hours of your time (or whomever
> else's has the skill/knowledge) to walk me through that.  After that I'll
> be happy to pitch in by offering documentation patches.  This will be a big
> help for me, since I'm finding myself having trouble writing docs for my
> own code.
>
>
>
>
>  I am well aware that what I’m wishing for isn’t necessarily compatible
> with
> Racket’s intended public’s needs (comp-sci teachers and students? That’s
> the
> impression I’m getting). But Racket is the most advanced general purpose
> programming tool I’ve ever seen. Wouldn’t it be a shame if it was limited
> to
> academic use?
>
>
>
> https://urldefense.com/v3/__https://www.youtube.com/watch?v=LN0qG-i1iT0=youtu.be__;!!NCZxaNi9jForCP_SxBKJCA!E1HW0DYeDaBURU0NVZ0qTBoXcScUGqgl1F962-iW9Qn3LDAl5HBdsyRdNRfm5wI$
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://urldefense.com/v3/__https://groups.google.com/d/msgid/racket-users/5ea97134.1c69fb81.8c167.2c68SMTPIN_ADDED_MISSING*40gmr-mx.google.com__;JQ!!NCZxaNi9jForCP_SxBKJCA!E1HW0DYeDaBURU0NVZ0qTBoXcScUGqgl1F962-iW9Qn3LDAl5HBdsyRdaDXQ6Z4$
>  .
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://urldefense.com/v3/__https://groups.google.com/d/msgid/racket-users/CAE8gKoe*3D5XYkfveAKUy2b6iq7pfNJsZVr*3Djhh7G-8rszHrwfbQ*40mail.gmail.com__;JSUl!!NCZxaNi9jForCP_SxBKJCA!E1HW0DYeDa

Re: [racket-users] Rhombus project plan

2020-04-29 Thread David Storrs
Cool, thanks! Ping sent.

On Wed, Apr 29, 2020 at 10:27 AM Sam Tobin-Hochstadt 
wrote:

> Hi David,
>
> If you ping me on Slack, I'll be happy to walk you through how to make
> changes to the docs. And maybe you can lend a hand to finally
> completing https://github.com/racket/racket/pull/874 which I think is
> mostly a matter of JavaScript programming now.
>
> Sam
>
> On Wed, Apr 29, 2020 at 9:35 AM David Storrs 
> wrote:
> >
> >
> >
> > On Wed, Apr 29, 2020 at 8:21 AM Matthew Flatt 
> wrote:
> >>
> >> At Wed, 29 Apr 2020 11:14:47 +0200, Dexter Lagan wrote:
> >> >   To the point: what would make Racket2 the ultimate tool (for me):
> >> > Performance. Faster startup times, shorter execution times in general.
> >> > Optionally, a ‘lite’ version of Racket that compiles directly to
> no-deps
> >> > binaries, bypassing the JIT altogether, would be a game-changer. As
> far as
> >> > high levels languages with functional concepts and metaprogramming
> facilities
> >> > that compiles to tiny, fast bins, Nim comes dangerously close, but
> it’s not a
> >> > Lisp, and it’s not Racket.
> >> > Production-quality, modern and fast GUI facilities. I’ll take properly
> >> > documented, complete Qt bindings. Racket/GUI is great for internal
> tools, but
> >> > it quickly becomes slow, tedious and limited for more complex
> client-facing
> >> > UIs.
> >> > One complete, commercial-grade Web framework, inspired from Symphony
> or
> >> > Laravel. Security and ease of use first, continuations later.
> >> > Better documentation: Racket docs are aesthetically very pleasing,
> complete
> >> > and detailed. However some parts are still very obscure and lacking
> simple
> >> > examples (if only the part about Continuations included just one basic
> >> > example, such as a ‘return’ implementation, on the very first page.
> If only
> >> > the Macros documentation started with define-simple-macro and a few
> very
> >> > basic, practical examples. Instead we’re greeted with pattern-based
> macros,
> >> > which although very powerful, are very hard to comprehend for
> newcomers).
> >>
> >> Which of these things will you be working on?
> >
> >
> > I'll step up.
> >
> > Matt, I need some help with Scribble and how to contribute to the Racket
> docs.  I'd be willing to pay for a couple hours of your time (or whomever
> else's has the skill/knowledge) to walk me through that.  After that I'll
> be happy to pitch in by offering documentation patches.  This will be a big
> help for me, since I'm finding myself having trouble writing docs for my
> own code.
> >
> >>
> >>
> >>
> >> >   I am well aware that what I’m wishing for isn’t necessarily
> compatible with
> >> > Racket’s intended public’s needs (comp-sci teachers and students?
> That’s the
> >> > impression I’m getting). But Racket is the most advanced general
> purpose
> >> > programming tool I’ve ever seen. Wouldn’t it be a shame if it was
> limited to
> >> > academic use?
> >>
> >> https://www.youtube.com/watch?v=LN0qG-i1iT0=youtu.be
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> >> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/5ea97134.1c69fb81.8c167.2c68SMTPIN_ADDED_MISSING%40gmr-mx.google.com
> .
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKoe%3D5XYkfveAKUy2b6iq7pfNJsZVr%3Djhh7G-8rszHrwfbQ%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/CAE8gKoe6LLOZk6Up_SCzXTaZH7fwEVDs%3DagbZ%2BqbY9pWVxLykw%40mail.gmail.com.


Re: [racket-users] Rhombus project plan

2020-04-29 Thread David Storrs
On Wed, Apr 29, 2020 at 8:21 AM Matthew Flatt  wrote:

> At Wed, 29 Apr 2020 11:14:47 +0200, Dexter Lagan wrote:
> >   To the point: what would make Racket2 the ultimate tool (for me):
> > Performance. Faster startup times, shorter execution times in general.
> > Optionally, a ‘lite’ version of Racket that compiles directly to no-deps
> > binaries, bypassing the JIT altogether, would be a game-changer. As far
> as
> > high levels languages with functional concepts and metaprogramming
> facilities
> > that compiles to tiny, fast bins, Nim comes dangerously close, but it’s
> not a
> > Lisp, and it’s not Racket.
> > Production-quality, modern and fast GUI facilities. I’ll take properly
> > documented, complete Qt bindings. Racket/GUI is great for internal
> tools, but
> > it quickly becomes slow, tedious and limited for more complex
> client-facing
> > UIs.
> > One complete, commercial-grade Web framework, inspired from Symphony or
> > Laravel. Security and ease of use first, continuations later.
> > Better documentation: Racket docs are aesthetically very pleasing,
> complete
> > and detailed. However some parts are still very obscure and lacking
> simple
> > examples (if only the part about Continuations included just one basic
> > example, such as a ‘return’ implementation, on the very first page. If
> only
> > the Macros documentation started with define-simple-macro and a few very
> > basic, practical examples. Instead we’re greeted with pattern-based
> macros,
> > which although very powerful, are very hard to comprehend for newcomers).
>
> Which of these things will you be working on?
>

I'll step up.

Matt, I need some help with Scribble and how to contribute to the Racket
docs.  I'd be willing to pay for a couple hours of your time (or whomever
else's has the skill/knowledge) to walk me through that.  After that I'll
be happy to pitch in by offering documentation patches.  This will be a big
help for me, since I'm finding myself having trouble writing docs for my
own code.


>
>
> >   I am well aware that what I’m wishing for isn’t necessarily compatible
> with
> > Racket’s intended public’s needs (comp-sci teachers and students? That’s
> the
> > impression I’m getting). But Racket is the most advanced general purpose
> > programming tool I’ve ever seen. Wouldn’t it be a shame if it was
> limited to
> > academic use?
>
> https://www.youtube.com/watch?v=LN0qG-i1iT0=youtu.be
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/5ea97134.1c69fb81.8c167.2c68SMTPIN_ADDED_MISSING%40gmr-mx.google.com
> .
>

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


Re: [racket-users] Functions not being linked in scribble

2020-04-28 Thread David Storrs
On Tue, Apr 28, 2020 at 11:41 AM Sam Tobin-Hochstadt 
wrote:

> I believe you're missing a `defmodule` inside test.scrbl.
>

Aha.  Okay, I:

*) Added @defmodule[test] to the test.scrbl file
*) Created a main.rkt that did (require "test.rkt") and (provide
(all-from-out "test.rkt"))
*) Did a raco pkg install to ensure that test was a recognized collection.
*) scribble test.scrbl

At that point it works correctly.   Thank you!


> Sam
>
> On Tue, Apr 28, 2020 at 11:32 AM David Storrs 
> wrote:
> >
> > Here's my test code.  I get the test.html file out at the end and, as
> expected, the explanation of bar says "Calls foo" with foo in blue with a
> red line underneath.  What am I missing?
> >
> >
> > ; test.rkt
> > #lang racket
> > (provide (all-defined-out))
> > (define (foo) 7)
> > (define (bar) (foo))
> >
> > --
> >
> > ; test.scrbl
> > #lang scribble/manual
> > @(require (for-label racket "test.rkt"))
> > @title{My Library}
> > @defproc[(foo) any]{Returns 7}
> > @defproc[(bar) any]{Calls @racket[foo]}
> >
> > --
> >
> > ; command line
> >
> > $ racket
> > Welcome to Racket v7.6.
> > > (require "test.rkt")
> > > (bar)
> > 7
> >
> >
> > $ scribble test.scrbl
> >
> > Output:
> > test.scrbl:6:10: WARNING: no declared exporting libraries for definition
> >   in: foo
> > test.scrbl:8:10: WARNING: no declared exporting libraries for definition
> >   in: bar
> >  [Output to test.html]
> > Warning: some cross references may be broken due to undefined tags:
> >  (dep (# bar))
> >  (dep ((lib "racket/contract/base.rkt") any))
> >  (dep ((lib "racket/contract.rkt") any))
> >  (dep ((lib "racket/contract/private/misc.rkt") any))
> >  (dep (# foo))
> >  (dep ((lib "racket/main.rkt") any))
> >
> >
> > On Tue, Apr 28, 2020 at 11:00 AM Ben Greenman <
> benjaminlgreen...@gmail.com> wrote:
> >>
> >> On 4/28/20, David Storrs  wrote:
> >> > According to what I see in Scribble, both actual examples and in the
> >> > documentation, I had thought that if I did @defproc[func-name] then
> >> > func-name would become a link target and later uses of
> @racket[func-name]
> >> > would automatically link to that site.  I'm clearly missing
> something; my
> >> > functions are being rendered in link style but they have red links
> under
> >> > them and are not actually links.  Can someone point me in the right
> >> > direction?
> >>
> >> Did you (require (for-label  func-name)) ?
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> >> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAFUu9R5%3Dk-WHJ87FHFbLFj-XWy9%2BhMrsVGXcGfeA834s25EfVg%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/CAE8gKodfM9TON5T7hwjQ6XPUCKGHdv98Rx-cX%2BFDo6ALXLg36A%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/CAE8gKoeyYV_dx6QgLfXeqkD1JojOQSpN9ejQYO%3DMtcYYUL7Z5g%40mail.gmail.com.


Re: [racket-users] Functions not being linked in scribble

2020-04-28 Thread David Storrs
Here's my test code.  I get the test.html file out at the end and, as
expected, the explanation of bar says "Calls foo" with foo in blue with a
red line underneath.  What am I missing?


; test.rkt
#lang racket
(provide (all-defined-out))
(define (foo) 7)
(define (bar) (foo))

--

; test.scrbl
#lang scribble/manual
@(require (for-label racket "test.rkt"))
@title{My Library}
@defproc[(foo) any]{Returns 7}
@defproc[(bar) any]{Calls @racket[foo]}

--

; command line

$ racket
Welcome to Racket v7.6.
> (require "test.rkt")
> (bar)
7


$ scribble test.scrbl

Output:
test.scrbl:6:10: WARNING: no declared exporting libraries for definition
  in: foo
test.scrbl:8:10: WARNING: no declared exporting libraries for definition
  in: bar
 [Output to test.html]
Warning: some cross references may be broken due to undefined tags:
 (dep (# bar))
 (dep ((lib "racket/contract/base.rkt") any))
 (dep ((lib "racket/contract.rkt") any))
 (dep ((lib "racket/contract/private/misc.rkt") any))
 (dep (# foo))
 (dep ((lib "racket/main.rkt") any))


On Tue, Apr 28, 2020 at 11:00 AM Ben Greenman 
wrote:

> On 4/28/20, David Storrs  wrote:
> > According to what I see in Scribble, both actual examples and in the
> > documentation, I had thought that if I did @defproc[func-name] then
> > func-name would become a link target and later uses of @racket[func-name]
> > would automatically link to that site.  I'm clearly missing something; my
> > functions are being rendered in link style but they have red links under
> > them and are not actually links.  Can someone point me in the right
> > direction?
>
> Did you (require (for-label  func-name)) ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAFUu9R5%3Dk-WHJ87FHFbLFj-XWy9%2BhMrsVGXcGfeA834s25EfVg%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/CAE8gKodfM9TON5T7hwjQ6XPUCKGHdv98Rx-cX%2BFDo6ALXLg36A%40mail.gmail.com.


Re: [racket-users] Rhombus project plan

2020-04-28 Thread David Storrs
I'll throw this in simply so that it's part of this thread.  There's
nothing new here, so if you've seen my comments in earlier Racket2 threads
then you can skip this.

I've said before and continue to think that getting rid of the parenthesis
syntax is a major error.  It is inarguable that there are significant
advantages to parenthesis syntax -- to name a few: No need to memorize
precedence tables, ease of code serialization and composition, extreme
friendliness to parsers and generators.  So far as I've seen, no one has
yet presented an argument in support of eliminating parenthesis notation
aside from "My students will find it easier."  That may or may not be true
but I find myself unconvinced that it is the major barrier to widespread
adoption.  I believe that people are not avoiding Racket primarily because
it has parentheses, they are avoiding it because it's one more thing to
learn, it's a huge language with sometimes daunting documentation, and they
aren't sold that the advantages will outweigh the effort + lack of
applicability to getting a job.  That's a matter for evangelism and
documentation development, not a language rewrite.

The Racket documentation is very impressive -- it's aesthetically
beautiful, it's thorough, and once you get comfortable with BNF the
Reference becomes very useful.  The documentation also has some weak
points, such as the Reference needing more examples, and it would be
helpful to have a visual distinction between the Guide and the Reference so
that when links point back and forth it's easy to tell which one you're in.
More importantly, it's very difficult to contribute to the documentation
without a lot of effort due to the literate programming style of needlessly
templatized chunks, link targets that don't match page URLs, and excessive
numbers of repositories with filetree layouts that are not intuitive.  (Or,
at least, aren't intuitive for *me*.  I don't think I'm smarter than the
average bear but I'm an experienced developer who has contributed to
multiple open source projects and I don't think it should be this difficult
to figure out.)  I'm good at documentation and would be delighted to
contribute a ton of it if those barriers to entry were lower.


On Wed, Oct 2, 2019 at 3:27 PM Matthew Flatt  wrote:

> [[NOTE: "Rhombus" is the new name for a design project formerly known
>   as "Racket2", but "Rhombus" IS NOT THE FINAL NAME OF THE NEW LANGUAGE.
>
>   "Rhombus" is the name of the project that will develop a language,
>   and "Rhombus" is a temporary stand-in for a language name to be
>   determined later. Phase 3 of the plan includes the mandatory step of
>   picking a new language name.]]
>
> Rhombus is about building on the good parts of Racket and advancing the
> frontier of Racket-style language-oriented programming. A significant
> part of the experiment is trying a surface syntax other than
> parenthesized prefix notation. Another part is simplifying and
> generalizing elements of `#lang racket`, such as its data structures
> for streams and binding with integrated and extensible
> pattern-matching. While some of these goals could be pursued
> independently, taking them together offers opportunities to make the
> whole language fit together better.
>
> Whether Rhombus will become a suitable alternative for current `#lang
> racket` can be determined only as the experiment progresses. It starts
> with that ambition, but the project may fail. It may fail for technical
> reasons, process reasons, or social reasons:
>
>  - On the technical side, we're trying to do something new.
>
>  - On the process side, we are trying a more visible and open approach
>than we have used for past major changes, even to the point of
>opening up the early exploratory phase.
>
>  - On the social side, we hope that skeptical Racketeers will make room
>for the experiment and understand that putting the experiment in the
>open (and being up-front about development costs) is part of the
>more open process.
>
> Matthew Flatt will lead the project with the guidance and consent of
> Racket project leadership. In early phases of the experiment, Matthew
> is responsible for delegating and deciding when the next phase starts.
> Toward the end of the process, Racket leadership is responsible for
> deciding whether to continue. Community participation is built into the
> process by keeping the design discussion open and by using an RFC
> process for the eventual design elements.
>
>
> What Will Happen to Racket During Rhombus
> -
>
> The Racket team will continue to maintain the language and its
> implementations:
>
>  - The existing ecosystem will continue to function as always.
>
>  - Existing `#lang racket` programs will continue to run, just as in
>the 6.x and 7.x series of releases.
>
>  - The team will release updated versions, occasionally making modest
>incompatibilities with explicit transition paths as needed 

[racket-users] Functions not being linked in scribble

2020-04-28 Thread David Storrs
According to what I see in Scribble, both actual examples and in the
documentation, I had thought that if I did @defproc[func-name] then
func-name would become a link target and later uses of @racket[func-name]
would automatically link to that site.  I'm clearly missing something; my
functions are being rendered in link style but they have red links under
them and are not actually links.  Can someone point me in the right
direction?

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


Re: [racket-users] visit a sequence of files

2020-04-21 Thread David Storrs
Ah, got it.  Well, as to opening all the files, you can select them all in
Finder and Cmd+O.  (Presumably the equivalent works on Windows.) Can't help
you with the aesthetics, sorry.

On Tue, Apr 21, 2020 at 4:38 PM John Clements 
wrote:

> Well, sure… once you open all the files. Opening all the files is the
> painful part. Also, the display of tabs is not totally great when you have
> sixty or seventy of them open. Sorry, it might not have been clear that I
> want a list of sixty or seventy files.
>
> John
>
> > On Apr 21, 2020, at 1:34 PM, David Storrs 
> wrote:
> >
> > I don't use DrRacket much, but would the normal 'previous / next window'
> commands work for you?  On Mac it's:
> > previous window:  Shft + Cmd + ~
> > next window: Cmd + ~
> >
> > or
> >
> > previous window: Cmd + 
> > next window: Cmd + 
> >
> > On Tue, Apr 21, 2020 at 4:29 PM 'John Clements' via Racket Users <
> racket-users@googlegroups.com> wrote:
> > Here’s a question I have about both DrRacket and Emacs. It often happens
> in my workflow (grading files, for instance) that I want to set up a list
> of files, and then have an easy way to move forward or back in that list
> (“next file”, “previous file”). I see that emacs has a function called
> “next-file” which can move forward and back in a list of files apparently
> specified by a tags-table file; is that the easiest way to do something
> like this in emacs, or am I missing something obvious? In DrRacket, I’m
> guessing that there’s no existing functionality that would allow me to
> specify a list of files and move back and forth between them. I’m guessing
> I could implement something like this pretty easily … would this be a good
> job for Laurent Orseau’s Quickscript?
> >
> > I would absolutely love to hear that I’ve missed something obvious!
> >
> > Many thanks!
> >
> > John
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/38dfc78b-4d01-4ac1-b1cd-2e4b372c2d09%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/CAE8gKocQ1gLeA6QSqqDWdFV5nQRhrgu0L1bRZxCnr_Hpd32J_A%40mail.gmail.com.


Re: [racket-users] [racket users] struct #:methods question

2020-04-21 Thread David Storrs
On Mon, Apr 20, 2020 at 6:50 PM Jon Zeppieri  wrote:

> There's no trick to it:
>
> #lang racket/base
>
> (require racket/generic)
>
> (define-generics foo
>   (foo-do foo x))
>
> (struct thing (x)
>   #:methods gen:foo
>   [(define (foo-do f x)
>  (thing x))])
>
>
> On Mon, Apr 20, 2020 at 6:32 PM Kevin Forchione  wrote:
> >
> > Hi guys,
> > How do you return an instance of the structure type from the struct’s
> #:methods? This is would seem to be a common situation, but it has me
> stumped.
> >
> > Kevin
>



Note that if you're getting fancy with structs then you might want to check
out: https://docs.racket-lang.org/struct-plus-plus/index.html

Among other things, it auto-generates functional setters and functional
updaters, a keyword constructor, dotted accessors, reflection data, and
allows for contracts on individual fields and enforcement of relationships
between fields.



>
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/EE404363-995C-4888-8B43-E463EB3C7418%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/CAKfDxxx6b2yq6Sn6zzr49oZqGXc5h4CA-Vj%3DVYEkLbmaBOi3Pg%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/CAE8gKof3k4GdbTerX-ss2uJCg7jQB2XWvC59P1SKYUbuCnrXgg%40mail.gmail.com.


Re: [racket-users] visit a sequence of files

2020-04-21 Thread David Storrs
I don't use DrRacket much, but would the normal 'previous / next window'
commands work for you?  On Mac it's:
previous window:  Shft + Cmd + ~
next window: Cmd + ~

or

previous window: Cmd + 
next window: Cmd + 

On Tue, Apr 21, 2020 at 4:29 PM 'John Clements' via Racket Users <
racket-users@googlegroups.com> wrote:

> Here’s a question I have about both DrRacket and Emacs. It often happens
> in my workflow (grading files, for instance) that I want to set up a list
> of files, and then have an easy way to move forward or back in that list
> (“next file”, “previous file”). I see that emacs has a function called
> “next-file” which can move forward and back in a list of files apparently
> specified by a tags-table file; is that the easiest way to do something
> like this in emacs, or am I missing something obvious? In DrRacket, I’m
> guessing that there’s no existing functionality that would allow me to
> specify a list of files and move back and forth between them. I’m guessing
> I could implement something like this pretty easily … would this be a good
> job for Laurent Orseau’s Quickscript?
>
> I would absolutely love to hear that I’ve missed something obvious!
>
> Many thanks!
>
> John
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/38dfc78b-4d01-4ac1-b1cd-2e4b372c2d09%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/CAE8gKodjBKkjdUE_gzyFZpVVJHd%2BnWYg%3D%2BN4bGKvT9W7ci4e-A%40mail.gmail.com.


Re: [racket-users] New to racket, help with coursework question

2020-04-20 Thread David Storrs
Great job!

For the record: Yes, it is entirely possible to have an 'if' clause choose
the arguments to a function. This is legal:

(define first-element (vector-ref some-vector (if (equal? type
'zero-indexed) 0 1)))

As is this, which is more relevant to your exercise:

(define leap-year-months (vector 0 31 29 31 30 31 30 31 31 30 31 30 31))
(define ordinary-year-months (vector 0 31 28 31 30 31 30 31 31 30 31 30 31))

(vector-ref (if (is-leap-year? month) leap-year-months
ordinary-year-months) month)


The other people in the thread have already given great advice, but I'll
toss in my $0.02 for how to approach programming in general:

1) Be sure that the problem is clearly defined.  Look for edge cases and
get them nailed down as early as possible.
2) Figure out how *you*, an intelligent human being, would solve the
problem if asked to do it manually
3) Make the computer do that.

This won't solve every problem and it won't necessarily result in the most
elegant or efficient solution, but it will generally get you *a* solution,
which is the important part.   You can always optimize something but you
can't optimize nothing.

For example, if the owner of BigCompany asks you to "Figure out how many
people work here", you might do something like this:

1) Define the problem and look for edge cases
- Does 'here' mean only people working in the physical building, or do
remote employees count?

- Do you include only full-time W-2 employees?  What about contractors?
Part-timers?  People like janitors and plant-maintenance staff who aren't
employed by BigCompany but are employed by a service company that
BigCompany retains and do jobs related to BigCompany?


2) Figure out how you would solve it yourself.
- Check with HR to get the number of people employed by BigCompany
- Check with the office manager to find out all the third-party companies
that provide services to BigCompany
- Ask each of those companies how many people they have working on
BigCompany-related tasks


3) Make the computer do that
- Connect to the HR database and do a query for all people employed by
BigCompany
- Connect to the OM's database and do a query for all service companies
retained by BigCompany
- Connect to the HR databases of each of those service companies and do a
query for all of their employees who are assigned to work on
BigCompany-related tasks



The number-of-days challenge was probably pretty frustrating, but hopefully
the 'aha' moment at the end was worth it.  Stick with it; computer
programming is often frustrating, but it's also immensely rewarding.  The
sheer joy of creation added to the knowledge that your software **actually
does something that helps people** is a wonderful feeling.

On Mon, Apr 20, 2020, 1:34 AM Kristina Marie  wrote:

> I wanted to thank you all. I did it! My head hurts, but now seeing how
> simple it was, it hurts that it hurts.
>
> ;leap year
> (define (leap-year? year)
>   (and (zero? (modulo year 4))
>(or (not (zero? (modulo year 100)))
>   (zero? (modulo year 400))
>   )
>)
>   )
>
> ;Months with days vector, beginning at an index of 0 since there is not
> 0th month
> (define leap-year-months (vector 0 31 29 31 30 31 30 31 31 30 31 30 31))
> (define ordinary-year-months (vector 0 31 28 31 30 31 30 31 31 30 31 30
> 31))
>
> (check-expect(days-in-month 2016 1)31)
> (check-expect(days-in-month 2016 11)30)
> (check-expect(days-in-month 2016 12)31)
> (check-expect(days-in-month 1900 2)28)
> (check-expect(days-in-month 2000 2)29)
> (check-expect(days-in-month 2016 2)29)
> (check-expect(days-in-month 2200 2)28)
>
>
> (define (days-in-month x y)
>   (cond
> [(leap-year? x) (vector-ref leap-year-months y)]
> [else (vector-ref ordinary-year-months y)]
> )
>   )
>
> On Sun, Apr 19, 2020 at 2:39 PM Matt Jadud  wrote:
>
>> This is good. Your questions are good, and while the
>> frustration/confusion is real, don't let it get you down. It's just part of
>> the process. (That is, learning often involves confusion and frustration.)
>>
>> This might step it back too far, but see if this helps a bit. Your
>> question about what you can put in the definition suggests that you're in a
>> good place, but you've got a lot of ideas swimming around all at once.
>> Let's try this.
>>
>> A function definition has a pattern to it.
>>
>> (define (__A__ __B__)
>>   __C__)
>>
>> When you look at a definition, you want to look for that pattern. Use
>> DrRacket's highlighting to help you see the pieces if you need to. I find
>> it handy all the time.
>>
>> "A" is the name of the thing you are defining, "B" is a parameter, and
>> "C" is the body. There can, of course, be multiple parameters. Then, the
>> pattern looks like:
>>
>> (define (__A__ __B1__ __B2__)
>>   __C__)
>>
>> assuming you have a function definition with two parameters.
>>
>> Making it a bit more concrete, you could have a function like this:
>>
>> ;; CONTRACT
>> ;; number -> number
>> (define (add-one n)
>>   (+ n 

Re: [racket-users] DrRacket and command line arguments

2020-04-18 Thread David Storrs
Okay, so "edit the file" is the answer.  That works for me.  Thanks!

On Sat, Apr 18, 2020 at 2:30 PM Michael MacLeod 
wrote:

> You can parameterize `current-command-line-arguments` like so:
>
> ```
> #lang racket
>
> (require racket/cmdline)
>
> (define foo (make-parameter 7))
>
> (parameterize ([current-command-line-arguments #("--thing" "9")])
>   (command-line
>#:program "foo"
>#:once-each
>[("--thing") thing "The thing" (foo thing)])
>   (displayln (foo)))
> ```
>
> See the docs
> <https://docs.racket-lang.org/reference/runtime.html?q=current%2Dcommand%2Dline%2Darguments#%28def._%28%28quote._~23~25kernel%29._current-command-line-arguments%29%29>
> for more information.
>
>
> On Sat, Apr 18, 2020 at 11:03 AM David Storrs 
> wrote:
>
>>
>> Is there a way to specify command line arguments when running inside
>> DrRacket?
>>
>> For example:
>>
>> #lang racket
>> (define foo (make-parameter 7))
>> (command-line
>>  #:program "foo"
>>  #:once-each
>>  [("--thing") thing "The thing" (foo thing)]
>>  )
>> (displayln (foo))
>>
>>
>> If running in DrRacket, how can I make this spit out 9 instead of 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/CAE8gKocbjLNy%3D9S-g4HSc6WmOJf2TAsd7LOzbEYGQsm%3DYLGLAg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAE8gKocbjLNy%3D9S-g4HSc6WmOJf2TAsd7LOzbEYGQsm%3DYLGLAg%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/CAE8gKodKGSnJj4eXZX6rXpLA7yomBywMtakCGn_G6M5AM-JfKA%40mail.gmail.com.


[racket-users] DrRacket and command line arguments

2020-04-18 Thread David Storrs
Is there a way to specify command line arguments when running inside
DrRacket?

For example:

#lang racket
(define foo (make-parameter 7))
(command-line
 #:program "foo"
 #:once-each
 [("--thing") thing "The thing" (foo thing)]
 )
(displayln (foo))


If running in DrRacket, how can I make this spit out 9 instead of 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/CAE8gKocbjLNy%3D9S-g4HSc6WmOJf2TAsd7LOzbEYGQsm%3DYLGLAg%40mail.gmail.com.


Re: [racket-users] Gradual Typed Racket?

2020-04-17 Thread David Storrs
On Fri, Apr 17, 2020 at 9:45 AM Ben Greenman 
wrote:

> Hi Marc,
>
>
> >> For contracts, though, (provide (contract-out ...)) gives better error
> >> messages than define/contract.
> >>
> >
> > In what sense is this the case, and where can I read more about the
> > differences, as well as how to improve errors of contracts?
>
> contract-out gives better error messages than define/contract in the
> sense that it has better blame
>
> A define/contract needs to immediately decide who could be blamed for
> future errors --- because the new definition can be used right away.
>
> A contract-out can wait until another module requires the definition
> --- and tailor its blame errors to different clients.
>

My understanding is that contract-out only provides protection against
inappropriate calls from clients *outside* the module, whereas
define/contract enforces the contract against everyone, including things
inside the module.  Do I have that right?  If so, I feel much more
comfortable using the latter even if its error messages are not quite as
good.

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


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

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


[racket-users] ports->ssl-ports issues, plus DTLS question

2020-04-10 Thread David Storrs
We are trying to use TLS (or, more specifically, DTLS) over UDP.  In order
to do this we create an input-port?/output-port? pair via make-pipe and
then run the pair through ports->ssl-ports.  The handshake this causes is
failing and therefore the whole process hangs and the ports don't get
converted.  We have a couple questions:

1) Does the Racket openssl library (i.e. (require openssl)) implement DTLS?

2) What might be causing the failure?  (Hopefully) minimal code is below;
we have been banging our heads on it and could use some advice.


; Pseudo code, simplified from live code and not tested

(define server-ctx (ssl-make-server-context 'tls12))
(ssl-load-certificate-chain!  server-ctx pem)
(ssl-load-private-key!server-ctx pem)
(ssl-server-context-enable-ecdhe! server-ctx 'secp521r1)

(define client-ctx (ssl-make-client-context 'tls12))
(ssl-set-ciphers! client-ctx "ECDHE-RSA-AES128-SHA256")

(define rx-in-ch  (make-async-channel))
(define sock (udp-open-socket))
(udp-bind! sock ...)

(define-values (rx-in1 rx-out1) (make-pipe size))
(define-values (tx-in1 tx-out1) (make-pipe size))

(define-values (rx-in tx-out)
   (ports->ssl-ports rx-in1 tx-out1
#:mode   'accept
#:contextserver-ctx
#:close-original?#t
#:shutdown-on-close? #t))

; the 'connect version is elided for brevity



;;;  Rx
; sync on the UDP socket.  When data is received, async-channel-put it onto
rx-in-ch.
; sync on rx-in-ch.  When data is received, write it onto rx-out port from
make-pipe
; sync on rx-in port from make-pipe.  When data is received it will be
processed by a handler function

;;; Tx
; the handler function writes to tx-out
; sync on tx-in.  When data is received, a handler will udp-send-to onto
the UDP socket

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


Re: [racket-users] Are there interfaces for IP ports at least raw sockets?

2020-04-02 Thread David Storrs
On Thu, Apr 2, 2020 at 1:32 PM George Neuner  wrote:
>
>
> On 4/2/2020 1:00 PM, David Storrs wrote:
> > On Thu, Apr 2, 2020 at 12:37 PM George Neuner  wrote:
> > >
> > > Windows historically placed a lot of limitations on the use of raw 
> > > sockets.
> > > https://docs.microsoft.com/en-us/windows/win32/winsock/tcp-ip-raw-sockets-2
> > >
> > > There doesn't seem to be any updated information on Win10, so you might
> > > conclude that it has the same limitations as Win7.
> >
> > Doesn't surprise me.  Fortunately, I don't need it for Windows, at
> > least right now.
>
> But it is because of Windows that Racket doesn't provide raw (or Unix)
> sockets.  Racket tries to support all of its features across all target
> platforms.

I mean...Racket tries to be memory-safe etc, but it also has libraries
like 'unsafe/foo'.  There's already a unix-sockets library
(https://docs.racket-lang.org/unix-socket/index.html) that is
Unix-only, which I found after starting this thread.  Why not have
core modules like unix/sockets and windows/thing-that-only-windows-has
?  Seems more useful than simply not having the functionality at all.

>
>
> > > Re: ICMP, I think it should be possible to implement at least some of
> > > the functions (not sure about all of them) ... but it will have to be
> > > done via FFI.
> >
> > Cool thanks.  Do you happen to know what library I should be FFI'ing
> > into, ideally for macOS?
>
> Sorry, I don't know MacOS.  In Unix it would be libsocket, and if you
> are using GCC then glibc transitively links libsocket and re-exports the
> entire socket API.

Great, 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/CAE8gKoe8-9%2Bi6tuTOGk3T0SXHHnihmxtYnxix%3DP%2Ba5WZ6u8Nig%40mail.gmail.com.


Re: [racket-users] Are there interfaces for IP ports at least raw sockets?

2020-04-02 Thread David Storrs
On Thu, Apr 2, 2020 at 1:15 PM Sam Tobin-Hochstadt  wrote:
>
> Here's some C source code which should point to the right functions:
> https://www.geeksforgeeks.org/ping-in-c/
>
> I think you can just use `#f` for the library -- all the functions
> should be from libc.

Much appreciated.

>
> Sam
>
> On Thu, Apr 2, 2020 at 1:00 PM David Storrs  wrote:
> >
> > On Thu, Apr 2, 2020 at 12:37 PM George Neuner  wrote:
> > >
> > >
> > > On 4/2/2020 11:13 AM, David Storrs wrote:
> > > > The Reference lists TCP and UDP but nothing else.  I'd like to be able
> > > > to implement ICMP, since there doesn't seem to be such a thing at the
> > > > moment, and I'm trying to figure out how to do that.
> > > >
> > > > In an ideal world I'd have something like ip-in and ip-out ports as
> > > > the complement to tcp-in and tcp-out ports and then I could simply
> > > > hand the ip-out port some bytes that constitute an ICMP or etc packet
> > > > and away it goes.  Failing that, if I can get a raw socket then I
> > > > could do the IP stuff on top of it; with that in hand it would be
> > > > (more) straightforward to implement other protocols.
> > > >
> > > > Is there a way to do this in Racket?
> > >
> > > Windows historically placed a lot of limitations on the use of raw 
> > > sockets.
> > > https://docs.microsoft.com/en-us/windows/win32/winsock/tcp-ip-raw-sockets-2
> > >
> > > There doesn't seem to be any updated information on Win10, so you might
> > > conclude that it has the same limitations as Win7.
> >
> > Doesn't surprise me.  Fortunately, I don't need it for Windows, at
> > least right now.
> >
> > > Re: ICMP, I think it should be possible to implement at least some of
> > > the functions (not sure about all of them) ... but it will have to be
> > > done via FFI.
> >
> > Cool thanks.  Do you happen to know what library I should be FFI'ing
> > into, ideally for macOS?  Trying to find information on using ICMP
> > programmatically tends to result in things like:  return
> > subprocess("ping hostname")
> >
> > >
> > > 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/bc77f87f-378c-6d5c-3875-3270cb25134b%40comcast.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/CAE8gKodjbeVWqdJRKKYEvYspg%3DDtDTk4GbWQeqHCk4kQ%2BPahZA%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/CAE8gKoce%2BX5XzbBSM39Mua%3DNJEPxyxiDqrTchu_u40eqm4_www%40mail.gmail.com.


Re: [racket-users] Are there interfaces for IP ports at least raw sockets?

2020-04-02 Thread David Storrs
On Thu, Apr 2, 2020 at 12:37 PM George Neuner  wrote:
>
>
> On 4/2/2020 11:13 AM, David Storrs wrote:
> > The Reference lists TCP and UDP but nothing else.  I'd like to be able
> > to implement ICMP, since there doesn't seem to be such a thing at the
> > moment, and I'm trying to figure out how to do that.
> >
> > In an ideal world I'd have something like ip-in and ip-out ports as
> > the complement to tcp-in and tcp-out ports and then I could simply
> > hand the ip-out port some bytes that constitute an ICMP or etc packet
> > and away it goes.  Failing that, if I can get a raw socket then I
> > could do the IP stuff on top of it; with that in hand it would be
> > (more) straightforward to implement other protocols.
> >
> > Is there a way to do this in Racket?
>
> Windows historically placed a lot of limitations on the use of raw sockets.
> https://docs.microsoft.com/en-us/windows/win32/winsock/tcp-ip-raw-sockets-2
>
> There doesn't seem to be any updated information on Win10, so you might
> conclude that it has the same limitations as Win7.

Doesn't surprise me.  Fortunately, I don't need it for Windows, at
least right now.

> Re: ICMP, I think it should be possible to implement at least some of
> the functions (not sure about all of them) ... but it will have to be
> done via FFI.

Cool thanks.  Do you happen to know what library I should be FFI'ing
into, ideally for macOS?  Trying to find information on using ICMP
programmatically tends to result in things like:  return
subprocess("ping hostname")

>
> 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/bc77f87f-378c-6d5c-3875-3270cb25134b%40comcast.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/CAE8gKodjbeVWqdJRKKYEvYspg%3DDtDTk4GbWQeqHCk4kQ%2BPahZA%40mail.gmail.com.


[racket-users] Are there interfaces for IP ports at least raw sockets?

2020-04-02 Thread David Storrs
The Reference lists TCP and UDP but nothing else.  I'd like to be able
to implement ICMP, since there doesn't seem to be such a thing at the
moment, and I'm trying to figure out how to do that.

In an ideal world I'd have something like ip-in and ip-out ports as
the complement to tcp-in and tcp-out ports and then I could simply
hand the ip-out port some bytes that constitute an ICMP or etc packet
and away it goes.  Failing that, if I can get a raw socket then I
could do the IP stuff on top of it; with that in hand it would be
(more) straightforward to implement other protocols.

Is there a way to do this in Racket?

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


Re: [racket-users] racket/draw: how to extract the path from a font% object?

2020-04-01 Thread David Storrs
I knocked together a very minimal pure-Racket library for this so you
don't have to FFI.  It won't give you all the bells and whistles, but
it should be a good starting point.

https://pkgd.racket-lang.org/pkgn/package/font-finder

Docs:   https://github.com/dstorrs/font-finder/blob/master/README.md

Newly arrived on a package server near you.

...where I note there is a newly-created package named 'fontland' that
was put up by Matthew and probably does all this and more.  Doh.

Well, hopefully this helps a little bit.




On Wed, Apr 1, 2020 at 2:48 PM Matthew Butterick  wrote:
>
> The answer is you can't, through pure Racket, because Racket delegates the 
> nitty-gritty of font-file resolution to external font-handling libraries.
>
> It is possible, however, to call into the `fontconfig` library via the FFI 
> and make it do the heavy lifting of 1) scanning font directories to amass a 
> list of possible fonts and then 2) finding a match for a certain query 
> pattern, say a family name.
>
>
>
> On Mar 31, 2020, at 4:52 PM, Matthew Butterick  wrote:
>
> IIUC every `font%` object must correspond to a particular font file on disk.
>
> If so, given a `font%` object, how do I extract the path to that file?
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/C28B01B3-4772-4AA4-899C-78DADE7B8B2A%40mbtype.com.

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


[racket-users] Is there an ICMP library?

2020-04-01 Thread David Storrs
Is there a way to generate ICMP messages from Racket, the way there is
a UDP and TCP library?  My Google-fu is apparently insufficient and
the Reference doesn't include anything.

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


[racket-users] UDP networking issue

2020-03-27 Thread David Storrs
This isn't a Racket question per se, but I'm hoping someone here will
have a suggestion.  We're working on NAT traversal, it's failing to
connect, and we aren't clear why.

On hostname Alice on the LAN:

(define s (udp-open-socket))
(udp-bind! s #f 3)
(udp-send-to s "18.218.67.59" 54545 #"hi")


Over on the EC2 instance at 18.218.67.59:54545:

(define s (udp-open-socket))
(udp-bind! s #f 54545)
(define buffer (make-bytes 50))
(udp-receive! s buffer)
Bytes received: 2
Source IP:  "76.127.206.145"
Source port:  3

This shouldn't be the case.  Alice has a socket bound to 3 on that
local machine, but when the message is sent to the router, the router
should choose a new external port number.  That's what this particular
router has done in the past and we aren't sure why that would have
changed.  Still, it wouldn't be an issue except that it's also not
accepting traffic as expected.  More on that below.

This router uses (used to use, since everything is uncertain now)
symmetric NAT, so it will only forward traffic from address X back to
Alice if she had previously sent traffic to address X.  (As opposed
to, e.g. full cone NAT where any traffic arriving at the port would be
forwarded and Alice could sort out what to do with it.)  The problem
is that traffic isn't being forwarded even when it should be.
Demonstration follows, using Alice and Bob (two instances on our LAN)
and the EC2 server from above.  We are deliberately forcing everything
to use the public IP instead of going across the local network.

Alice and Bob hold a continuous connection to EC2 server.
The router's IP is 76.127.206.145, which I'll type as R for
convenience.  R:4 therefore means 76.127.206.145, port 4.

Alice -> server:  I want to talk to Bob
server -> Alice: He's connected to me from R:4
Alice -> R:4 ping

[Router should note that Alice tried to talk to R:4 and shoul
start accepting traffic for her from that address.  Message will not
be received by Bob because he has not previously talked to Alice.]

server -> Bob: Alice wants to talk to you. She's at R:3
Bob -> R:3 ping

[Router should note that Bob tried to talk to R:3 and should start
accepting traffic for him from that address.  Message should be
received by Alice, since she already had the mapping set up to listen
for Bob's messages]

Alice -> R:4 ping

[Message should be received by Bob, since he was already listening for Alice]


That's normal STUN-based NAT traversal, and we had it working until
recently.  Now it's failing and we're unsure what has changed that
would affect it.

Then we get to our next issue, which is that the router is not
choosing different ports for outbound connections to different
machines.  In the past, what we've seen is this:

On Alice:

(define s (udp-open-socket))
(udp-bind! s #f 3)
(udp-send-to s "18.218.67.59" 54545 #"hi")  ; EC2 server, instance #1
(udp-send-to s "18.218.67.59" 63212 #"hi")  ; EC2 server, instance #2

The instance running at 54545 used to see the message as coming from
an arbitrary remote port, e.g., 41378.
The instance running at 63212 used to see the message as coming from a
  different remote port, e.g., 41379.
Now, both instances see the message as coming from port 3.

When we were seeing different external ports we could use the
difference between them to make a prediction about what our next
outbound UDP port would be and leverage that into connecting despite
having symmetric NATs at both ends of the connection (which STUN will
not handle).  Unfortunately, now both servers are reporting the same
port number:  3.

To summarize, we have two separate issues that are probably related:

1) The router is re-using the local port as the external port
2) It's not accepting traffic from an address that has already been
sent to from that port

We're pretty stumped here and could use a hint.  Anyone have thoughts
on where to look?
(udp-bind! s 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/CAE8gKoc28kfZAOo9TLmonTL8Go%2BBYbbBFBFMv5WW_uA7AP9pxQ%40mail.gmail.com.


Re: [racket-users] Arbitrary property types on structs?

2020-03-25 Thread David Storrs
Got it. I'm actually relieved that this isn't possible, since it means I
wasn't simply being dumb.



On Wed, Mar 25, 2020, 7:41 PM Sam Phillips  wrote:

> On 2020-03-25 14:16, David Storrs wrote:
> > This would let me use a struct as an output port:
> >
> > (struct foo (name out) #:property prop:output-port (struct-field-index
> out))
> >
> > I'd like to be able to set up a struct such that I can use it as a UDP
> > socket, something like the following pseudo-code:
> >
> > (struct foo (socket) #:property prop:udp (struct-field-index socket))
> >
> > I see that Racket defines prop:input-port and prop:output-port, but
> > there's no prop:udp, nor can I figure out how to do it through the
> > structure type properties or generic interfaces.  (I feel like I'm
> > missing something on those two, so maybe it's just poor understanding.)
> >
> > Is there a way to do this?
>
> The way those properties work is that functions that use input-ports and
> outputs-ports have knowledge about the properties and check if it is a
> struct with those properties.  There is no prop:udp though.  You could
> make one (like the following), but you would need to make your own
> wrappers of the existing udp-* functions and have them do the coercion
> before passing arguments to the existing racket functions.
>
> Cheers,
> Sam
>
> --- >8 --- >8 ---
>
> #lang racket/base
>
> (require (prefix-in - racket/udp))
>
> (define-values (prop:udp prop:udp? udp-socket-ref)
>(make-struct-type-property
> 'prop:udp
> (lambda (val struct-info)
>   (cond
> [(procedure? val) val]
> [(exact-nonnegative-integer? val)
>  ; XXX: check for valid index
>  (let ([struct-ref (list-ref struct-info 3)])
>(lambda (a-struct-value)
>  (struct-ref a-struct-value val)))]
>
> (define (->udp-socket v)
>(cond
>  [(-udp? v) v]
>  [else
>   (->udp-socket ((udp-socket-ref v) v))]))
>
> ;; Something like this for every udp function
> (define (udp-bind! socket hostname-string port-no [reuse? #f])
>(-udp-bind! (->udp-socket socket)
>hostname-string
>port-no
>reuse?))
>
> (struct server (socket)
>#:property
>prop:udp (struct-field-index socket)
>#:transparent)
>
> (define (make-server)
>(let ([udp (-udp-open-socket)])
>  (server udp)))
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/34622180-8073-1e61-8187-f7d9dc48b236%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/CAE8gKofUwGm7YexxvLJkMA9gtfRoW_ixr948WNwMShD_0-iA1g%40mail.gmail.com.


[racket-users] Arbitrary property types on structs?

2020-03-25 Thread David Storrs
This would let me use a struct as an output port:

(struct foo (name out) #:property prop:output-port (struct-field-index out))

I'd like to be able to set up a struct such that I can use it as a UDP
socket, something like the following pseudo-code:

(struct foo (socket) #:property prop:udp (struct-field-index socket))

I see that Racket defines prop:input-port and prop:output-port, but there's
no prop:udp, nor can I figure out how to do it through the structure type
properties or generic interfaces.  (I feel like I'm missing something on
those two, so maybe it's just poor understanding.)

Is there a way to do this?

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


Re: [racket-users] Best way to say "terminate unless received by X time"

2020-03-24 Thread David Storrs
Aha! I didn't know there was a udp-receive-evt. That's exactly what I
needed, thank you.

On Tue, Mar 24, 2020, 4:15 PM Jon Zeppieri  wrote:

> On Tue, Mar 24, 2020 at 4:03 PM David Storrs 
> wrote:
> >
> > I've got this code:
> >
> > (thread
> >   (thunk
> > (let loop ()
> >   (define-values (len shost sport) (udp-receive! socket buffer))
> >   ...do stuff with the received message...
> >  (loop
> >
> > I'd like to be able to say "If you haven't received a message in X time,
> kill the thread".  I'm not sure how to enact that; sync/timeout won't do it
> since the thread won't return.  I've thought of weird signaling systems
> using channels or set! on some external value or etc, but they are all
> terrible.
> >
> > What's the right way to do this?
> >
>
> Not quite sure what you mean when you say "sync/timeout won't do it
> since the thread won't return." You'll know when you timed-out, so you
> can return in that case. Wouldn't something like this work?
>
> ```
> (thread
>  (λ ()
>(let loop ()
>  (match (sync/timeout timeout (udp-receive!-evt socket buffer))
>[(list len shost sport)
> ;; do stuff
> (loop)]
>[#f
> ;; timed out; exit the loop and the thread
> (void)]
> ```
>
> Apologies if I've misunderstood you.
>
> - Jon
>

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


[racket-users] Best way to say "terminate unless received by X time"

2020-03-24 Thread David Storrs
I've got this code:

(thread
  (thunk
(let loop ()
  (define-values (len shost sport) (udp-receive! socket buffer))
  ...do stuff with the received message...
 (loop

I'd like to be able to say "If you haven't received a message in X time,
kill the thread".  I'm not sure how to enact that; sync/timeout won't do it
since the thread won't return.  I've thought of weird signaling systems
using channels or set! on some external value or etc, but they are all
terrible.

What's the right way to do this?

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


Re: [racket-users] Contracts on parameters

2020-03-23 Thread David Storrs
Thanks, that was exactly it.

On Mon, Mar 23, 2020 at 3:51 PM Michael MacLeod
 wrote:
>
> I think you are looking for parameter/c. See 
> https://docs.racket-lang.org/reference/data-structure-contracts.html?q=parameterof#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._parameter%2Fc%29%29
>  for more information.
>
> Best,
> Michael
>
> On Mon, Mar 23, 2020, 12:36 PM David Storrs  wrote:
>>
>> (define/contract (foo x)
>>   (-> boolean? any)
>>   'ok)
>>
>> (foo #t)
>> 'ok
>> (foo 7)
>> ; foo: contract violation
>> ;   expected: boolean?
>> ;   given: 7
>> ;   in: the 1st argument of
>> ;   (-> boolean? any)
>> ;   contract from: (function foo)
>> ;   blaming: top-level
>> ;(assuming the contract is correct)
>> ;   at: readline-input:4.18
>> ; [,bt for context]
>>
>> Yup, all good.
>>
>>
>> (define/contract foo (make-parameter #f) boolean?)
>> (foo #t)
>> (foo)
>> #t
>> (foo 7)
>> #f
>>
>>
>> This isn't what I expected.  What am I missing?
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/CAE8gKocV-TC1U6g5sq7C%2BZAjSVqDc%2B4yZWobr245qx4fZ9%2Bi3w%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/CAE8gKodRytXdXTEb72RBFJ1jCiJDmHjCtgjCE6vmSZi74tQiVw%40mail.gmail.com.


[racket-users] Contracts on parameters

2020-03-23 Thread David Storrs
(define/contract (foo x)
  (-> boolean? any)
  'ok)

(foo #t)
'ok
(foo 7)
; foo: contract violation
;   expected: boolean?
;   given: 7
;   in: the 1st argument of
;   (-> boolean? any)
;   contract from: (function foo)
;   blaming: top-level
;(assuming the contract is correct)
;   at: readline-input:4.18
; [,bt for context]

Yup, all good.


(define/contract foo (make-parameter #f) boolean?)
(foo #t)
(foo)
#t
(foo 7)
#f


This isn't what I expected.  What am I missing?

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


Re: [racket-users] Terminal Phase hits 1.0

2020-01-19 Thread David Storrs
Oh, cool.  It's Defender in ASCII art.  Neat idea, and I'm interested to
see how to do cursor positioning in Racket.  Thanks for the link.

On Sun, Jan 19, 2020 at 10:57 PM Christopher Lemmer Webber <
cweb...@dustycloud.org> wrote:

> Hello,
>
> Just a small blogpost about Terminal Phase, which hit 1.0:
>
>   https://dustycloud.org/blog/terminal-phase-1.0/
>
> I think the game is pretty interesting.  Anyway, you can try it
> yourself:
>
>   raco pkg install terminal-phase
>   raco terminal-phase
>
> (I guess it also installs a launcher thing.)
>
> This is all related to Spritely Goblins, and for more on that, here's a
> video:
>
>   https://www.youtube.com/watch?v=wxt2dqqulQc
>
> But... that video is quite long.  A more condensed Spritely Goblins
> video coming soon-ish.
>
> Anyway, hope you have some fun hammering away at your space key!
>
>  - cwebb
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/87pnfe4w5b.fsf%40dustycloud.org
> .
>

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


[racket-users] Logging to STDOUT and to file

2020-01-15 Thread David Storrs
At runtime I can use PLTSTDERR to specify which log messages are displayed
to STDOUT.  Is there a way to specify at runtime *where* they should be
logged?  That is, is there a built-in that does this:

PLTSTDERR="debug@the-logger error"  racket foo.rkt | tee foo.log

...except without using tee?  tee is interfering with my program for some
reason, and if there's a simple way to resolve this then I'd rather not
spend the time figuring out what's going on.

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


Re: [racket-users] Re: Racket2 and syntax

2020-01-13 Thread David Storrs
On Mon, Jan 13, 2020 at 10:38 AM John Cowan  wrote:

>
>
> On Sunday, July 14, 2019 at 10:30:04 PM UTC-4, Matthew Flatt wrote:
>
> At RacketCon today, after summarizing the state of work on Racket CS, I
>> recommended that we next explore the possibly of changing to an
>> infix-oriented syntax in "Racket2".
>>
>
> I realize that Racket2 is the name of the project, but I think it's very
> important that the *language* of the project gets its own unique name.
> Otherwise outsiders will see it as the successor, the important one, the
> one they should use by default, because they will think Racket1 (which will
> quickly become the human-oriented name of the existing language) has become
> obsolete.  Larry Wall just changed the name of Perl 6 to Raku, and this is
> a Good Thing, because it deflects the "When are you going to replace Perl
> 5?" question.
>

+1


>
>
> John Cowan  http://vrici.lojban.org/~cowanco...@ccil.org
> I don't know half of you half as well as I should like, and I like less
> than half of you half as well as you deserve.  --Bilbo
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/2f002c9e-61f2-4fd4-8014-0cd3d4e61853%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/CAE8gKoc4%2BZTAa8iEpgM8sF6jGv8vmX3Z-C7rW-tWLC8wtjzuYg%40mail.gmail.com.


Re: [racket-users] racket-mode finds wrong version of Racket

2019-12-16 Thread David Storrs
Thanks, Bruno. Much appreciated.

On Mon, Dec 16, 2019, 12:56 PM bruno cuconato  wrote:

> Emacs has a few ways to update environment variables (see
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Environment.html
> ),
> but IMHO they are not very practical if updating several variables — I
> always prefer to simply restart Emacs, or not to add anything to $PATH
> but to symlink files to somewhere in my PATH (when that approach is
> viable).
>
>
> since you are using OSX,
> https://github.com/purcell/exec-path-from-shell might be useful to
> you.
>
> -- bruno cuconato
>
> On Mon, 16 Dec 2019 at 14:28, David Storrs  wrote:
> >
> > I just now updated to 7.5 from 7.3, then updated my .bashrc to have the
> correct path.  I'm using GNU Emacs in Terminal on OSX 10.11.
> >
> >
> > $ echo $PATH
> > [...stuff that isn't
> Racket...]:/Applications/Racket_v7.5.0.10/bin:[...stuff that isn't
> Racket...]
> >
> > From a .rkt file:
> > C-c C-c
> > Welcome to Racket v7.3.
> >
> > ; Kill the Racket command server buffer
> > C-x C-k
> >
> > ; back to the .rkt file, try again
> > C-c C-c
> > Welcome to Racket v7.3.
> >
> > ; kill and restart emacs
> > C-x C-c
> > $ emacs
> > C-c C-c
> > Welcome to Racket v7.3.
> >
> > Killing and restarting Terminal and reloading Emacs from scratch finally
> worked.
> >
> > Is there any way that I could have resolved this without getting quite
> so nuclear?  I googled around and could not find anything.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKodzUn8ZU4Yd2eV26xrBKyb0XW0mSBRNuj5WmE_ZtQW3MA%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/CAE8gKoeKDamfbd5nUR%3D%3DHK0FTafGjuCT8sZ%3D3Do%2B8qCq8a%2BMcg%40mail.gmail.com.


[racket-users] racket-mode finds wrong version of Racket

2019-12-16 Thread David Storrs
I just now updated to 7.5 from 7.3, then updated my .bashrc to have the
correct path.  I'm using GNU Emacs in Terminal on OSX 10.11.


$ echo $PATH
[...stuff that isn't
Racket...]:/Applications/Racket_v7.5.0.10/bin:[...stuff that isn't
Racket...]

>From a .rkt file:
C-c C-c
Welcome to Racket v7.3.

; Kill the Racket command server buffer
C-x C-k

; back to the .rkt file, try again
C-c C-c
Welcome to Racket v7.3.

; kill and restart emacs
C-x C-c
$ emacs
C-c C-c
Welcome to Racket v7.3.

Killing and restarting Terminal and reloading Emacs from scratch finally
worked.

Is there any way that I could have resolved this without getting quite so
nuclear?  I googled around and could not find anything.

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


Re: [racket-users] Racket 7.5 DMG file does not open on OSX 10.11

2019-12-11 Thread David Storrs
Brilliant.  Downloaded, installed, works great.  Thanks, Matthew.

On Wed, Dec 11, 2019 at 11:00 AM Matthew Flatt  wrote:

> At the moment, we don't have plans to rebuild v7.5, so the change would
> kick in with v7.6.
>
> The snapshot builds use HFS+ --- but they did, anyway, since they're
> created with an older version of Mac OS.
>
> At Wed, 11 Dec 2019 10:45:08 -0500, David Storrs wrote:
> > Thanks, Matthew,
> >
> > The version on the downloads page seems to still be APFS.  Will it
> rebuild
> > at some point?
> >
> > On Tue, Dec 10, 2019 at 8:46 PM Matthew Flatt 
> wrote:
> >
> > > I’ve changed the distribution build to use HFS+ going forward.
> > >
> > > > On Dec 10, 2019, at 6:28 PM, James Platt  wrote:
> > > >
> > > >
> > > >> On Dec 6, 2019, at 9:56 PM, Darth Vadør wrote:
> > > >>
> > > >> If it isn't too much trouble, I at least would really appreciate
> this.
> > > >> One reason I think this is important is because Homebrew has a cask
> for
> > > Racket, which uses the .dmg distribution. It sets up $PATH (and
> probably
> > > other things I don't know about as well), and can update Racket for
> you,
> > > which is quite pleasant.
> > > >>
> > > >> If the maintainers of the cask see there is an easy way to support
> > > older Macs they might (fingers crossed) consider it.
> > > >
> > > > I would also like to have an HFS+ formatted dmg as an option.
> However,
> > > Homebrew has dropped support for El Capitan and earlier but it
> continues to
> > > work (most of the time) if you already had a previous version
> installed.
> > > Everything after El Capitan can read APFS.   So, the maintainers of the
> > > cask might decide that any new legacy support would be short lived.
> > > >
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > Groups "Racket Users" group.
> > > > To unsubscribe from this group and stop receiving emails from it,
> send
> > > an email to racket-users+unsubscr...@googlegroups.com.
> > > > To view this discussion on the web visit
> > >
> >
> https://groups.google.com/d/msgid/racket-users/EDDD1A40-9C10-4F2B-8A07-6933784C
> > 5C41%40biomantica.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/FFE82A21-AE9E-49F0-9F55-76E47C32
> > D58B%40cs.utah.edu
> > > .
> > >
>

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


Re: [racket-users] Racket 7.5 DMG file does not open on OSX 10.11

2019-12-11 Thread David Storrs
Thanks, Matthew,

The version on the downloads page seems to still be APFS.  Will it rebuild
at some point?

On Tue, Dec 10, 2019 at 8:46 PM Matthew Flatt  wrote:

> I’ve changed the distribution build to use HFS+ going forward.
>
> > On Dec 10, 2019, at 6:28 PM, James Platt  wrote:
> >
> >
> >> On Dec 6, 2019, at 9:56 PM, Darth Vadør wrote:
> >>
> >> If it isn't too much trouble, I at least would really appreciate this.
> >> One reason I think this is important is because Homebrew has a cask for
> Racket, which uses the .dmg distribution. It sets up $PATH (and probably
> other things I don't know about as well), and can update Racket for you,
> which is quite pleasant.
> >>
> >> If the maintainers of the cask see there is an easy way to support
> older Macs they might (fingers crossed) consider it.
> >
> > I would also like to have an HFS+ formatted dmg as an option.  However,
> Homebrew has dropped support for El Capitan and earlier but it continues to
> work (most of the time) if you already had a previous version installed.
> Everything after El Capitan can read APFS.   So, the maintainers of the
> cask might decide that any new legacy support would be short lived.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/EDDD1A40-9C10-4F2B-8A07-6933784C5C41%40biomantica.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/FFE82A21-AE9E-49F0-9F55-76E47C32D58B%40cs.utah.edu
> .
>

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


Re: [racket-users] Sharing a udp socket between threads via parameters

2019-12-05 Thread David Storrs
Cool, thanks!

On Thu, Dec 5, 2019, 4:11 PM Matthew Flatt  wrote:

> At Thu, 5 Dec 2019 14:26:17 -0500, David Storrs wrote:
> > My understanding is that parameters are copied between threads, but I'm
> not
> > sure how this interacts with things like file ports, network connections,
> > etc.  Would the following code be problematic?
> >
> >
> > (define conn (make-parameter))
> > (define s (udp-open-socket))
> > (udp-bind! s #f  12345)
> > (conn s)
> >
> > (thread (thunk (udp-send-to (conn) "8.8.8.8" 5 #"hi from bob")))
> > (thread (thunk (udp-send-to (conn) "8.8.8.8" 5 #"hi from fred")))
>
> Yes, this works.
>
> As you say, a thread inherits parameter values (at the time that the
> thread is created) from its creating thread, and a UDP socket can be
> used from multiple threads at once and isn't tied to any particular
> thread, so using `(conn)` in different threads is fine.
>
>

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


Re: [racket-users] Re: GUI (get-directory)

2019-12-05 Thread David Storrs
For the record, my big concern with the documentation is that it's
extremely hard to contribute to.  I would be delighted to contribute
documentation if the process was easy, but it's just not.  For a language
as amazing as Racket and a documentation set as high-quality as Racket's,
the difficulty of helping with it is surprising.

tl;dr :  Using literate programming techniques(*) for documentation is a
bad idea.  So is having random tiny files scattered around instead of one
single .scrbl file in a location that maps to the URL of the page.

(*) (i.e., having random tiny files with documentation on one particular
thing and then automating the process of assembling them)


My understanding is that the sequence goes like this:

1) Notice a thing you would like to change (a typo fix, add an example, etc)
1a) Ask on the mailing list how to contribute changes since the Guide /
Reference / package does not have clear directions built in
2) Go to Github
3) Find which racket-related repository is the one that matters for this
documentation.  The Racket project itself has half a dozen repositories and
it's not obvious (to me, at least) which one is which.  Things on the
package server will have a direct link, which helps a lot.
4) git fork the appropriate repository, git clone it to your local machine
5) grep -r through the clone to find the document that you want to modify.
It will not be in a location apparent from the URL of the page you were
looking at, nor will it be named what that page was named, nor will it
contain all of the content from that page.  Also, it will be in Scribble,
which is a DSL that requires non-trivial effort to learn and is non-trivial
to read.  Still, it produces amazing output so that's probably worth it.
It's intimidating when you're just getting started, though.
6a) make your change
6b) google for how to rebuild scribble documentation
6c) rebuild (by default this will rebuild all documentation), verify you
made the change correctly
7) git commit, git push
8) go back to github and submit a pull request
9) (when (eq? (sync pr-msg-ch) 'Accepted) (exit))
10) make requested changes
11) git commit, git push, goto 9

Compare that to what it looks like in, e.g., Perl

1) Notice a thing you would like to change (a typo fix, add an example, etc)
2) got to CPAN and search for the package / tutorial / etc.  clicking on
the name of the package gets you a listing of all files in the package (cf
https://metacpan.org/release/ETHER/Moose-2.2012)
3) click on the 'Package::Name::Contributing' file and do what it says.
This will probably be similar to the Racket workflow except that:

a) The complete details are spelled out.
b) There is a link directly to the repository
c) The location of the file you need to edit is obvious from the URL of the
documentation page that you're changing
d) The file contains the complete text of the page so it's easier to find
and easier to verify that your edits were correct
e) The file is in POD, which is so simple that you can generally learn what
you need just from glancing at the file, and it's easier to read than
Scribble.  It's simple enough that you generally don't need to rebuild it
to HTML, but if you choose to then you can easily rebuild just that page.

Example of a Contributing file:
https://metacpan.org/pod/release/ETHER/Moose-2.2012/lib/Moose/Manual/Contributing.pod

  (NB:  All major Perl packages have a Contributing file and the 'create a
package' tool for generating Perl modules creates a stub version for you so
it's hard to forget.  If the author somehow *does* forget and the package
doesn't have its own Contributing file then CPAN will show you a default
version that contains all critical information.  Also, it's easy to find
the Contributing file:  Go to the package listing that's available directly
on CPAN and Ctrl+F for "Contributing")



On Tue, Dec 3, 2019 at 5:26 PM James Platt  wrote:

>
> On Nov 25, 2019, at 1:29 PM, Stephen De Gabrielle wrote:
>
> > Many packages contain an /examples folder, and adding examples is an
> easy way to contribute.
>
> I did not know that.  So, I guess the strategy is to find the git
> repository for the package and look there?  In any case, I haven't been
> finding these examples with a general web search.
>
> >
> > There is also https://github.com/racket/racket/wiki/Artifacts
> >
> >> This page captures useful code snippets that are too small to be a
> package.
> >>
> >> Please contribute your own!
> >
> > Though these might be better places in documentation, or in /examples
>
> That artifacts wiki a good thing to know about.  Most of these are a
> little more complex than I am thinking are good for documentation but I may
> well contribute some small but useful code.  I sometimes create my own
> examples as I go because I often look back through my own code to refresh
> my memory on how to do something.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To 

[racket-users] Sharing a udp socket between threads via parameters

2019-12-05 Thread David Storrs
My understanding is that parameters are copied between threads, but I'm not
sure how this interacts with things like file ports, network connections,
etc.  Would the following code be problematic?


(define conn (make-parameter))
(define s (udp-open-socket))
(udp-bind! s #f  12345)
(conn s)

(thread (thunk (udp-send-to (conn) "8.8.8.8" 5 #"hi from bob")))
(thread (thunk (udp-send-to (conn) "8.8.8.8" 5 #"hi from fred")))

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


Re: [racket-users] contract for an "overloaded function"

2019-11-29 Thread David Storrs
I think you want `case->`:
https://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._case-~3e%29%29

On Fri, Nov 29, 2019 at 2:28 PM Ryan Kramer 
wrote:

> I'm not exactly sure what I mean by "overloaded function", but I think you
> will understand. I'm looking for something that would allow me to write a
> function contract like
>
> (magic-> [integer? integer? -> integer?]
>  [string? symbol? -> string?]
>  [string? ...+ -> string?])
>
> The above contract would mean:
>   * If the function is given an argument list that satisfies (cons/c
> integer? (cons/c integer? null?)), then the return value must be an integer?
>   * Else if the function is given an argument list that satisfies (cons/c
> string? (cons/c symbol? null?)), then the return value must be a string?
>   * Else if the function is given an argument list that satisfies (cons/c
> string? (list/c string?)), then the return value must be a string?
>   * Else the caller is blamed for not providing correct arguments.
>
> (I don't think I need support for keyword arguments)
>
> Does this already exist in a library somewhere? If not, it doesn't look
> too hard for me to roll my own but I am (perhaps prematurely) concerned
> about the performance. Would the following approach be reasonable?
>
> (define-syntax-rule (magic-> [dom ... range-expr] ...)
>   ; We should make sure that every dom and range is a flat-contract?
>   (make-contract
>#:name '(magic-> [dom ... range-expr] ...)
>#:first-order procedure?
>#:projection
>(λ (blame)
>  (λ (proc)
>(λ args
>  (cond
>[((list/c dom ...) args)
> (let ([range ((contract-projection range-expr) blame)])
>   (range (apply proc args)))]
>...
>[else
> (raise-blame-error
>  (blame-swap blame) args
>  '(expected "a conforming argument list" given: "~e")
>  args)]))
>
> (define/contract (blah a b)
>   (magic-> [integer? string? list?]
>[string? integer? (list/c string? integer?)]
>; This one will throw a contract violation
>[integer? integer? integer?])
>   (list a b))
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/b21a5512-521f-4c6e-8e4e-ca6d3528df8c%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/CAE8gKoeGJvoP9wfgcmtX%3DopVa9F%2BJzTE6JN7ZjsC%3DcbuxEGNww%40mail.gmail.com.


[racket-users] Racket 7.5 DMG file does not open on OSX 10.11

2019-11-25 Thread David Storrs
When I download and install the .dmg file from racket-lang, I'm told "no
mountable filesystems".  I'm not sure if this is an issue with how it was
built, with my machine, or with OSX in general.

This may not be worth worrying about, since OSX 10.11 was released
September 30, 2015 and Apple has decided that something from four years ago
is FAR too old to worry about backwards compatibility. (grumble, grumble)

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


Re: [racket-users] polymorphic datastructures in typed/racket

2019-11-18 Thread David Storrs
On Mon, Nov 18, 2019 at 12:23 PM David Storrs 
wrote:

>
>
> On Mon, Nov 18, 2019 at 10:09 AM Sam Tobin-Hochstadt 
> wrote:
>
>>
>> Third, your version with structs can't work because you can't tell
>> what type a function expects -- that information is not there at
>> runtime.
>>
>
> If there is a contract assigned to a function, is it possible to get that
> function and analyze it?
>

Correction:  Get that *contract* and analyze it.


>
>> Sam
>>
>> On Wed, Nov 6, 2019 at 2:51 PM bedeke  wrote:
>> >
>> > Hello,
>> >
>> > I was trying to type some polymorphic classes but I got stuck early on
>> making a polymorphic subclass
>> >
>> > #lang typed/racket/base
>> >
>> > ;*1*
>> > (require typed/racket/class)
>> >
>> > (define-type (C-class A)(Class [init-field [x A]]))
>> >
>> > (define C1%
>> >  (class object%
>> >  #:∀ (A)
>> >  (init-field [x : A])
>> >  (super-new)))
>> >
>> > (define C2%
>> >  (class (inst C1% A)
>> >  #:∀ (A)
>> >  (super-new)))
>> >
>> > (new (inst C2% Integer) [x 4])
>> >
>> > C1% is recognised as a C-class, but explicitly calling C1% a C-class
>> (omitting the #:forall (A) ) doesn't work
>> > In the next step I don't seem to find the right way to make C2% a
>> polymorphic subclass of C1%
>> >
>> >
>> >
>> > Having failed that I went with structures. This I got mostly working,
>> but I would like to have some niceties.
>> > One was to parameterize a structure, but this lead to a problem of not
>> being able to check some
>> > types at runtime. I thought I got close, but I stranded on getting
>> fields of structures without knowing the instantiation type
>> > ;*2*
>> > (struct (A) S ([f1 : (-> A A A)]
>> >[f2 : (-> A Boolean : A)]))
>> >
>> > (: S-of-type? (-> (-> Any Boolean : A) Any Boolean
>> >   : #:+ (implies #t (S A))
>> > #:- (implies #f (! (S A)
>> > (define (S-of-type? fct A)
>> >   (and (S? A) (eq? fct (S-f2 A
>> > ;  ^ how can I acces a field of this polymorfic
>> struct
>> >
>> >
>> >
>> > And another thing I tried but failed to get working is to sub-type a
>> structure based
>> > on a narrower type for one of the fields.
>> > ;*3*
>> > (struct (A) B ([f1 : (Vectorof A)]
>> >[f2 : Integer])
>> >   #:transparent)
>> >
>> > (: B1? (All (A) (-> (B A) Boolean)))
>> > (define (B1? b)(= (B-f2 b) 1))
>> > (define b (B (vector 3) 1))
>> > (assert b B1?)
>> > b
>> > (define-type B1 B1?)
>> > ;(define-new-subtype B1 B1?)
>> > ;(define-type B1 (All (A)(Struct (B (Vectorof A) 1
>> >
>> >
>> > Are any of these things doable? Or are there better ways to tackle this
>> problems?
>> >
>> >
>> > What I got working is in
>> >
>> https://github.com/bdeket/polynomials/blob/alg-dic-pol/polynomials/math/private/polynomial/poly-struct.rkt
>> (WIP)
>> >
>> > Kind regards,
>> > Bert
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Racket Users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to racket-users+unsubscr...@googlegroups.com.
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/3c4bcedd-5677-4972-97a3-04e33ca30816%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/CAK%3DHD%2BaE1h7tYT4nyRoAgUhVCWCNmJfvJ5V5QTzCcbwv_kvJhA%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/CAE8gKodq4Y_sFnCdTXtOP4OrZxckhajxejOOqwyN3j0wTe7_EQ%40mail.gmail.com.


Re: [racket-users] polymorphic datastructures in typed/racket

2019-11-18 Thread David Storrs
On Mon, Nov 18, 2019 at 10:09 AM Sam Tobin-Hochstadt 
wrote:

>
> Third, your version with structs can't work because you can't tell
> what type a function expects -- that information is not there at
> runtime.
>

If there is a contract assigned to a function, is it possible to get that
function and analyze it?


> Sam
>
> On Wed, Nov 6, 2019 at 2:51 PM bedeke  wrote:
> >
> > Hello,
> >
> > I was trying to type some polymorphic classes but I got stuck early on
> making a polymorphic subclass
> >
> > #lang typed/racket/base
> >
> > ;*1*
> > (require typed/racket/class)
> >
> > (define-type (C-class A)(Class [init-field [x A]]))
> >
> > (define C1%
> >  (class object%
> >  #:∀ (A)
> >  (init-field [x : A])
> >  (super-new)))
> >
> > (define C2%
> >  (class (inst C1% A)
> >  #:∀ (A)
> >  (super-new)))
> >
> > (new (inst C2% Integer) [x 4])
> >
> > C1% is recognised as a C-class, but explicitly calling C1% a C-class
> (omitting the #:forall (A) ) doesn't work
> > In the next step I don't seem to find the right way to make C2% a
> polymorphic subclass of C1%
> >
> >
> >
> > Having failed that I went with structures. This I got mostly working,
> but I would like to have some niceties.
> > One was to parameterize a structure, but this lead to a problem of not
> being able to check some
> > types at runtime. I thought I got close, but I stranded on getting
> fields of structures without knowing the instantiation type
> > ;*2*
> > (struct (A) S ([f1 : (-> A A A)]
> >[f2 : (-> A Boolean : A)]))
> >
> > (: S-of-type? (-> (-> Any Boolean : A) Any Boolean
> >   : #:+ (implies #t (S A))
> > #:- (implies #f (! (S A)
> > (define (S-of-type? fct A)
> >   (and (S? A) (eq? fct (S-f2 A
> > ;  ^ how can I acces a field of this polymorfic
> struct
> >
> >
> >
> > And another thing I tried but failed to get working is to sub-type a
> structure based
> > on a narrower type for one of the fields.
> > ;*3*
> > (struct (A) B ([f1 : (Vectorof A)]
> >[f2 : Integer])
> >   #:transparent)
> >
> > (: B1? (All (A) (-> (B A) Boolean)))
> > (define (B1? b)(= (B-f2 b) 1))
> > (define b (B (vector 3) 1))
> > (assert b B1?)
> > b
> > (define-type B1 B1?)
> > ;(define-new-subtype B1 B1?)
> > ;(define-type B1 (All (A)(Struct (B (Vectorof A) 1
> >
> >
> > Are any of these things doable? Or are there better ways to tackle this
> problems?
> >
> >
> > What I got working is in
> >
> https://github.com/bdeket/polynomials/blob/alg-dic-pol/polynomials/math/private/polynomial/poly-struct.rkt
> (WIP)
> >
> > Kind regards,
> > Bert
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/3c4bcedd-5677-4972-97a3-04e33ca30816%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/CAK%3DHD%2BaE1h7tYT4nyRoAgUhVCWCNmJfvJ5V5QTzCcbwv_kvJhA%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/CAE8gKodTMUAokaSpjVmz6qhnKWJJx9R0nQ4%2BPcYBv3CGZ4uf5w%40mail.gmail.com.


Re: [racket-users] Anyone who has mastered DrRacket

2019-11-11 Thread David Storrs
Hi Mahmmadullah,

It sounds like you're asking for help with homework. I suspect there will
be general reluctance to help you with that in more than general terms, and
also reluctance to provide a personal contact address. Why don't you try
asking the list directly, without including actual scans?

To have the best chance of getting answers, your questions should:

- Be clear and simple
- Be general. Avoid "what is the result of this expression" questions.
- Include details about what you've already tried and any error messages
you got.

Some examples:

Bad: "Here is a specification. Please give me code."

Probable answer: Total silence.


Better: "I'm building a simple webserver and having trouble with HTML
parsing. I can't figure out how to handle attributes. Any suggestions?"

Probable answer: "Take a look at the html-parsing package or one of the
equivalents. Alternatively, if you are required to write it yourself, try
accumulating them together using 'for/hash'."


Best: "I'm building a simple webserver and when I try to connect it throws
exn: network:foo and spits out the following error stack. I think the issue
is in the chunk of code I've included below, but I have no idea what it
might be in particular. Help?"

Probable answer: "You didn't  and here is some code to fix it. Also,
you could simplify things like this . Don't forget about ; you can find more in ."





On Mon, Nov 11, 2019, 7:56 AM Mahmmadullah Obaidi 
wrote:

> Hello I am a computer engineering student studying DrRacket. I need
> someone who can help me out in worksheets anyone can give his/her number so
> I can send my worksheet photos to them. Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/daaa7c79-9876-4285-abe1-a4d83533a896%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/CAE8gKodAYx%3DwDZSamkORAt57-PQLz9HyymHMqrHhhxtqu_3L2g%40mail.gmail.com.


Re: [racket-users] Evaluating to get the output with a specific lang

2019-11-11 Thread David Storrs
Don't forget to handle multiple value return. What will you do if the last
line in the file is (values a b)?

Also, side effects. Do you care if someone includes a print/write/display
statement? You mentioned that the code would be safe, so presumably
tcp-connect and sqlite3-connect are not issues.

On Sun, Nov 10, 2019, 4:44 PM Christopher Lemmer Webber <
cweb...@dustycloud.org> wrote:

> Well, I think I figured out how to get further:
>
> with example1.rkt being:
>
> ```
> #lang racket/base
> ;; #lang dungeon/misery
>
> (define ((make-start-game read-save-file) player-name)
>   (list 'running-this-read-save-file: read-save-file
> 'on-player-name: player-name
> 'result: (read-save-file player-name)))
>
> (define (entrypoint read-save-file)
>   (make-keyword-procedure
>(lambda (kws kw-args method-name . args)
>  (define method
>(case method-name
>  ['start-game (make-start-game read-save-file)]
>  ['what-is-make-start-game (lambda () make-start-game)]
>  ['throw-error
>   (lambda ()
> (error "oh no :("))]
>  [else (error "owch!")]))
>  (keyword-apply method kws kw-args args
>
> (provide entrypoint)
> ```
>
> It seems I'm able to read things in:
>
> ```
> read-example.rkt> (parameterize ([current-namespace
>(module->namespace 'racket/base)]
>   [read-accept-reader #t])
>  (define stx
>(call-with-input-file "example1.rkt"
>  (lambda (ip)
>(read-syntax 'my-module ip
>  (eval stx)
>  (eval '(require 'example1))
>  (dynamic-require ''example1 'entrypoint))
> #
> ```
>
> I know that's kludgy, but it seems closer to being on track.  Thanks to
> everyone who has responded.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/87sgmvh0dr.fsf%40dustycloud.org
> .
>

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


Re: [racket-users] Version number issue with snapshot 7.5.0.6

2019-11-04 Thread David Storrs
On Mon, Nov 4, 2019 at 11:47 AM Matthew Flatt  wrote:
>
> At Mon, 4 Nov 2019 11:30:49 -0500, David Storrs wrote:
> > read-compiled-linklet: version mismatch  expected: "7.5.0.5"  found:
> > "7.5.0.6"  in:
> > /Applications/snapshot_Racket_v7.5.0.6/collects/racket/compiled/main_rkt.zo
> >
> > I'm on OSX 10.11.6 if that matters.
>
> I'm not yet able to replicate this problem. Can you say more about
> which installer you downloaded and what command you ran to get that
> error?

Huh, odd.

I downloaded 
https://www.cs.utah.edu/plt/snapshots/current/installers/racket-7.5.0.6-x86_64-macosx.dmg
and I was running a bunch of local-built networking code.  I had to do
some faffing about to get PLTCOLLECTS and such set up properly, so it
may be a purely my-problem problem.

One thing I did find odd:

$ which raco
/Applications/snapshot_Racket_v7.5.0.6/bin/raco

$ raco pkg install handy
/Applications/snapshot_Racket_v7.5.0.6/bin/raco: Unrecognized command: pkg

Usage: raco   ...  ...

Frequently used commands:
  docs search and view documentation
  make compile source to bytecode
  planet   manage Planet package installations
  exe  create executable
  test run tests associated with files/directories

A command can be specified by an unambiguous prefix.
See `raco help' for a complete list of commands.
See `raco help ' for help on a command.

$ raco help
Usage: raco   ...  ...

Frequently used commands:
  docs search and view documentation
  make compile source to bytecode
  planet   manage Planet package installations
  exe  create executable
  test run tests associated with files/directories

All available commands:
  check-requires   check for useless requires
  contract-profile profile overhead from contracts
  ctoolcompile and link C-based extensions
  decompiledecompile bytecode
  demodularize produce a whole program from a single module
  dependencies-graph   opens a GUI window showing transitive module
dependencies (aka `Module Browser')
  distribute   prepare executable(s) in a directory for distribution
  docs search and view documentation
  exe  create executable
  expand   macro-expand source
  macro-profiler   profile macro expansion (code size)
  macro-stepperexplore expansion steps
  make compile source to bytecode
  pack pack files/collections into a .plt archive
  planet   manage Planet package installations
  profile  profile execution time
  read read and pretty-print source
  scribble render a Scribble document
  show-dependenciesshow module dependencies
  slideshowrender a Slideshow document
  test run tests associated with files/directories
  unpack   unpack files/collections from a .plt archive

A command can be specified by an unambiguous prefix.
See `raco help ' for help on a command.


This is probably a mistake on my end, and it may fix itself once the
recompile finishes (maybe?) but why would the pkg command be missing?


>
> (I tried the current NWU "Racket plus Tests" snapshot, the current Utah
> "Racket" snapshot, and yesterday's Utah "Racket" snapshot, all for
> x86_64 Mac OS and running `racket` and `drracket`. Installation was by
> dragging the folder to my desktop.)
>
> Based on the path name, that ".zo" file really should be version
> "7.5.0.6", so I'm not clear on why the executable expects a different
> version.
>

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


Re: [racket-users] Version number issue with snapshot 7.5.0.6

2019-11-04 Thread David Storrs
On Mon, Nov 4, 2019 at 11:44 AM John Clements  wrote:
>
> Forgive me if I’m missing something important, but I see messages like this 
> all the time when I’m using two installations of racket simultaneously on one 
> machine. It suggests to me that you need to recompile using a raco make, or 
> just delete the compiled files. Again, apologies if I’m misunderstanding your 
> issue!

No, you're exactly right, and I'm in the process of compiling.  I was
simply surprised that the shipped version (albeit in a nightly
snapshot) had this issue and wanted to call it out.

>
> John Clements
>
> > On Nov 4, 2019, at 08:30, David Storrs  wrote:
> >
> > read-compiled-linklet: version mismatch  expected: "7.5.0.5"  found:
> > "7.5.0.6"  in: 
> > /Applications/snapshot_Racket_v7.5.0.6/collects/racket/compiled/main_rkt.zo
> >
> > I'm on OSX 10.11.6 if that matters.
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/racket-users/CAE8gKocTtpS1LJMJ_v1XHpoCFUFdUyyshU1a-MgQFjxhxdmwiw%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/CAE8gKocQx%3D8Qydoxdt0suUNaztJx7as8Y7o_XbhXLYgjALGepQ%40mail.gmail.com.


[racket-users] Version number issue with snapshot 7.5.0.6

2019-11-04 Thread David Storrs
read-compiled-linklet: version mismatch  expected: "7.5.0.5"  found:
"7.5.0.6"  in: 
/Applications/snapshot_Racket_v7.5.0.6/collects/racket/compiled/main_rkt.zo

I'm on OSX 10.11.6 if that matters.

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


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

2019-10-25 Thread David Storrs
On Fri, Oct 25, 2019 at 10:28 AM Thomas Dickerson
 wrote:
>
> For reasons that are unclear to me, hash-keys and dict-keys both return a 
> list? instead of a set? (frankly, this seems like a bug in the API...).
>
> Is there a something I can do that's more efficient than just calling 
> list->set?

You could do   '(apply set list-of-keys)', although I'm not sure if
that's more efficient or not.  You'd need to benchmark it.


>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/36eb8bd7-45eb-4ebb-be30-ebdfd89023fe%40googlegroups.com.

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


Re: [racket-users] Remind me?: bidirectional channel-ish thing in two parts

2019-10-25 Thread David Storrs
Yep!  That was it.  Thanks.

On Fri, Oct 25, 2019 at 2:43 AM Eric Griffis  wrote:
>
> Maybe pipe ports?
>
> https://docs.racket-lang.org/reference/pipeports.html
>
> Eric
>
>
> On Thu, Oct 24, 2019, 11:28 PM David Storrs  wrote:
>>
>> I saw something in the Reference about bi-directional {pipes |
>> channels | ???} with a constructor that returned two values, A and B,
>> where data put onto A could be read out of B and vice versa.  I can't
>> remember what it was called and my reference-search-fu is weak.  It's
>> not the one from Distributed Places
>> (https://docs.racket-lang.org/distributed-places/index.html?q=bi-directional#%28part._.Async_.Bidirectional_.Channels%29).
>>
>> Could someone remind me what these things are called?
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/CAE8gKod4smzgAwye14zZauVL4nhHB%3DnNPMWRGKkgKEOM3wCxAg%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/CAE8gKodfFLdZEb6t%2BWFdAfpTwGq0CNcmmLVBHbpOTK4f%2BKGC0w%40mail.gmail.com.


[racket-users] Remind me?: bidirectional channel-ish thing in two parts

2019-10-25 Thread David Storrs
I saw something in the Reference about bi-directional {pipes |
channels | ???} with a constructor that returned two values, A and B,
where data put onto A could be read out of B and vice versa.  I can't
remember what it was called and my reference-search-fu is weak.  It's
not the one from Distributed Places
(https://docs.racket-lang.org/distributed-places/index.html?q=bi-directional#%28part._.Async_.Bidirectional_.Channels%29).

Could someone remind me what these things are called?

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


[racket-users] Setting TTL on non-multicast UDP

2019-10-16 Thread David Storrs
I'm implementing the port prediction NAT-traversal algorithm[1], part
of which specifies sending non-multicast UDP packets with very short
TTLs.  The only method I see in the Racket docs for setting TTL on UDP
is the udp-multicast-set-ttl! function.  Is there a way to do this for
regular UDP packets?



[1] 
https://www.researchgate.net/publication/228411948_A_New_Method_for_Symmetric_NAT_Traversal_in_UDP_and_TCP

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


Re: [racket-users] Syntax pattern to match a sequence with x identical elements?

2019-10-11 Thread David Storrs
Alexis, is there any way that we can get this explanation and some of
the ones you've given me added to the Guide?  I've tried to add things
to the documentation before, or even just submit typo reports but, as
I've mentioned before, the way the docs are organized (random little
snippets scattered in unintuitive locations in a huge code base
scattered across multiple repositories) presents too high a barrier to
entry to be worth it for simple changes.  Presumably someone who knows
the system better could copy/paste this into an appropriate file and
submit a pull request.

Your explanations of things are extremely helpful, and really REALLY
need to be part of the docs somewhere.  I would add them myself if the
method of doing so were straightforward and/or clearly documented.
Sadly, it is not.

Dave

PS:  IMO, a vastly better system for the docs would be to have a set
of complete pages that actually correspond to the pages / URLs that
appear in the presentation.  I'm not sure why it isn't done that way,
although I'm sure there's a reason.  I do think that it's a major
problem that is denying a lot of the value of open-source
documentation.

On Thu, Oct 10, 2019 at 11:17 PM Alexis King  wrote:
>
> tl;dr: You need to use an ellipsis, so your pattern should be ((~between 
> x:integer 3 3) ...). A (much) more detailed explanation of why follows.
>
> ~between is an ellipsis-head pattern. The most common ellipsis-head pattern, 
> ~optional, also works as a plain head pattern, but ~between does not. What’s 
> the difference?
>
> Let’s start by answering what a head pattern is. The simplest kind of 
> syntax/parse pattern is a single-term pattern, which (as the name implies) 
> only matches a single syntax object at a time. Head patterns are special in 
> that they can match zero or more consecutive syntax objects in the head of a 
> list. What is the head of a list? Well, if you have a list like '(1 2 3 4), 
> its head is the sequence of elements “1 2 3 4” and its tail is simply the 
> empty list, '(). It’s possible to write the list '(1 2 3 4 . ()) to make that 
> more explicit.
>
> So when you have a head pattern like (~optional x:integer), it might parse an 
> integer, but it also might parse nothing. In the latter case, the next head 
> pattern in the sequence would get a chance to parse the same element that 
> (~optional x:integer) did. Head patterns are able to do this because lists 
> introduce a kind of linear sequencing (not just tree-like nesting), so 
> “skipping” an element is an operation that makes sense.
>
> But what about ellipsis-head patterns? These are patterns that don’t just 
> appear inside a list pattern, they appear inside a list pattern and under an 
> ellipsis. For example, in the pattern (x y ... z), x and z are head patterns, 
> but y is an ellipsis-head pattern. While head patterns introduce the ability 
> to consume one or more elements at a time, ellipsis-head patterns extend that 
> with the power to match elements in the list out of order. This is most 
> useful when parsing keyword options, such as in the following pattern:
>
> ((~alt (~once (~seq #:foo foo:integer)) (~once (~seq #:bar bar:string))) 
> ...)
>
> The above pattern will match (#:foo 1 #:bar "two") or (#:bar "two" #:foo 1), 
> but not (#:foo 1) or (#:foo 1 #:foo 2 #:bar "three"). This is because ~alt 
> introduces a set of alternatives that can be matched, but unlike a simple 
> ~or* pattern, it also keeps track of how many times each case matched, and 
> patterns like ~once, ~optional, and ~between introduce constraints on the 
> number of times a given case must match for the overall parse to be 
> successful.
>
> Interestingly, note that pattern variables bound under ~once and ~optional 
> don’t have an ellipsis depth of 1, they have an ellipsis depth of 0. This is 
> why, in the given example, you can refer to the foo and bar pattern variables 
> in a template without any ellipses. ~between, however, still increments the 
> ellipsis depth, since the pattern can actually match multiple times.
>
> In the pattern I suggested at the beginning of this email, ((~between 
> x:integer 3 3) ...), you’re creating an ellipsis-head context with exactly 
> one alternative: (~between x:integer 3 3). That is exactly what you want, so 
> everything works out fine.
>
> The one remaining question, however, is why ~between is only allowed as an 
> ellipsis-head pattern, but ~optional is also allowed as a head pattern. I 
> can’t say for certain, since you can think of ((~optional x:integer)) as 
> being sort of implicitly expanded to ((~optional x:integer) ...), and the 
> same could be done for ~between. However, my guess is that it isn’t allowed 
> because ~between increments the ellipsis depth of its sub-pattern, and Ryan 
> thought it would be confusing for a pattern variable’s ellipsis depth to be 
> incremented despite there not actually being any ellipses in the pattern. 
> Therefore, when using ~between, you have to 

Re: [racket-users] Re: Structured Concurrency in Racket

2019-10-09 Thread David Storrs
Note that it's possible to send S-expressions through a channel and then
eval them on the far end. This would let you do something like this:

(hash 'func 'my-predefined-lambda 'args '(arg1 arg2))

Which calls a predefined function, or:

(hash 'install '(lambda (username) (displayln (~a "Hello, " username)))
'name 'greet)

Which defines a new function and installs it for later use under the name
"greet".

It's not elegant and it has all the usual problems with eval'ing code, but
it's possible.

On Wed, Oct 9, 2019, 2:34 AM Zelphir Kaltstahl 
wrote:

> I don't think places are a good example for good support of parallelism.
>
> It is difficult to get a flexible multi processing implementation done,
> without hard-coding the lambdas, that run in each place, because we
> cannot send serializable lambdas (which also are not core, but only
> exist in the web server package) over channels. That means, that one
> needs to define ones lambdas ahead of time before even starting a place
> and sending it the data to process. That means, that we cannot have
> something like a process pool.
>
> The other problem is, that using places means using multiple Racket VMs,
> if I remember correctly, which uses some RAM. It is not like places are
> super lightweight at least.
>
> Racket threads run on a single core, I think.
>
> I know there is a tutorial about using futures somewhere, where it
> depends on the number type one uses, whether the code can be
> automatically run in parallel or not, so there is also some issue there,
> or at least it did not look to me like one could use futures everywhere
> and have neat parallelism.
>
>
> When I tried to write a process pool kind of thing (had a lot of help
> from this mailing list!), which I called work distributor, the above
> mentioned problems with lambdas caused me to abandon that project, until
> I can send lambdas over channels.
>
> Correct any of the things I wrote above, if they are not true, but I
> think Racket definitely needs a better multi processing story. I would
> love to see something like Guile Fibers. Andy Wingo even mentioned in
> his video, that some of the Racket greats advised him to look at
> Concurrent ML and that that is where he got some ideas from, when
> implementing Guile Fibers as a library. Shouldn't Racket then be able to
> have a similar library? I don't understand how Fibers really works, but
> that is a thought I had many times, since I heard about the Fibers library.
>
> Regards,
>
> Zelphir
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/59c68f8e-b668-f08e-55ae-a977084f5bb1%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/CAE8gKoeQAyfp6t0Zg1oa1%2B%3D7PXNJhU0VHWG7-13D3_zqLonfzQ%40mail.gmail.com.


Re: [racket-users] Current state of racket2 planning?

2019-10-04 Thread David Storrs
Great, thanks! And yes, I missed it for that reason.

On Fri, Oct 4, 2019, 8:44 AM Sam Tobin-Hochstadt 
wrote:

> Matthew wrote a long email on Wednesday with about the current state,
> although the subject was "Rhombus Project Plan" so that may have been why
> you missed it.
>
> Sam
>
> On Fri, Oct 4, 2019, 8:42 AM David Storrs  wrote:
>
>> The racket2 discussion dropped off my radar a while ago but I got some
>> spoons back and thought I'd check in again. Where should I look to see the
>> ongoing discussion / current state?
>>
>> Sidebar: I read the Honu paper... Is the current plan still "programmer
>> writes C-ish code and then, behind the scenes,  Honu-ish enforestation
>> expander turns it back into Lisp-ish code so that the engine can run 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/CAE8gKocEuSA%2B-zbcEtpw09ud6e6MPsN%2B4EP5gx_r-PDN9%2BDPfA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAE8gKocEuSA%2B-zbcEtpw09ud6e6MPsN%2B4EP5gx_r-PDN9%2BDPfA%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/CAE8gKodhk1bzG_yBh-%2BbTsP5Xn95t19FJS_FrX59uYQeNToCRQ%40mail.gmail.com.


[racket-users] Current state of racket2 planning?

2019-10-04 Thread David Storrs
The racket2 discussion dropped off my radar a while ago but I got some
spoons back and thought I'd check in again. Where should I look to see the
ongoing discussion / current state?

Sidebar: I read the Honu paper... Is the current plan still "programmer
writes C-ish code and then, behind the scenes,  Honu-ish enforestation
expander turns it back into Lisp-ish code so that the engine can run 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/CAE8gKocEuSA%2B-zbcEtpw09ud6e6MPsN%2B4EP5gx_r-PDN9%2BDPfA%40mail.gmail.com.


Re: [racket-users] Ensuring that channels are GC'd when the child thread terminates

2019-10-02 Thread David Storrs
Ok, thanks.

On Wed, Oct 2, 2019, 4:16 PM Matthew Flatt  wrote:

> At Wed, 2 Oct 2019 11:06:14 -0400, David Storrs wrote:
> > On Wed, Oct 2, 2019 at 8:42 AM Matthew Flatt  wrote:
> > > It depends on `process-file`. If `process-file` retains `msg` until it
> > > is otherwise done, then yes. But if `process-file` ignores the argument
> > > for `msg` or only uses it for the first part of its work, then `msg`
> > > can get GCed before `process-file` returns.
> >
> > If process-file looked like this:
> >
> > (define (process-file msg ch)
> >   (define the-hash-str (file-info-hash msg))
> >   ...do stuff with the-hash-str...
> > )
> >
> > I think this would mean that msg could get GC'd as early as right
> > after the first line, but it's not guaranteed as to when it would be
> > GC'd.  Yes?
>
> Yes, essentially. But depending on `file-info-hash`, `msg` might be
> GC'd before `file-info-hash` returns, which is even before the second
> line within `process-file`.
>
>

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


Re: [racket-users] Ensuring that channels are GC'd when the child thread terminates

2019-10-02 Thread David Storrs
On Wed, Oct 2, 2019 at 8:42 AM Matthew Flatt  wrote:
>
> At Tue, 1 Oct 2019 23:52:05 -0400, David Storrs wrote:
> > ; main dispatcher loop in the server.  Receives messages, dispatches
> > to child thread for processing
>
> > 2) This WOULD work:
> > (let loop ()
> > (define msg (get-next-message)) ; e.g. (file-info "sha1-hash-of-file-X")
> > (hash-set! channels msg ch)
> > (thread (thunk (process-file msg ch)
> > (loop))
> >
> > In this case, 'msg' is still reachable from the processing thread, so
> > it remains in the weak hash until the processing thread terminates, at
> > which point it is removed from the weak hash and the corresponding
> > channel is GC'd.
>
> It depends on `process-file`. If `process-file` retains `msg` until it
> is otherwise done, then yes. But if `process-file` ignores the argument
> for `msg` or only uses it for the first part of its work, then `msg`
> can get GCed before `process-file` returns.

If process-file looked like this:

(define (process-file msg ch)
  (define the-hash-str (file-info-hash msg))
  ...do stuff with the-hash-str...
)

I think this would mean that msg could get GC'd as early as right
after the first line, but it's not guaranteed as to when it would be
GC'd.  Yes?

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


[racket-users] Ensuring that channels are GC'd when the child thread terminates

2019-10-01 Thread David Storrs
I have a server with a main dispatcher loop that receives messages and
farms them out to processing threads.  I'd like to have able to have
later messages inform the behavior of earlier message processing -- an
example would be "message 1: here is a file to download" followed by
"stop downloading if you're still doing it".

I'll do the simple version, where it keeps the channels around until
the thread terminates but doesn't actually use the channels:

; main dispatcher loop in the server.  Receives messages, dispatches
to child thread for processing
 (struct file-info (hash) #:transparent)
 (define channels (make-weak-hash))
 (let loop ()
(define msg (get-next-message)) ; e.g. (file-info "sha1-hash-of-file-X")
(hash-set! channels (file-info-hash msg) ch)
(thread (thunk (process-file msg ch)
(loop))

1) Am I correct that this does not work? The string that came out of
file-info-hash is not eq? to the one stored inside msg, meaning that
it's not referenced from anywhere else, so it's going to disappear the
moment it goes into the weak hash.


2) The following also would not work:
(let loop ()
(define msg (get-next-message))
(define the-str (file-info-hash msg))  ;; save the value out before using it
(hash-set! channels the-str ch)
(thread (thunk (process-file msg ch)
(loop))

The (loop) is in tail position, so this is not a recursive call.  That
means the stack frame is cleared, so 'the-str' is not reachable and
it's cleared from the weak hash.


2) This WOULD work:
(let loop ()
(define msg (get-next-message)) ; e.g. (file-info "sha1-hash-of-file-X")
(hash-set! channels msg ch)
(thread (thunk (process-file msg ch)
(loop))

In this case, 'msg' is still reachable from the processing thread, so
it remains in the weak hash until the processing thread terminates, at
which point it is removed from the weak hash and the corresponding
channel is GC'd.

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


Re: [racket-users] gen:equal+hash on hashes or other non-struct data structure

2019-10-01 Thread David Storrs
Perfect.  Thank you, Philip.

The example definition is:  (define-custom-hash-types string-hash
#:key? string? string=? string-length)

'string-length' in the above is the "optional hash function".  What
does that mean?  It's not demonstrated in the example code.


On Tue, Oct 1, 2019 at 10:38 PM Philip McGrath  wrote:
>
> On Tue, Oct 1, 2019 at 10:21 PM David Storrs  wrote:
>>
>> For example, there's a hash, hasheqv, and hasheq.  Is there a way to
>> have a hash with a user-provided key-comparison function?
>
>
> You probably want `define-custom-hash-types` and the related functions: 
> https://docs.racket-lang.org/reference/dicts.html#(form._((lib._racket%2Fdict..rkt)._define-custom-hash-types))
>  More generally, you can of course use `gen:dict` to do exactly what you 
> want. There are corresponding options for sets, also.
>
>>
>> Is it possible to put gen:equal+hash on something other than a struct?
>
>
> In general, this would mean redefining how `equal?` works on built-in 
> datatypes, which would cause trouble for libraries that use those types. You 
> can choose what `equal?` means for datatypes you define, and you can choose 
> to use some other notion of equality on datatypes you're comparing, but you 
> can't mess with what `equal?` means when other people's code calls it on 
> other people's datatypes.
>
> One alternative that can sometimes make sense is creating a wrapper struct 
> that basically is just there to hang methods like `gen:equal+hash` on.
>
> -Philip
>

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


[racket-users] gen:equal+hash on hashes or other non-struct data structure

2019-10-01 Thread David Storrs
Is it possible to put gen:equal+hash on something other than a struct?
 For example, there's a hash, hasheqv, and hasheq.  Is there a way to
have a hash with a user-provided key-comparison function?

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


Re: [racket-users] Re: Confusion with udp-receive!

2019-09-26 Thread David Storrs
On Wed, Sep 25, 2019 at 8:16 PM David Storrs  wrote:
>
> On Wed, Sep 25, 2019 at 7:45 PM Alex Harsanyi  wrote:
> >
> > Is there any tunneling involved for connecting to your AWS instance?
> >
> > There is only one copy of the source port in an IP+UDP datagram, and this 
> > needs to be whatever the router is using for NAT, otherwise it would not be 
> > able to route replies back to your machine on the local network.  If you 
> > have some kind of tunneling set up to access the AWS servers, the router 
> > will wrap the original UDP packet into another UDP packet with its own 
> > source port, leaving the original source port unchanged.
>
> I'll have to check.

Okay, we checked and there is definitely no tunneling going on.

Does anyone have any further thoughts on this?
>
> >
> > You could also run tcpdump on your AWS server and dump the entire contents 
> > of the packet to see what the server actually receives.
>
> Did that, and it's getting the 25890 port (the one for my local
> machine instead of the router).
>
> >
> > Alex.
> >
> > On Thursday, September 26, 2019 at 12:49:51 AM UTC+8, David Storrs wrote:
> >>
> >> We (my business partner and I) ran tcpdump on the router and
> >> determined that no, it is not using the local port.  At first it bound
> >> to 65395 and then after we stopped/started the process it bound to a
> >> different port (49428) as expected.
> >>
> >> After a bit of digging in the racket source code I note that the
> >> various UDP functions are an FFI into librktio.  This leaves me with
> >> two questions:
> >>
> >> 1) Is it possible that there is a bug in the underlying C code?
> >>
> >> 2) Why does Racket use a hand-rolled io library instead of a more
> >> standard net stack element?  Is it for portability or...?
> >>
> >> On Wed, Sep 25, 2019 at 9:28 AM David Storrs  wrote:
> >> >
> >> >
> >> >
> >> > On Wed, Sep 25, 2019, 3:16 AM Alex Harsanyi  wrote:
> >> >>
> >> >> Do you know what port the router is using for NAT?  Are you sure that 
> >> >> the router is not simply choosing the same port, so 25890 is both your 
> >> >> local port and the port used by the router?
> >> >
> >> >
> >> > I haven't yet 100% ruled it out, but it doesn't look like it. I tried 
> >> > sending traffic to :25890 and it was not received.  It's 
> >> > possible that the port went stale and was released before my sending 
> >> > went out, but that seems unlikely, as it should persist for seconds or 
> >> > tens of seconds.My next step is to try again with a flood ping, just to 
> >> > be sure.
> >> >
> >> > Regards, it really shouldn't be doing that. If so, it's leaking 
> >> > information about the inner network to the outside, and that's not what 
> >> > I'd expect from the latest version of the FOSS OpenWRT.
> >> >
> >> >
> >> >>
> >> >> Alex.
> >> >>
> >> >> On Wednesday, September 25, 2019 at 1:08:16 PM UTC+8, David Storrs 
> >> >> wrote:
> >> >>>
> >> >>> udp-receive! is giving me unexpected results when my local machine ->
> >> >>> router -> server shows the UDP port of the process running on the
> >> >>> local machine instead of the one from the router.  I'm not sure how to
> >> >>> get the router's port instead.
> >> >>>
> >> >>>
> >> >>> The AWS server does this:
> >> >>>   (define-values (len senders-host senders-port) (udp-receive! socket 
> >> >>> buffer))
> >> >>>
> >> >>> What I'm actually getting is:
> >> >>>
> >> >>> senders-host:  
> >> >>> senders-port: 25890 ; this is the UDP port bound by the process on the
> >> >>> local machine
> >> >>>
> >> >>> What I'm expecting is:
> >> >>>
> >> >>> senders-host:  
> >> >>> senders-port:   >> >>> message from my machine to the AWS server>
> >> >>>
> >> >>> I've been digging through the  RFCs for UDP and Traditional NAT
> >> >>> (https://www.ietf.org/rfc/rfc768.txt and
> >> >>> https://www.ietf.org/rfc/rfc3022.txt) to make sure that I haven't
> >> >>> r

Re: [racket-users] Confusion with udp-receive!

2019-09-25 Thread David Storrs
Hi Greg,

On Wed, Sep 25, 2019 at 3:33 PM George Neuner  wrote:
>
> Hi David,
>
> On 9/25/2019 1:08 AM, David Storrs wrote:


> What you are overlooking is that UDP is a level 4 [end-to-end] protocol,
> but you are trying to get level 3 [routing] information.
>
> Neither UDP nor TCP normally records the path a packet takes - only the
> routers themselves know what they do to forward the packet.  The path
> between 2 machines is never fixed, and it may change abruptly due to
> congestion or outage along the way."traceroute" uses a special
> (level 3) IP packet which explicitly commands each router along the way
> ... and the end destination as well if the packet gets there ... to send
> back a response to the traceroute initiator.  The path is discovered
> dynamically from the responses.

I don't think this is correct.  NAPT is defined here:
https://www.ietf.org/rfc/rfc3022.txt  The relevant section is 4.1 (NB:
"TU port" means "TCP or UDP port")

 start quote
4.1. IP, TCP, UDP and ICMP Header Manipulations

   In Basic NAT model, the IP header of every packet must be modified.
   This modification includes IP address (source IP address for outbound
   packets and destination IP address for inbound packets) and the IP
   checksum.

   For TCP ([TCP]) and UDP ([UDP]) sessions, modifications must include
   update of checksum in the TCP/UDP headers.  This is because TCP/UDP
   checksum also covers a pseudo header which contains the source and
   destination IP addresses.  As an exception, UDP headers with 0
   checksum should not be modified.  As for ICMP Query packets ([ICMP]),
   no further changes in ICMP header are required as the checksum in
   ICMP header does not cover IP addresses.

   In NAPT model, modifications to IP header are similar to that of
   Basic NAT.  For TCP/UDP sessions, modifications must be extended to
   include translation of TU port (source TU port for outbound packets
   and destination TU port for inbound packets) in the TCP/UDP header.
   ICMP header in ICMP Query packets must  also be modified to replace
   the query ID and ICMP header checksum.  Private host query ID must be
   translated into assigned ID on the outbound and the exact reverse on
   the inbound.  ICMP header checksum must be corrected to account for
   Query ID translation.

 end quote

The firewall that I'm behind, like most modern NAT instances, is a
NAPT instance -- a single external address that maps multiple internal
addresses based on a semi-randomly-chosen port assigned when the
initial connection is made.  As stated above, the differences between
the two are:

Basic NAT rewrites
  - IP header
 -- IP address for source (on outbound) or destination (on inbound)
 -- IP checksum
  UDP header:  UDP checksum

NAPT rewrites:
  - IP header
 -- IP address for source (on outbound) or destination (on inbound)
 -- IP checksum
  - UDP header:
  -- UDP checksum
  -- TU port for source (on outbound) or destination (on inbound)

In short, the connection should go like this:

local machine (192.168.1.221, port 25891)  sends message to
:54545 by way of router  (192.168.1.1).   At each step
the source/destination are:

local machine -> router
  (source: 192.168.1.221:25891
   dest: :54545)

router -> AWS-server
  (s: :X  <--- arbitrary port number for this session
   d: :54545)

AWS-server -> router
  (s: :54545
   d: :X)

router -> local machine
  (s: :54545
   d: 192.168.1.221:25891


Did I misunderstand something?  If not, then I think that the
udp-receive! on the AWS server should return IP address 
and port .  This matches when Matt Flatt is seeing, but not
what I'm seeing.  As yet, I have no explanation, but it's obviously
something to do with my specific setup.



>
>
> Hope this helps,
> 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/CAE8gKocBySEa-_58_U0Cs2tR%2BMMOG4pwBJqd1Tsd6WLugypQ-g%40mail.gmail.com.


Re: [racket-users] Re: Confusion with udp-receive!

2019-09-25 Thread David Storrs
On Wed, Sep 25, 2019 at 2:57 PM Matthew Flatt  wrote:
>
> At Wed, 25 Sep 2019 12:49:36 -0400, David Storrs wrote:
> > 1) Is it possible that there is a bug in the underlying C code?
>
> It's always possible. But if I understand the original problem, it
> seems unlikely that a bug manages to exactly reconstruct a port number
> that has been replaced in a UDP packet by a NAT.
>
>
> Just to make sure we're talking about the same thing, I'm enclosing
> complete code based on your fragments. If I run "server.rkt" first and
> then "client.rkt", I see
>
>  me: 0.0.0.0 25891
>  reply from:  54545
>  reply: #s(transport-address "" )
>
> If I run as-is, using "localhost" as the server shown by , then
>  and  are `127.0.0.1` and `25891`, as expected. I change
> "client.rkt" to connect to a remote host where my client is behind a
> NAT, then  is my NAT's address and  is something other than
> 25891 --- and that  persists over multiple runs of "client.rkt" and
> "server.rkt" in some complicated way that does indeed seem to be at
> least tens of seconds. (My NAT is an AirPort.)
>
> If I understand, you're seeing  as always 25891, and you have good
> reason to think that the NAT isn't just using 25891 as a convenient
> substitute for 25891. I have no explanation.

Interesting.  When I run server.rkt and client.rkt on my local machine
then I, like you, get 127.0.0.1 and 25891.  When I put the code onto
my AWS instance so that there is NAT between us, I *still* get 25891
on both the server and the client.  If it's working for you then there
must be something wrong with my network.

Would it be possible for you to give me the IP of the remote machine
you used and leave server.rkt running there for an hour or so?  That
way I could try it against a different remote machine without needing
to spin up and provision a different VM.

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


Re: [racket-users] Re: Confusion with udp-receive!

2019-09-25 Thread David Storrs
We (my business partner and I) ran tcpdump on the router and
determined that no, it is not using the local port.  At first it bound
to 65395 and then after we stopped/started the process it bound to a
different port (49428) as expected.

After a bit of digging in the racket source code I note that the
various UDP functions are an FFI into librktio.  This leaves me with
two questions:

1) Is it possible that there is a bug in the underlying C code?

2) Why does Racket use a hand-rolled io library instead of a more
standard net stack element?  Is it for portability or...?

On Wed, Sep 25, 2019 at 9:28 AM David Storrs  wrote:
>
>
>
> On Wed, Sep 25, 2019, 3:16 AM Alex Harsanyi  wrote:
>>
>> Do you know what port the router is using for NAT?  Are you sure that the 
>> router is not simply choosing the same port, so 25890 is both your local 
>> port and the port used by the router?
>
>
> I haven't yet 100% ruled it out, but it doesn't look like it. I tried sending 
> traffic to :25890 and it was not received.  It's possible that the 
> port went stale and was released before my sending went out, but that seems 
> unlikely, as it should persist for seconds or tens of seconds.My next step is 
> to try again with a flood ping, just to be sure.
>
> Regards, it really shouldn't be doing that. If so, it's leaking information 
> about the inner network to the outside, and that's not what I'd expect from 
> the latest version of the FOSS OpenWRT.
>
>
>>
>> Alex.
>>
>> On Wednesday, September 25, 2019 at 1:08:16 PM UTC+8, David Storrs wrote:
>>>
>>> udp-receive! is giving me unexpected results when my local machine ->
>>> router -> server shows the UDP port of the process running on the
>>> local machine instead of the one from the router.  I'm not sure how to
>>> get the router's port instead.
>>>
>>>
>>> The AWS server does this:
>>>   (define-values (len senders-host senders-port) (udp-receive! socket 
>>> buffer))
>>>
>>> What I'm actually getting is:
>>>
>>> senders-host:  
>>> senders-port: 25890 ; this is the UDP port bound by the process on the
>>> local machine
>>>
>>> What I'm expecting is:
>>>
>>> senders-host:  
>>> senders-port:  >> message from my machine to the AWS server>
>>>
>>> I've been digging through the  RFCs for UDP and Traditional NAT
>>> (https://www.ietf.org/rfc/rfc768.txt and
>>> https://www.ietf.org/rfc/rfc3022.txt) to make sure that I haven't
>>> randomly gotten confused about how routers work but it seems to be
>>> what I recall: The local machine sends to the router using the port
>>> number 25890, the router rewrites it to an arbitrary port number
>>> chosen on the fly, the AWS server sees the router's assigned port and
>>> not 25890.
>>>
>>> What am I missing here?  I'm sure it's something embarrassingly obvious.
>>>
>>>
>>>
>>> Simplified form of code for reference:
>>>
>>> ---
>>> shared code
>>> ---
>>> (struct Message (message-id attributes) #:prefab)
>>> (struct Binding-Request  Message () #:prefab)
>>> (struct Binding-Success-Response Message () #:prefab)
>>> (struct transport-address (ip port) #:prefab)
>>>
>>> (define (write-to-bytes v)
>>>   (define out (open-output-bytes))
>>>   (write v out)
>>>   (get-output-bytes out))
>>>
>>> ---
>>> local machine:
>>> ---
>>> (define socket (udp-open-socket #f #f))
>>> (udp-bind! socket #f 25890 #t)
>>> (thread
>>>  (thunk
>>>   (define-values (len senders-host senders-port) (udp-receive! socket 
>>> buffer))
>>>   (log-msg-debug "host: ~a, port ~a, buffer ~a " senders-host
>>> senders-port buffer)))
>>>
>>> (udp-send-to socket default-host default-port
>>>  (wrap (Binding-Request 17 (hash
>>>
>>> -
>>> AWS server:
>>> -
>>> The server has its own UDP socket (bound to 54545, fwiw) and a receive
>>> loop that identifies the Binding-Request and routes it to the
>>> following code:
>>>
>>> (define-values (len senders-host senders-port) (udp-receive!
>>> socket buffer)
>>> (define mapped-address (transport-address senders-host senders-port))
>>> (define msg-out
>>>   (Binding-Success-Response mid
>

Re: [racket-users] Re: Confusion with udp-receive!

2019-09-25 Thread David Storrs
On Wed, Sep 25, 2019, 3:16 AM Alex Harsanyi  wrote:

> Do you know what port the router is using for NAT?  Are you sure that the
> router is not simply choosing the same port, so 25890 is both your local
> port and the port used by the router?
>

I haven't yet 100% ruled it out, but it doesn't look like it. I tried
sending traffic to :25890 and it was not received.  It's
possible that the port went stale and was released before my sending went
out, but that seems unlikely, as it should persist for seconds or tens of
seconds.My next step is to try again with a flood ping, just to be sure.

Regards, it really shouldn't be doing that. If so, it's leaking information
about the inner network to the outside, and that's not what I'd expect from
the latest version of the FOSS OpenWRT.



> Alex.
>
> On Wednesday, September 25, 2019 at 1:08:16 PM UTC+8, David Storrs wrote:
>>
>> udp-receive! is giving me unexpected results when my local machine ->
>> router -> server shows the UDP port of the process running on the
>> local machine instead of the one from the router.  I'm not sure how to
>> get the router's port instead.
>>
>>
>> The AWS server does this:
>>   (define-values (len senders-host senders-port) (udp-receive! socket
>> buffer))
>>
>> What I'm actually getting is:
>>
>> senders-host:  
>> senders-port: 25890 ; this is the UDP port bound by the process on the
>> local machine
>>
>> What I'm expecting is:
>>
>> senders-host:  
>> senders-port:  > message from my machine to the AWS server>
>>
>> I've been digging through the  RFCs for UDP and Traditional NAT
>> (https://www.ietf.org/rfc/rfc768.txt and
>> https://www.ietf.org/rfc/rfc3022.txt) to make sure that I haven't
>> randomly gotten confused about how routers work but it seems to be
>> what I recall: The local machine sends to the router using the port
>> number 25890, the router rewrites it to an arbitrary port number
>> chosen on the fly, the AWS server sees the router's assigned port and
>> not 25890.
>>
>> What am I missing here?  I'm sure it's something embarrassingly obvious.
>>
>>
>>
>> Simplified form of code for reference:
>>
>> ---
>> shared code
>> ---
>> (struct Message (message-id attributes) #:prefab)
>> (struct Binding-Request  Message () #:prefab)
>> (struct Binding-Success-Response Message () #:prefab)
>> (struct transport-address (ip port) #:prefab)
>>
>> (define (write-to-bytes v)
>>   (define out (open-output-bytes))
>>   (write v out)
>>   (get-output-bytes out))
>>
>> ---
>> local machine:
>> ---
>> (define socket (udp-open-socket #f #f))
>> (udp-bind! socket #f 25890 #t)
>> (thread
>>  (thunk
>>   (define-values (len senders-host senders-port) (udp-receive! socket
>> buffer))
>>   (log-msg-debug "host: ~a, port ~a, buffer ~a " senders-host
>> senders-port buffer)))
>>
>> (udp-send-to socket default-host default-port
>>  (wrap (Binding-Request 17 (hash
>>
>> -
>> AWS server:
>> -
>> The server has its own UDP socket (bound to 54545, fwiw) and a receive
>> loop that identifies the Binding-Request and routes it to the
>> following code:
>>
>> (define-values (len senders-host senders-port) (udp-receive!
>> socket buffer)
>> (define mapped-address (transport-address senders-host senders-port))
>> (define msg-out
>>   (Binding-Success-Response mid
>> (hasheq 'mapped-address
>> mapped-address)))
>>  (udp-send-to socket senders-host senders-port (wrap msg-out))
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/0fc8af6a-c50c-4a90-ba8e-64718161379e%40googlegroups.com
> <https://groups.google.com/d/msgid/racket-users/0fc8af6a-c50c-4a90-ba8e-64718161379e%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/CAE8gKodfa3NGofn%3D9Q4BvvCEv7wEJXu9mKWyeLJTGZKGNHo2Vg%40mail.gmail.com.


[racket-users] Confusion with udp-receive!

2019-09-24 Thread David Storrs
udp-receive! is giving me unexpected results when my local machine ->
router -> server shows the UDP port of the process running on the
local machine instead of the one from the router.  I'm not sure how to
get the router's port instead.


The AWS server does this:
  (define-values (len senders-host senders-port) (udp-receive! socket buffer))

What I'm actually getting is:

senders-host:  
senders-port: 25890 ; this is the UDP port bound by the process on the
local machine

What I'm expecting is:

senders-host:  
senders-port:  

I've been digging through the  RFCs for UDP and Traditional NAT
(https://www.ietf.org/rfc/rfc768.txt and
https://www.ietf.org/rfc/rfc3022.txt) to make sure that I haven't
randomly gotten confused about how routers work but it seems to be
what I recall: The local machine sends to the router using the port
number 25890, the router rewrites it to an arbitrary port number
chosen on the fly, the AWS server sees the router's assigned port and
not 25890.

What am I missing here?  I'm sure it's something embarrassingly obvious.



Simplified form of code for reference:

---
shared code
---
(struct Message (message-id attributes) #:prefab)
(struct Binding-Request  Message () #:prefab)
(struct Binding-Success-Response Message () #:prefab)
(struct transport-address (ip port) #:prefab)

(define (write-to-bytes v)
  (define out (open-output-bytes))
  (write v out)
  (get-output-bytes out))

---
local machine:
---
(define socket (udp-open-socket #f #f))
(udp-bind! socket #f 25890 #t)
(thread
 (thunk
  (define-values (len senders-host senders-port) (udp-receive! socket buffer))
  (log-msg-debug "host: ~a, port ~a, buffer ~a " senders-host
senders-port buffer)))

(udp-send-to socket default-host default-port
 (wrap (Binding-Request 17 (hash

-
AWS server:
-
The server has its own UDP socket (bound to 54545, fwiw) and a receive
loop that identifies the Binding-Request and routes it to the
following code:

(define-values (len senders-host senders-port) (udp-receive!
socket buffer)
(define mapped-address (transport-address senders-host senders-port))
(define msg-out
  (Binding-Success-Response mid
(hasheq 'mapped-address
mapped-address)))
 (udp-send-to socket senders-host senders-port (wrap msg-out))

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


Re: [racket-users] Would it help to call racket2 something else?

2019-08-28 Thread David Storrs
On Wed, Aug 28, 2019, 11:43 PM Sage Gerard  wrote:

>
> Maybe I'm overthinking this. I already know that nothing in #lang racket
> is getting thrown out or anything.



Yes, it is. #lang racket uses parenthesized S-expressions and prefix
notation such that operator precedence is not relevant and each expression
is a clearly self-contained entity that's easy to manipulate, since it's
essentially identical to its own parse tree.  #lang racket2 will be
non-parenthesized infix notation, probably with whitespace-significance.
Operator precedence will matter, it will be easy to accidentally move only
part of an expression/form, and the parse tree will be entirely different
from the user-level code.

I just feel like I am getting mixed messages about why this is all
> happening.
>

I've heard two explanations thus far. The first is that parentheses and
prefix notation are hard for students to grok and (by implication) Racket
uptake will increase if it moves to a more Python/Java/C-like syntax. I
think I may at some point have suggested that I have reservations about
this idea, but I acknowledge that the core developers are more skilled at
CS than I am and that they have more experience teaching and therefore a
larger dataset about what people find difficult to learn.

The other explanation I've heard is that Racket is due for a serious
overhaul and there's a lot of very powerful stuff that could be done if
backwards compatibility could be sacrificed. I think this is almost
certainly true, although there are certainly challenges.

So far as I'm aware, there isn't a clear statement of whether the primary
intent is to gain new users or to increase power for existing users, eg by
making the latest CS research available to the masses and fixing warts in
the existing language, etc. There's definitely tension between those goals.


One other issue that hasn't been discussed that I've seen is whether #lang
racket2 is intended for beginners or experienced developers. Everyone
starts off as a beginner but they don't stay beginners for long. (Unless
they stop programming completely, in which case there's no point in
factoring them into language design issues.) To me this suggests that it
would be possible to aim racket2 at experienced developers and use the
simpler teaching languages as a way of easing people into the ideas --
which, as I understand it, is what they're intended for and used for right
now.

Making syntax more similar to other languages is useful for Racket
beginners and will provide easier skill transference. Whether it's better
for experienced developers is an open question. Again, the core devs have
larger datasets than I do, although I will note that those datasets are
almost entirely compared of novices.


> -slg
>
>
>
>
>  Original Message 
> On Aug 28, 2019, 11:23 PM, George Neuner < gneun...@comcast.net> wrote:
>
>
>
> On 8/28/2019 10:56 PM, Sage Gerard wrote:
> > #lang new-coke
> >
> > -slg
>
> "New Coke" was horrible ... tasted like the bastard child of Pepsi and
> Dr. Pepper.
>
> And no matter what they claim, "Classic Coke" never was (and still
> isn't) the same as the original.  Classic Coke hit shelves a mere 3
> months after the original was discontinued.  I had cases of original
> stockpiled and was able to do side by side comparison.  Classic tasted
> like original diluted with extra water.  Probably it was deliberately
> diluted to enhance profit and they hoped no one would notice.
>
> YMMV,
> 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/d2be1ddf-9c83-2641-7e89-c2f61a993bd7%40comcast.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/3vo8nFdnB0xIR4oT5kr2-lY0USBKikSjnUAW344zx-OAIG4iCv9iD3fYQdoD2H0n1EIKP9Ni3-ZhoNsk-aG39mbXwcMq007wm-OL19HEtpU%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/CAE8gKofk7S6KKWc4gs%3Dz0EY1scQgpG%3DEViia1GyK_udq_Gz75w%40mail.gmail.com.


Re: [racket-users] Would it help to call racket2 something else?

2019-08-28 Thread David Storrs
On Wed, Aug 28, 2019 at 5:08 PM Daniel Prager 
wrote:

> Changing the canonical syntax seems like a bigger jump than from PLT
> Scheme to Racket.
>
> Perhaps a name change would help.
>
> I looked up English language anagrams of racket and found two: retack and
> tacker.
>
> *retack** [Nautical] To tack or alter course by sailing into the wind for
> a second or further time.*
>
> I reckon *#lang retack* would at least make an apt working title. ;-)
>
> Dan
>

Hang on, 'tack' means to change direction across the wind, so shouldn't
'retack' mean to change direction and then change direction again such that
you're back to your original course?  I'm not sure how apropos that would
be in this case...  ;>

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


Re: [racket-users] Is there an expanded form of the Racket2 purpose declaration?

2019-08-28 Thread David Storrs
Thanks, Jay.  I've responded to the RFC.

On Wed, Aug 28, 2019 at 12:28 PM Jay McCarthy 
wrote:

> My thoughts are in the thread you linked to:
>
> https://github.com/racket/racket2-rfcs/issues/105#issuecomment-521446706
> """
> I see Racket2 through the rubric of "We almost never break backwards
> compatible and insist on gradual evolution as the only way to make
> progress; but, now we are willing to make some radical changes: What
> can we do to make Racket drastically better that can't be expressed as
> an evolution?" In other words, I feel like Racket2 is defined as the
> goal, "Whatever makes Racket a lot better" and the design constraint,
> "It's okay to be incompatible."
> """
>
> When it comes specifically to syntax, which is what you seem to be
> asking about by reading the quote, here's a quote from my attempts to
> write this up before:
>
>
> https://github.com/racket/racket2-rfcs/pull/109/files#diff-f609e36bab3cb71c8829f58a5f9b2455R16
> """
> The uniformity of S-expressions limits the amount of information at
> the notational level of reading Racket programs. A small amount of
> extra notation can go a long way with a small number of mores on its
> use. For example, in Racket brackets are used in S-expressions when no
> function or macro application is implied (like in the cases of a
> `cond`); reading Racket programs without this notational affordance is
> more difficult. On the other hand, it is awkward to embed arbitrary
> fragments of code not in S-expression format, such as when quoting a
> program in another language. The only effective option is to embed a
> string. The Racket @-reader is helpful at this, but it is not
> uniformly available and the standard structure of Racket's
> S-expression based languages do not allow macro-specific reading of
> such syntaxes.
> """
>
> I'll add that I see S-expressions as obviously limited and it would be
> nice to make a more powerful syntactic extension system that does not
> say, "You can have anything you want, provided it is a parenthesis."
>
> So for me, I don't see the syntax mission as having anything to do
> with students or getting people to like me, I see it as a way to go
> beyond the limitations of S-expressions and do something more powerful
> and interesting. I think people will like us more after in as much as
> I think people like awesome things, and I want to make something
> awesome.
>
> Jay
>
> --
> Jay McCarthy
> Associate Professor @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> Vincit qui se vincit.
>
> On Wed, Aug 28, 2019 at 1:09 AM David Storrs 
> wrote:
> >
> > The discussion on Racket2 seems to have moved offlist to the RFC list on
> github (https://github.com/racket/racket2-rfcs/issues); are there other
> locations?
> >
> > There is one question that I had back at the beginning of the process
> that I didn't manage to get clarity on, which is the rationale behind the
> whole thing.  I've gone back through some of the email discussion and gone
> through all 4 pages of the issues lists and read everything that seemed
> relevant.  The most apropos thing seems to be this:
> https://github.com/racket/racket2-rfcs/issues/105 but it still doesn't
> really speak to my question.
> >
> > My current understanding is that the rationale for the Racket2 effort
> looks something like this:
> >
> > "We, the core developers, many (all?) of whom are also academics with a
> lot of experience teaching Racket to new programmers, have noticed that
> parentheses and prefix notation are a stumbling block for many students.
> We would like to help the ideas of Racket spread into the larger
> community.  Therefore, we want to produce Racket2, which will have all the
> power of Racket but will get rid of parens and use infix notation, which
> will be more familiar and intuitive to students.  We also see this as a
> great time to improve existing elements of the language based on what we've
> learned since they were added, and potentially add new features."
> >
> > Is this in fact correct?  Is there more specific discussion of it
> somewhere that I've missed?  I don't want to make people retread the issue
> if it's already clearly laid out elsewhere.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKodAh%2BdO

[racket-users] Is there an expanded form of the Racket2 purpose declaration?

2019-08-27 Thread David Storrs
The discussion on Racket2 seems to have moved offlist to the RFC list on
github (https://github.com/racket/racket2-rfcs/issues); are there other
locations?

There is one question that I had back at the beginning of the process that
I didn't manage to get clarity on, which is the rationale behind the whole
thing.  I've gone back through some of the email discussion and gone
through all 4 pages of the issues lists and read everything that seemed
relevant.  The most apropos thing seems to be this:
https://github.com/racket/racket2-rfcs/issues/105 but it still doesn't
really speak to my question.

My current understanding is that the rationale for the Racket2 effort looks
something like this:

"We, the core developers, many (all?) of whom are also academics with a lot
of experience teaching Racket to new programmers, have noticed that
parentheses and prefix notation are a stumbling block for many students.
We would like to help the ideas of Racket spread into the larger
community.  Therefore, we want to produce Racket2, which will have all the
power of Racket but will get rid of parens and use infix notation, which
will be more familiar and intuitive to students.  We also see this as a
great time to improve existing elements of the language based on what we've
learned since they were added, and potentially add new features."

Is this in fact correct?  Is there more specific discussion of it somewhere
that I've missed?  I don't want to make people retread the issue if it's
already clearly laid out elsewhere.

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


Re: [racket-users] [racket ursers] Keyword question

2019-08-23 Thread David Storrs
There's also keyword-apply:
https://docs.racket-lang.org/reference/procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._keyword-apply%29%29

(define

 (f x #:y y #:z [z 10])
  (list

 x y z))

> (keyword-apply

 f '(#:y) '(2) '(1))

'(1 2 10)
> (keyword-apply

 f '(#:y #:z) '(2 3) '(1))

'(1 2 3)
> (keyword-apply

 f #:z 7 '(#:y) '(2) '(1))

'(1 2 7)

On Fri, Aug 23, 2019 at 1:35 AM Tim Meehan  wrote:

> If it was just passing keyword arguments to your function, you might be
> able to do it like this:
>
> ; https://docs.racket-lang.org/guide/lambda.html
> ; https://docs.racket-lang.org/reference/procedures.html
>
> (define greet
>   (lambda (given #:last surname)
> (string-append "Hello, " given " " surname)))
>
> ; 'apply' allows you to specify a keyword argument ...
> (define (test f . args)
>   (apply f args #:last "Doe"))
>
> (test greet "John") ; => "Hello, John Doe"
>
> On Thu, Aug 22, 2019 at 3:32 PM Kevin Forchione  wrote:
>
>>
>>
>> > On Aug 22, 2019, at 1:33 PM, Kevin Forchione  wrote:
>> >
>> > Hi guys,
>> > Suppose I have something like the following:
>> >
>> > (define (f  g . args)
>> >   (apply g args))
>> >
>> > How would I be able to pass keyword arguments to g?
>>
>> After racking my brains for the common lisp  and
>> googling for the scheme/Racket equivalent, stumbling through  mzlib/kw and
>> finally a bit of digging through racket procedure documentation I cobbled
>> together an approach that seems to do what I’m after. So I thought I’d
>> share. Here’s an example:
>>
>> #lang racket
>>
>>
>> (define (foo #:a (a 0) #:b (b 1) c (d 3) . rst) (list a b c d rst))
>>
>> (define show
>>   (make-keyword-procedure (λ (kws kw-args f . args) (keyword-apply f kws
>> kw-args args
>>
>> (show foo #:a 10 2 3 4 5 6 7)
>> => '(10 1 2 3 (4 5 6 7))
>>
>> Now apparently any keywords defined for show itself are captured in the
>> kWh and kw-args lists and would need to be filtered out of those lists
>> before tasing them on to f, but that shouldn’t be too difficult.
>>
>> 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/395CF1DB-3B85-4FFA-9C1B-5566EB2CC60F%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/CACgrOxJ%3DAadxH4_9a2u%2B0XZhVpyT2gA-qLtRrhWAy3w2JLRtmw%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/CAE8gKof8B2Gf%2B4NTEDixa7upZ9FnU1UyCcL16msHfSGudyPXhg%40mail.gmail.com.


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

2019-08-06 Thread David Storrs
I should mention that the reason I'm looking into this is because I have
UDP sockets that are not getting closed.  They are managed by custodians,
but the custodians are not releasing them; I take this to mean that the
custodians are not being run.

On Tue, Aug 6, 2019 at 1:06 PM David Storrs  wrote:

> A bunch of reading through docs suggests that custodians do not
> automatically run when Racket exits and that if I want them to then I
> should either use a plumber (which is not guaranteed to run if there's a
> segfault) or register the custodian with the ffi/unsafe/custodian module (
> http://web.mit.edu/racket_v612/amd64_ubuntu1404/racket/doc/foreign/Custodian_Shutdown_Registration.html)
> Is that right, or is there something I'm missing?
>

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


<    1   2   3   4   5   6   7   8   >