Re: [racket-users] Re: Parallel merge-sort leveraging futures

2019-10-07 Thread Sam Tobin-Hochstadt
I've submitted a pull request fixing those errors and supporting
running in serial mode.

One thing I notice is that it's substantially faster than
`vector-sort!` even when run in serial mode on traditional Racket (but
not on Racket CS), so perhaps this should be integrated (or there are
improvements that we can adopt).

Alex, just to clarify a couple things about futures: they block when
performing operations that are either sensitive to the current
continuation or need single-threaded access to the runtime. Vector
operations, as you see in Dominik's code, are not in this category.
Mutable hash table operations are blocking. Here's some numbers with
performance on sorting a vector with random fixnums using this package
on a 4 core machine with hyperthreading, "classic" is `vector-sort!`.
Note that the futures-sort library creates 2^k futures.

k: 0
cpu time: 3402 real time: 3399 gc time: 45
k: 1
cpu time: 3487 real time: 1834 gc time: 46
k: 2
cpu time: 3581 real time: 1097 gc time: 69
k: 4
cpu time: 5745 real time: 1014 gc time: 69
k: 8
cpu time: 5742 real time: 992 gc time: 45
k: 16
cpu time: 8111 real time: 2189 gc time: 279
'classic
cpu time: 4390 real time: 4388 gc time: 98

Here are similar numbers for Racket CS:

k: 0
cpu time: 2960 real time: 2960 gc time: 33
k: 1
cpu time: 3021 real time: 1594 gc time: 33
k: 2
cpu time: 3462 real time: 1154 gc time: 36
k: 4
cpu time: 4381 real time: 929 gc time: 36
k: 8
cpu time: 4406 real time: 889 gc time: 34
k: 16
cpu time: 7124 real time: 1655 gc time: 440
'classic
cpu time: 2749 real time: 2749 gc time: 51

On Mon, Oct 7, 2019 at 8:17 PM Alex Harsanyi  wrote:
>
> Hi Dominik,
>
> I tried to use your package and you are missing a dependency for the 
> `scribble-math` package in your info.rkt file, this has to be installed 
> separately otherwise your package won't install.
>
> However, I tried to use the `vector-futures-sort!` function and got an error:
>
> > (vector-futures-sort! #(3 1 7 6 4) <)
> . . vector-futures-sort!: broke its own contract
>   promised: vector?
>   produced: #
>   in: the res result of
>   (->i
>((unsorted vector?))
>((compare procedure?))
>(res vector?))
>   contract from: /futures-sort/main.rkt
>   blaming: /futures-sort/main.rkt
>(assuming the contract is correct)
>   at: /futures-sort/main.rkt:40.2
> >
>
> I would also be interested to know what performance gains did you get by using
> futures.  I experimented with futures a few years ago and noticed that they
> will block when accessing shared data structures.  My understanding is that
> all the futures will wait for each other while trying to access and set
> elements in the vector and this the execution will be mostly serial with no
> performance gains.  I am curious if anything has changed with regards to this
> in the last few years.
>
> Alex.
>
> On Monday, October 7, 2019 at 9:01:25 PM UTC+8, Dominik Pantůček wrote:
>>
>> Hello,
>>
>> over the course of past few months I have been tasked with solving a
>> (real-world) problem of sorting the sums of all possible combinations of
>> numbers. Some boring accounting stuff revolving around invoices. As the
>> total number of combinations is 2^N where N is the number of source
>> numbers, this task got "interesting" once there were more than 24
>> numbers - that is on my laptop with:
>>
>> model name: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
>>
>> 4 cores, 8 hyper-threads and 16GB RAM.
>>
>> Long story short, I had to implement a custom merge-sort for fxvectors
>> and managed to leverage futures for fully parallel execution. Now in
>> some spare time, I slightly polished the code and released it as
>> "futures-sort" package.
>>
>> The source code is available on GitHub[1] and it is already in Racket
>> package index[2].
>>
>> The package provides four sorting functions - two for vector? and two
>> for fxvector?. There are two variants of each, one with progress
>> reporting and one without. For the original task I needed to show
>> progress using racket/gui gauge% and it might be helpful for others
>> (it's just a callback that gets current and total number of merges
>> performed regularly).
>>
>> I would really appreciate any feedback regarding the naming conventions,
>> code style and generally anything else.
>>
>> Yes, the tests are not there (yet).
>>
>> The same algorithm without futures runs on par with Racket's default
>> sorting routines (tested for sets upto 2^30 - only 16G of memory here)
>> and for fixnums it is even (very slightly but consistently) faster than
>> vector-sort alone. With parallelism using futures it runs roughly N
>> times faster where N is the number reported by (processor-count).
>>
>> I have already some benchmark results available and once I get more data
>> I am more than happy to share it as well.
>>
>> The parallelism is configurable as parameter.
>>
>> And yes, all of this can be seen in the documentation which is included
>> but I still have to look into 

[racket-users] Re: Rhombus project plan

2019-10-07 Thread Chris Nelson
One part of me thinks of glorious success of Perl 6 and the rapid 
conversion to Python 3.x  from Python 2.x ...

... the other part says, "Racket is your research project, you do what you 
want to do."

Good Luck and have Fun!
Chris

>
>

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


[racket-users] Re: Parallel merge-sort leveraging futures

2019-10-07 Thread Alex Harsanyi
Hi Dominik,

I tried to use your package and you are missing a dependency for the 
`scribble-math` package in your info.rkt file, this has to be installed 
separately otherwise your package won't install.

However, I tried to use the `vector-futures-sort!` function and got an 
error:

> (vector-futures-sort! #(3 1 7 6 4) <)
. . vector-futures-sort!: broke its own contract
  promised: vector?
  produced: #
  in: the res result of
  (->i
   ((unsorted vector?))
   ((compare procedure?))
   (res vector?))
  contract from: /futures-sort/main.rkt
  blaming: /futures-sort/main.rkt
   (assuming the contract is correct)
  at: /futures-sort/main.rkt:40.2
> 

I would also be interested to know what performance gains did you get by 
using
futures.  I experimented with futures a few years ago and noticed that they
will block when accessing shared data structures.  My understanding is that
all the futures will wait for each other while trying to access and set
elements in the vector and this the execution will be mostly serial with no
performance gains.  I am curious if anything has changed with regards to 
this
in the last few years.

Alex.

On Monday, October 7, 2019 at 9:01:25 PM UTC+8, Dominik Pantůček wrote:
>
> Hello, 
>
> over the course of past few months I have been tasked with solving a 
> (real-world) problem of sorting the sums of all possible combinations of 
> numbers. Some boring accounting stuff revolving around invoices. As the 
> total number of combinations is 2^N where N is the number of source 
> numbers, this task got "interesting" once there were more than 24 
> numbers - that is on my laptop with: 
>
> model name: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz 
>
> 4 cores, 8 hyper-threads and 16GB RAM. 
>
> Long story short, I had to implement a custom merge-sort for fxvectors 
> and managed to leverage futures for fully parallel execution. Now in 
> some spare time, I slightly polished the code and released it as 
> "futures-sort" package. 
>
> The source code is available on GitHub[1] and it is already in Racket 
> package index[2]. 
>
> The package provides four sorting functions - two for vector? and two 
> for fxvector?. There are two variants of each, one with progress 
> reporting and one without. For the original task I needed to show 
> progress using racket/gui gauge% and it might be helpful for others 
> (it's just a callback that gets current and total number of merges 
> performed regularly). 
>
> I would really appreciate any feedback regarding the naming conventions, 
> code style and generally anything else. 
>
> Yes, the tests are not there (yet). 
>
> The same algorithm without futures runs on par with Racket's default 
> sorting routines (tested for sets upto 2^30 - only 16G of memory here) 
> and for fixnums it is even (very slightly but consistently) faster than 
> vector-sort alone. With parallelism using futures it runs roughly N 
> times faster where N is the number reported by (processor-count). 
>
> I have already some benchmark results available and once I get more data 
> I am more than happy to share it as well. 
>
> The parallelism is configurable as parameter. 
>
> And yes, all of this can be seen in the documentation which is included 
> but I still have to look into how to build it - I was sort of assuming 
> this works automatically based on what I see for example in 
> scribble-math[3][4]. Any help with getting this right is also more than 
> welcome. 
>
>
> Lastly - thanks go out to Jens Axel Søgaard for pointing out that 
> fixnums and fxvectors might help (and why) and also to other helpful 
> folks on #racket at Freenode. 
>
>
> Cheers, 
> Dominik 
>
>
> [1] https://github.com/dzoep/futures-sort 
> [2] https://pkgd.racket-lang.org/pkgn/package/futures-sort 
> [3] https://docs.racket-lang.org/scribble-math/index.html 
> [4] https://pkgd.racket-lang.org/pkgn/package/scribble-math 
>
>

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


[racket-users] Re: Racket News - Issue 17

2019-10-07 Thread Alex Harsanyi
Hi Paulo,

I would be interested to know what your plans are for your Darwin package 
(which is a fork of the Frog blog generator, for those who didn't read the 
newsletter :-) ).  

Over the years several people have updated their copy of Frog with new 
features, you can see this on the Network tab in GitHub.  Do you plan to 
integrate these changes into Darwin and/or add new features to it?

Alex.

On Monday, October 7, 2019 at 11:01:15 PM UTC+8, Paulo Matos wrote:
>
> Hi, 
>
> RN Issue 17 is finally here. 
> https://racket-news.com/2019/10/racket-news-issue-17.html 
>
> Enjoy, 
>
> Paulo 
>

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


Re: [racket-users] Some guidance in setting up Racket as a game scripting language.

2019-10-07 Thread George Neuner


On 10/7/2019 4:30 PM, George Neuner wrote:


Visual Studio's compile and link options are output in log files in 
the *.tlog*  sub-directory under the build (debug or 
release) directory.  See *CL.command.?.log* and *link.command.?.log*  
where '?' is some number.   [I don't know what that number represents 
- on my system I have only ever seen '1'.]


Sorry, should have been a little more explicit.

By default the logs and build information are in the *_source_* tree in 
sub-directories that are named corresponding to the desired build:  
debug, release, x64/debug, x64/release.  The .tlog directory 
and the logs for each build that has happened will be under those.


If the project is customized for different output locations, then 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/a352c46c-1688-d26b-1544-79721f2e59ef%40comcast.net.


Re: [racket-users] Some guidance in setting up Racket as a game scripting language.

2019-10-07 Thread George Neuner


On 10/7/2019 3:47 PM, Jens Axel Søgaard wrote:
Den man. 7. okt. 2019 kl. 20.15 skrev Hans Sjunnesson 
mailto:hans.sjunnes...@gmail.com>>:


I'm sorry Jens - I'm using Visual Studio on Windows to compile
this project.
I've initially built libracket, and SDL, which I'm linking against.
I can zip the entire solution and upload it somewhere for you to
have a look, but you'll need Visual Studio on Windows for that to
work.


I don't have a windows machine - but your test example only have two 
files. Is there a way to see

what options are applied (in a log perhaps)?

/Jens Axel


Visual Studio's compile and link options are output in log files in the 
*.tlog*  sub-directory under the build (debug or release) 
directory.  See *CL.command.?.log* and *link.command.?.log*  where '?' 
is some number.   [I don't know what that number represents - on my 
system I have only ever seen '1'.]


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/171a0c22-5bde-e9ec-d684-5fdd0c8621a7%40comcast.net.


Re: [racket-users] Structured Concurrency in Racket

2019-10-07 Thread George Neuner



On 10/7/2019 1:46 PM, jab wrote:

Coming across 
https://trio.discourse.group/t/structured-concurrency-and-delimited-continuations/
 just provoked me to search for discussion of structured concurrency in Racket. 
I didn’t immediately find much.* I hope that doesn’t mean that the interesting 
work that’s being discussed over in 
https://trio.discourse.group/c/structured-concurrency etc. has been largely 
unknown by the Racket community. Trio is having a profound impact on the future 
of concurrency, not just in Python but in many other languages. There’s even a 
post on Wikipedia now: https://en.wikipedia.org/wiki/Structured_concurrency

(For anyone new to the term, 
https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/
 might be the best starting point. One persuasive example shows Nathaniel live 
coding a correct implementation of RFC 655 “Happy Eyeballs” in 40 lines of 
Python: 
https://github.com/python-trio/trio-talks/tree/master/njsmith-async-concurrency-for-mere-mortals
  (For comparison, Twisted’s implementation took hundreds of lines and still 
had a logic bug after years of work.) There is also some related reading in 
https://github.com/python-trio/trio/wiki/Reading-list.)

I hope this post provokes discussion of structured concurrency in Racket. It’d 
be fascinating to read more of your thoughts!

Thanks,
Josh

* For example, Googling “structured concurrency racket” turned up mostly just a 
brief mention of Racket’s custodians in the bottom-most comment on this post: 
http://250bpm.com/blog:71


"Structured concurrency" as defined by those articles really applies 
only to programs that operate in distinct phases -  which is a pretty 
good description of many science programs  - but such programs represent 
a (important, but) small subset of all parallel programs.


Racket's APIs are designed to support general parallelism, not just 
phased parallelism.


I suppose an argument could be made for syntax explicitly aimed at 
phased parallelism ... but using macros, such syntax could be built on 
top of the existing parallel (future, thread, place) APIs - so there is 
nothing stopping you, or anyone else, from creating a "structured 
concurrency" package that everyone can use.



One problem I foresee is defining a reasonable syntax and semantics.   
Most of the languages that promote "structured" concurrency have C-like 
syntax.  Moreover they vary considerably in semantics - in some of them 
the spawning thread stops immediately and can't continue until its 
children exit, but other allow the spawning thread to continue until it 
executes an explicit join / wait for its children.


The Lisp/Scheme based idioms of S-expr Racket are very different from 
those of C-like languages, and whether or not some "Racket2" 
materializes having a more C-like syntax, many people like Racket just 
the way it is.  I can envision heated debates about what should be the 
proper "structuring" semantics and what syntax best represents them.


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/8b83ff75-7b57-f3f1-0514-46170c9c3141%40comcast.net.


Re: [racket-users] Some guidance in setting up Racket as a game scripting language.

2019-10-07 Thread Jens Axel Søgaard
Den man. 7. okt. 2019 kl. 20.15 skrev Hans Sjunnesson <
hans.sjunnes...@gmail.com>:

> I'm sorry Jens - I'm using Visual Studio on Windows to compile this
> project.
> I've initially built libracket, and SDL, which I'm linking against.
> I can zip the entire solution and upload it somewhere for you to have a
> look, but you'll need Visual Studio on Windows for that to work.
>

I don't have a windows machine - but your test example only have two files.
Is there a way to see
what options are applied (in a log perhaps)?

/Jens Axel

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


Re: [racket-users] Structured Concurrency in Racket

2019-10-07 Thread Arie Schlesinger
Can somebody specify how to use racket in jupyter notebook ?
Thanks

On Mon, Oct 7, 2019 at 21:59 jab  wrote:

> Yeah, I’d say give a closer read to
> https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/
>
> Excerpting a footnote:
>
> > For those who can't possibly pay attention to the text without first
> knowing whether I'm aware of their favorite paper, my current list of
> topics to include in my review are: the "parallel composition" operator in
> Cooperating/Communicating Sequential Processes and Occam, the fork/join
> model, Erlang supervisors, Martin Sústrik's article on Structured
> concurrency and work on libdill, and crossbeam::scope / rayon::scope in
> Rust. [Edit: I've also been pointed to the highly relevant
> golang.org/x/sync/errgroup and github.com/oklog/run in Golang.]
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/02b4c456-2af1-4306-b749-b7d54173c7dc%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/CAMJd8C5JqCU82gg3ZoRPwV4H1_SxGQTSht9UXCWFtneSp_MVOA%40mail.gmail.com.


Re: [racket-users] Structured Concurrency in Racket

2019-10-07 Thread jab
Yeah, I’d say give a closer read to 
https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/

Excerpting a footnote:

> For those who can't possibly pay attention to the text without first knowing 
> whether I'm aware of their favorite paper, my current list of topics to 
> include in my review are: the "parallel composition" operator in 
> Cooperating/Communicating Sequential Processes and Occam, the fork/join 
> model, Erlang supervisors, Martin Sústrik's article on Structured concurrency 
> and work on libdill, and crossbeam::scope / rayon::scope in Rust. [Edit: I've 
> also been pointed to the highly relevant golang.org/x/sync/errgroup and 
> github.com/oklog/run in Golang.]

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


Re: [racket-users] Structured Concurrency in Racket

2019-10-07 Thread Matt Jadud
Hi Josh,

Racket has a number of powerful concurrency libraries/extensions that
handle both concurrent execution of code in a single process as well as
parallel execution across multiple processes/hosts. There is the "futures"
library, which might be the most similar to Trio.

https://docs.racket-lang.org/reference/futures.html

However, there are libraries that provide a larger lift, and are
grounded in language traditions that tie back to algebras for reasoning
about parallel systems. The channel library, and the code that builds on it
("places"), are examples.

https://docs.racket-lang.org/reference/channel.html

https://docs.racket-lang.org/guide/parallelism.html

The history of formal reasoning, and implementation of, mechanisms for
concurrency and parallelism go back to at least the... 70's?

https://en.wikipedia.org/wiki/Communicating_sequential_processes

"Structured concurrency" does not, from the link(s) provided, seem to be
anything that stands out from this long tradition. (Or, if you prefer,
computer scientists have been reasoning about, building systems around, and
integrating into languages notions of parallelism and concurrency for
roughly 40+ years.)

So, personally, I would say that Racket has multiple libraries (which,
because of the nature of Racket, are in some cases extensions to the base
language) that implement structured concurrency.

Unless I'm completely misunderstanding your post.

Cheers,
Matt


On Mon, Oct 7, 2019 at 1:46 PM jab  wrote:

> Coming across
> https://trio.discourse.group/t/structured-concurrency-and-delimited-continuations/
> just provoked me to search for discussion of structured concurrency in
> Racket. I didn’t immediately find much.* I hope that doesn’t mean that the
> interesting work that’s being discussed over in
> https://trio.discourse.group/c/structured-concurrency etc. has been
> largely unknown by the Racket community. Trio is having a profound impact
> on the future of concurrency, not just in Python but in many other
> languages. There’s even a post on Wikipedia now:
> https://en.wikipedia.org/wiki/Structured_concurrency
>
> (For anyone new to the term,
> https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/
> might be the best starting point. One persuasive example shows Nathaniel
> live coding a correct implementation of RFC 655 “Happy Eyeballs” in 40
> lines of Python:
> https://github.com/python-trio/trio-talks/tree/master/njsmith-async-concurrency-for-mere-mortals
> (For comparison, Twisted’s implementation took hundreds of lines and still
> had a logic bug after years of work.) There is also some related reading in
> https://github.com/python-trio/trio/wiki/Reading-list.)
>
> I hope this post provokes discussion of structured concurrency in Racket.
> It’d be fascinating to read more of your thoughts!
>
> Thanks,
> Josh
>
> * For example, Googling “structured concurrency racket” turned up mostly
> just a brief mention of Racket’s custodians in the bottom-most comment on
> this post: http://250bpm.com/blog:71
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/bb36e50a-a77b-4c5b-b144-71ce647069b7%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/CAAGM455HSfVgBcu%2B1FZc-mubYaeYEFZb1XxZo_z_sQNqRDO4XQ%40mail.gmail.com.


Re: [racket-users] Some guidance in setting up Racket as a game scripting language.

2019-10-07 Thread Hans Sjunnesson
I'm sorry Jens - I'm using Visual Studio on Windows to compile this project.
I've initially built libracket, and SDL, which I'm linking against.
I can zip the entire solution and upload it somewhere for you to have a 
look, but you'll need Visual Studio on Windows for that to work.

On Saturday, October 5, 2019 at 3:57:09 PM UTC+2, Jens Axel Søgaard wrote:
>
> Den ons. 2. okt. 2019 kl. 15.31 skrev Hans Sjunnesson <
> hans.sj...@gmail.com >:
>
>> This is a hobby project of mine - a game in C, using SDL. I'd like to 
>> only use C for the rendering part - rather use a scripting language for all 
>> of the gameplay code. I want to try to use Racket for this - I've been 
>> doing enough Clojure that I'm familiar with a lisp. My first approach was 
>> to following along "Embedding into a Program" section of the Racket guide. 
>> But I'm running into road blocks - and I can't find any good examples of 
>> projects which embed Racket in a C program that calls functions in a Racket 
>> environment. My initial plan was to define a Racket module that provided an 
>> "init", an "update", and a "draw" function, then call those from the C 
>> program. The embedding guide points me to using "raco" to generate a C 
>> version of "racket/base", and that works - I can eval basic stuff, but I'm 
>> getting an error when I (require "test.rkt"). So I'm guessing there's more 
>> to be done with setting up the environment.
>>
>
> How do I compile the two test files?
> In the reddit thread you said, I should start with:
> raco ctool --c-mods base.c ++lib racket/base
>
> But what are the options for gcc and the linker?
>
> /Jens Axel
>
>

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


[racket-users] Structured Concurrency in Racket

2019-10-07 Thread jab
Coming across 
https://trio.discourse.group/t/structured-concurrency-and-delimited-continuations/
 just provoked me to search for discussion of structured concurrency in Racket. 
I didn’t immediately find much.* I hope that doesn’t mean that the interesting 
work that’s being discussed over in 
https://trio.discourse.group/c/structured-concurrency etc. has been largely 
unknown by the Racket community. Trio is having a profound impact on the future 
of concurrency, not just in Python but in many other languages. There’s even a 
post on Wikipedia now: https://en.wikipedia.org/wiki/Structured_concurrency

(For anyone new to the term, 
https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/
 might be the best starting point. One persuasive example shows Nathaniel live 
coding a correct implementation of RFC 655 “Happy Eyeballs” in 40 lines of 
Python: 
https://github.com/python-trio/trio-talks/tree/master/njsmith-async-concurrency-for-mere-mortals
  (For comparison, Twisted’s implementation took hundreds of lines and still 
had a logic bug after years of work.) There is also some related reading in 
https://github.com/python-trio/trio/wiki/Reading-list.)

I hope this post provokes discussion of structured concurrency in Racket. It’d 
be fascinating to read more of your thoughts!

Thanks,
Josh

* For example, Googling “structured concurrency racket” turned up mostly just a 
brief mention of Racket’s custodians in the bottom-most comment on this post: 
http://250bpm.com/blog:71

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


Re: [racket-users] Mysterious issue with pict/code

2019-10-07 Thread Matthew Flatt
Yes, that one (combined with the previous commit).

At Mon, 7 Oct 2019 09:23:49 -0700, Stephen Foster wrote:
> Awesome!  Thanks. :)
> 
> Just for my own curiosity, is it this commit or a different one?
> 
> https://github.com/racket/racket/commit/9bb5bc935251e25490dec82f824e1d8e9cd202c
> 9
> 
> 
> 
> On Sat, Oct 5, 2019 at 6:42 PM Matthew Flatt  wrote:
> 
> > Thanks for the report and simplification! I've pushed a repair.
> >
> > At Sat, 5 Oct 2019 15:33:31 -0400, Sam Tobin-Hochstadt wrote:
> > > This definitely seems like a bug. Here's a smaller program that shows it:
> > >
> > > #lang racket
> > > (begin-for-syntax
> > >   (dynamic-require 'pict/code #f))
> > >
> > > Sam
> > >
> > > On Sat, Oct 5, 2019 at 12:56 PM Stephen Foster 
> > wrote:
> > > >
> > > > I spent a few hours tracking down a mysterious bug.  Although I've
> > fixed it,
> > > I still don't understand it. I would appreciate some insight from those
> > who
> > > understand these things better.
> > > >
> > > > Here's the simple reproduction:
> > > >
> > > > main.rkt:
> > > >
> > > > #lang racket
> > > >
> > > > (define-syntax (test stx)
> > > >
> > > >   (dynamic-require "./other.rkt" #f)
> > > >
> > > >   #'(displayln "HI"))
> > > >
> > > > ;This is fine
> > > > (dynamic-require "./other.rkt" #f)
> > > >
> > > > ;This triggers the error
> > > > (test)
> > > >
> > > >
> > > > And other.rkt is simply:
> > > >
> > > > #lang racket
> > > >
> > > > (require pict/code)
> > > >
> > > > The error when running main.rkt is:
> > > >
> > > > no module instance found: # > > v7.4/collects/racket/private/list.rkt"> 0
> > > >
> > > >
> > > >   context...:
> > > >
> > > >
> > > >namespace->module-namespace82
> > > >
> > > >
> > > >copy-namespace-value
> > > >
> > > >
> > > >temp250
> > > >
> > > >
> > > >for-loop
> > > >
> > > >
> > > >[repeats 1 more time]
> > > >
> > > >
> > > >perform-require!78
> > > >
> > > >
> > > >/Applications/Racket
> > > v7.4/share/pkgs/compatibility-lib/mzscheme/private/old-procs.rkt:47:4:
> > > make-namespace
> > > >
> > > >
> > > >.../racket/unit.rkt:996:20
> > > >
> > > >
> > > >"/Applications/Racket v7.4/share/pkgs/pict-lib/pict/code.rkt":
> > [running
> > > body]
> > > >
> > > >
> > > >temp37_0
> > > >
> > > >
> > > >for-loop
> > > >
> > > >
> > > >run-module-instance!125
> > > >
> > > >
> > > >for-loop
> > > >
> > > >
> > > >[repeats 1 more time]
> > > >
> > > >
> > > >run-module-instance!125
> > > >
> > > >
> > > >apply-transformer-in-context
> > > >
> > > >
> > > >...
> > > >
> > > >
> > > >
> > > >
> > > > It would appear that the dynamic-require of a module that requires
> > pict/code
> > > fails inside a macro, but not otherwise.  What's up with that?
> > > >
> > > > --Stephen
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > "Racket Users" group.
> > > > To unsubscribe from this group and stop receiving emails from it, send
> > an
> > > email to racket-users+unsubscr...@googlegroups.com.
> > > > To view this discussion on the web visit
> > >
> > 
> https://groups.google.com/d/msgid/racket-users/7acffe39-c491-4da6-b00b-2450e41f
> > > 5008%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%2BYGMeCVCO_h_NXErf1LQWz
> > > NWxmBXWTQNt%3DUt2iyyVv5Yw%40mail.gmail.com.
> >
> > --
> > You received this message because you are subscribed to a topic in the
> > Google Groups "Racket Users" group.
> > To unsubscribe from this topic, visit
> > https://groups.google.com/d/topic/racket-users/ouNaokcNdpo/unsubscribe.
> > To unsubscribe from this group and all its topics, send an email to
> > racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> > 
> https://groups.google.com/d/msgid/racket-users/5d994668.1c69fb81.28e90.27b3SMTP
> IN_ADDED_MISSING%40gmr-mx.google.com
> > .
> >
> 
> 
> -- 
> 
> 
> Stephen Foster
> ThoughtSTEM Co-Founder
> 318-792-2035
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CA%2BzSu29PCzOtjZSjHegoJ%3D3KM-%
> 3DCB1mOnvQOCTR-dsvkjzsCpg%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 

Re: [racket-users] Mysterious issue with pict/code

2019-10-07 Thread Stephen Foster
Awesome!  Thanks. :)

Just for my own curiosity, is it this commit or a different one?

https://github.com/racket/racket/commit/9bb5bc935251e25490dec82f824e1d8e9cd202c9



On Sat, Oct 5, 2019 at 6:42 PM Matthew Flatt  wrote:

> Thanks for the report and simplification! I've pushed a repair.
>
> At Sat, 5 Oct 2019 15:33:31 -0400, Sam Tobin-Hochstadt wrote:
> > This definitely seems like a bug. Here's a smaller program that shows it:
> >
> > #lang racket
> > (begin-for-syntax
> >   (dynamic-require 'pict/code #f))
> >
> > Sam
> >
> > On Sat, Oct 5, 2019 at 12:56 PM Stephen Foster 
> wrote:
> > >
> > > I spent a few hours tracking down a mysterious bug.  Although I've
> fixed it,
> > I still don't understand it. I would appreciate some insight from those
> who
> > understand these things better.
> > >
> > > Here's the simple reproduction:
> > >
> > > main.rkt:
> > >
> > > #lang racket
> > >
> > > (define-syntax (test stx)
> > >
> > >   (dynamic-require "./other.rkt" #f)
> > >
> > >   #'(displayln "HI"))
> > >
> > > ;This is fine
> > > (dynamic-require "./other.rkt" #f)
> > >
> > > ;This triggers the error
> > > (test)
> > >
> > >
> > > And other.rkt is simply:
> > >
> > > #lang racket
> > >
> > > (require pict/code)
> > >
> > > The error when running main.rkt is:
> > >
> > > no module instance found: # > v7.4/collects/racket/private/list.rkt"> 0
> > >
> > >
> > >   context...:
> > >
> > >
> > >namespace->module-namespace82
> > >
> > >
> > >copy-namespace-value
> > >
> > >
> > >temp250
> > >
> > >
> > >for-loop
> > >
> > >
> > >[repeats 1 more time]
> > >
> > >
> > >perform-require!78
> > >
> > >
> > >/Applications/Racket
> > v7.4/share/pkgs/compatibility-lib/mzscheme/private/old-procs.rkt:47:4:
> > make-namespace
> > >
> > >
> > >.../racket/unit.rkt:996:20
> > >
> > >
> > >"/Applications/Racket v7.4/share/pkgs/pict-lib/pict/code.rkt":
> [running
> > body]
> > >
> > >
> > >temp37_0
> > >
> > >
> > >for-loop
> > >
> > >
> > >run-module-instance!125
> > >
> > >
> > >for-loop
> > >
> > >
> > >[repeats 1 more time]
> > >
> > >
> > >run-module-instance!125
> > >
> > >
> > >apply-transformer-in-context
> > >
> > >
> > >...
> > >
> > >
> > >
> > >
> > > It would appear that the dynamic-require of a module that requires
> pict/code
> > fails inside a macro, but not otherwise.  What's up with that?
> > >
> > > --Stephen
> > >
> > >
> > >
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > "Racket Users" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to racket-users+unsubscr...@googlegroups.com.
> > > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/racket-users/7acffe39-c491-4da6-b00b-2450e41f
> > 5008%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%2BYGMeCVCO_h_NXErf1LQWz
> > NWxmBXWTQNt%3DUt2iyyVv5Yw%40mail.gmail.com.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Racket Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/racket-users/ouNaokcNdpo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/5d994668.1c69fb81.28e90.27b3SMTPIN_ADDED_MISSING%40gmr-mx.google.com
> .
>


-- 


Stephen Foster
ThoughtSTEM Co-Founder
318-792-2035

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


Re: [racket-users] Re: My macro works in the global namespace, but fails inside of a let

2019-10-07 Thread Eric Griffis
Hi Cistian,

Both of your examples are hygienic, in the sense that neither actually
do anything that violates macro hygiene.

When `a_definition` is defined in the module context (i.e., the
"global namespace"), it has the same scope as the `a_definition` used
inside `my-macro`. (There's more to it, but this is enough for now.)

When `a_definition` is defined in a local context (e.g., inside a
`(let () ...)` form) outside `my-macro`, it won't have the same scope
as the `a_definition` used inside `my-macro`.

There's an easy trick to get around this. As Simon suggested, make
`a_definition` an argument to `my-macro`:

  (define-simple-macro (my-macro a_definition)
(display a_definition))

Now, each call to `my-macro` "borrows" `a_definition` from the macro
caller's scope. There are other ways to tackle the problem, but this
is the safest option.

Eric

On Mon, Oct 7, 2019 at 7:33 AM Cistian Alejandro Alvarado Vázquez
 wrote:
>
> Okay, that I am aware of, but why is it hygienic inside of let but *not* in 
> the global namespace? Also, you should (from my limited understanding!) still 
> be able to access bindings from inside of a macro, no? For example, I can 
> call functions inside of a macro and those identifiers are available even 
> though they weren't provided as arguments. So it appears that macros have 
> access to module-level bindings but NOT more local bindings, and that is what 
> I'm confused about.
>
> On Monday, 7 October 2019 08:04:56 UTC-5, Simon Schlee wrote:
>>
>> Your second macro does not work as you expect, because by default macros in 
>> racket are hygienic, described roughly that means that a macro only 
>> "manipulates" the syntax it is given as arguments, not with the syntax 
>> around its invocation. As gfb has mentioned one way to do this is to use 
>> parameters, this way you can achieve dynamic effects without breaking 
>> hygiene.
>>
>> Why is hygiene good? This section in the guide explains: 
>> https://docs.racket-lang.org/guide/pattern-macros.html?q=macro#%28part._.Lexical_.Scope%29
>>
>> You say you want to use some definitions in your macro, why not just pass 
>> the relevant ones as parameters?
>> Without knowing more about what you are trying to do, it is difficult to 
>> suggest a good direction/solution.
>>
>> Not part of the answer, but related and interesting:
>> (fifth RacketCon): Matthew Flatt — Bindings as Sets of Scopes
>> https://www.youtube.com/watch?v=ABWLveMNdzg
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/47407fc2-2c51-4cf1-a5b7-78a390484fbf%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/CAORuSUwA-%3DLEK7DughwXZKyW2d10oxV8EcXgGgx5jnonioMX6g%40mail.gmail.com.


[racket-users] Racket News - Issue 17

2019-10-07 Thread Paulo Matos
Hi,

RN Issue 17 is finally here.
https://racket-news.com/2019/10/racket-news-issue-17.html

Enjoy,

Paulo

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


[racket-users] Re: My macro works in the global namespace, but fails inside of a let

2019-10-07 Thread Cistian Alejandro Alvarado Vázquez
Okay, that I am aware of, but why is it hygienic inside of let but *not* in 
the global namespace? Also, you should (from my limited understanding!) 
still be able to access bindings from inside of a macro, no? For example, I 
can call functions inside of a macro and those identifiers are available 
even though they weren't provided as arguments. So it appears that macros 
have access to module-level bindings but NOT more local bindings, and that 
is what I'm confused about.

On Monday, 7 October 2019 08:04:56 UTC-5, Simon Schlee wrote:
>
> Your second macro does not work as you expect, because by default macros 
> in racket are hygienic, described roughly that means that a macro only 
> "manipulates" the syntax it is given as arguments, not with the syntax 
> around its invocation. As gfb has mentioned one way to do this is to use 
> parameters, this way you can achieve dynamic effects without breaking 
> hygiene.
>
> Why is hygiene good? This section in the guide explains: 
> https://docs.racket-lang.org/guide/pattern-macros.html?q=macro#%28part._.Lexical_.Scope%29
>
> You say you want to use some definitions in your macro, why not just pass 
> the relevant ones as parameters? 
> Without knowing more about what you are trying to do, it is difficult to 
> suggest a good direction/solution.
>
> Not part of the answer, but related and interesting:
> (fifth RacketCon): Matthew Flatt — Bindings as Sets of Scopes
> https://www.youtube.com/watch?v=ABWLveMNdzg
>

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


[racket-users] Re: My macro works in the global namespace, but fails inside of a let

2019-10-07 Thread Simon Schlee
I meant to write (less confusing):
"You say you want to use some definitions in your macro, why not just pass 
the relevant ones as arguments to your macro?" 

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


[racket-users] Re: My macro works in the global namespace, but fails inside of a let

2019-10-07 Thread Simon Schlee
Your second macro does not work as you expect, because by default macros in 
racket are hygienic, described roughly that means that a macro only 
"manipulates" the syntax it is given as arguments, not with the syntax 
around its invocation. As gfb has mentioned one way to do this is to use 
parameters, this way you can achieve dynamic effects without breaking 
hygiene.

Why is hygiene good? This section in the guide explains: 
https://docs.racket-lang.org/guide/pattern-macros.html?q=macro#%28part._.Lexical_.Scope%29

You say you want to use some definitions in your macro, why not just pass 
the relevant ones as parameters? 
Without knowing more about what you are trying to do, it is difficult to 
suggest a good direction/solution.

Not part of the answer, but related and interesting:
(fifth RacketCon): Matthew Flatt — Bindings as Sets of Scopes
https://www.youtube.com/watch?v=ABWLveMNdzg

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


[racket-users] Parallel merge-sort leveraging futures

2019-10-07 Thread Dominik Pantůček
Hello,

over the course of past few months I have been tasked with solving a
(real-world) problem of sorting the sums of all possible combinations of
numbers. Some boring accounting stuff revolving around invoices. As the
total number of combinations is 2^N where N is the number of source
numbers, this task got "interesting" once there were more than 24
numbers - that is on my laptop with:

model name  : Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz

4 cores, 8 hyper-threads and 16GB RAM.

Long story short, I had to implement a custom merge-sort for fxvectors
and managed to leverage futures for fully parallel execution. Now in
some spare time, I slightly polished the code and released it as
"futures-sort" package.

The source code is available on GitHub[1] and it is already in Racket
package index[2].

The package provides four sorting functions - two for vector? and two
for fxvector?. There are two variants of each, one with progress
reporting and one without. For the original task I needed to show
progress using racket/gui gauge% and it might be helpful for others
(it's just a callback that gets current and total number of merges
performed regularly).

I would really appreciate any feedback regarding the naming conventions,
code style and generally anything else.

Yes, the tests are not there (yet).

The same algorithm without futures runs on par with Racket's default
sorting routines (tested for sets upto 2^30 - only 16G of memory here)
and for fixnums it is even (very slightly but consistently) faster than
vector-sort alone. With parallelism using futures it runs roughly N
times faster where N is the number reported by (processor-count).

I have already some benchmark results available and once I get more data
I am more than happy to share it as well.

The parallelism is configurable as parameter.

And yes, all of this can be seen in the documentation which is included
but I still have to look into how to build it - I was sort of assuming
this works automatically based on what I see for example in
scribble-math[3][4]. Any help with getting this right is also more than
welcome.


Lastly - thanks go out to Jens Axel Søgaard for pointing out that
fixnums and fxvectors might help (and why) and also to other helpful
folks on #racket at Freenode.


Cheers,
Dominik


[1] https://github.com/dzoep/futures-sort
[2] https://pkgd.racket-lang.org/pkgn/package/futures-sort
[3] https://docs.racket-lang.org/scribble-math/index.html
[4] https://pkgd.racket-lang.org/pkgn/package/scribble-math

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/bdddfd14-7e06-28e7-91c0-67a2403f5629%40trustica.cz.


[racket-users] Best path to a typed/racket compilation target?

2019-10-07 Thread Raoul Schorer
Hi,

There are multiple potential ways to compile to typed/racket from a custom 
language. A few I am aware of:

- roll-your-own macros compiling to typed code (my current solution)
- typed-expander
- turnstile package

Maybe there are others that I don't know of, but how you would do it as an 
experienced racket user?

Also, if I want to compile to an intermediate AST before code generation, how 
to best represent the AST in the macros? Plain lists? Something else?

Thank you for your help!
Raoul

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