Re: [racket-users] Smart contracts in Racket

2021-03-18 Thread Christopher Lemmer Webber
James Platt writes:

> On Mar 16, 2021, at 3:24 PM, Christopher Lemmer Webber wrote:
>
>> But "smart contracts" is a use case, a broad problem domain.  What kind
>> of smart contracts are you wanting to write?
>
> I do need to research the topic a bit to make sure that what I want to
> do is possible but, according to what I understand so far, it's
> actually a clearer use case for smart contracts than most.  I want to
> use them to promote reproducibility of scientific data analysis.  The
> idea would be that you put your data analysis together as a smart
> contract and then others can run it again and be much better assured
> of getting the same result than they would be without the smart
> contract.  As I understand it, one of the big issues with smart
> contracts for work transactions is that there could be a bug which
> causes your contract to enforce something a bit differently than you
> intended. This is quite different from traditional business contracts
> where, if it comes to a lawsuit, the courts will look for the intent
> of the contract.  My use case is only asking for reproducibility.
>
> The big difficulty for my use case is that you have to be able to tie
> into various different bits of code previously published by others.
> For example, a DNA sequencing analysis pipeline which I worked with,
> had various parts of the process written in Perl, Python, C, R, JAVA,
> javascript, UNIX shell script, and AppleScript, much of it published
> by people outside my lab.  So a lot of that would probably have to be
> outside the contract.  However, you need a "glue language" to put it
> all together.  We were using shell script for that because most of it
> needs to run on a supercomputing cluster.  We looked for something
> that could make the code more understandable.  Python was a
> possibility but we were leaning towards Big Data Script (BDS) which is
> a DSL specifically for this purpose.  In any case, if something like
> BDS (as a glue language) were implemented as a smart contract
> language, that would at least take care of the top level.
>
> Later on, it would be great to be able to buy and sell resources on
> our P2P network with a cryptocurrency.  This would include storage,
> bandwidth, and processing time for intensive computations.  You would
> be able to buy and sell smart contracts using these things.  I
> understand that Etherium can do things like this but there are quite a
> few technologies to read up on, starting with Subutai,
> https://subutai.io.

You may enjoy reading the "72 Hours to DonutLab" writeup.

  https://www.hpl.hp.com/techreports/2005/HPL-2005-5.html

Again, pre-blockchains.  This is using the E programming language on
which Spritely is based.  As you can see, it's even listed on the E
website under "smart contracts":

  http://www.erights.org/smart-contracts/index.html

As for running external programs, these can be contained; SandStorm did
a nice demonstration of how to do this.  Guix Workflow Language might
also be an interesting source of inspiration, even though I'm not
suggesting it exactly be what you use.

However, I'd be cautious about drinking too deeply into the blockchain
hype; the things you'd like to accomplish can probably be accomplished
just as well with an E-style mint, as I referenced earlier.  But yes,
you can compose blockchains with this too... but more importantly, the
abstraction layer can be *general* enough to not use a *specific* choice
of a cryptocurrency approach.  Beware of someone trying to sell you
otherwise on some ICO.

The way that blockchains can just be perceived as mutually-executed
machines on the network (in that sense, "decentralized centralization"
converging on a single machine in the network, reproduced in multiple
places) is probably best explained by this talk:

  https://www.youtube.com/watch?v=YXUqfgdDbr8

With the abstractions Mark talks about in that talk (ERTP), you can use
a blockchain... but also plenty of non-blockchain components which might
work just as well for your usecase.  But then you haven't tied yourself
to a specific approach.  Generalize appropriately.

 - 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/87o8fg17do.fsf%40dustycloud.org.


Re: [racket-users] Smart contracts in Racket

2021-03-16 Thread Christopher Lemmer Webber
James Platt writes:

> On Mar 15, 2021, at 7:01 PM, Beatriz Moreira wrote:
>
>> Hello! I recently used Racket as a tool to see the small step
>> execution of some smart contract languages and I was wondering if
>> there is anywhere i can submit my work or share it with the Racket
>> community.
>
> One place might be the Racket Artifacts site.  I think it's mainly
> intended for short demonstrations of code but, if yours is not too
> long, that might be the place.
>
> https://github.com/racket/racket/wiki/Artifacts
>
> I am interested in smart contracts, as well, for a possible future
> addition to a project I am working on but it will be a while before I
> get to that point.

Spritely Goblins is probably what you want to look at, or will after the
next release (v0.8) comes out:

   https://docs.racket-lang.org/goblins/index.html

In the not too distant future, Spritely and Agoric's CapTP should
converge.  Agoric's current work is all based around smart contracts:

  https://agoric.com/
  https://github.com/Agoric/agoric-sdk/issues/1827

There's a lot of confusion out there about what "smart contracts" mean;
most of the examples tend to assume it has to do with blockchains.  In
fact, work on smart contracts precedes blockchains by several decades.
If you look at http://www.erights.org/ on which many of the ideas in
Spritely Goblins is based, you'll notice that it has the word "smart
contracts" prominently, yet this was well over a decade before
blockchains even existed.  What the heck?

Smart contracts as something implemented with distributed objects can be
best understood probably by reading Capability Based Financial Instruments:

  http://erights.org/elib/capability/ode/index.html

The mint example from that paper is implemented in Goblins:

  
https://gitlab.com/spritely/goblins/-/blob/dev/goblins/actor-lib/simple-mint.rkt

That's right, in about 25 lines of Goblins code you can have a
functioning bank of sorts, which preserves financial integrity and even
permits networked accounts.  No blockchain required.

Yet, you could add a blockchain, or even turn Goblins into a blockchain
if you wanted.  (Since Goblins' actor state is transactional and
snapshottable, you can have a merkle tree of all inputs, and global
consensus on the set of messages accepted by the network, and all
participants can replay and simulate the same abstract machine.  This is
fairly trivial to do in Goblins.)

But more interestingly, Agoric has already done the work of abstracting
even remote blockchains as abstract machines on the network.  Since
we'll be implementing the same CapTP, when the time comes you'll be able
to access all that for free, even though Agoric programs are written in
Javascript and Goblins programs in Racket.

Anyway, the next release of Goblins, coming soon, should allow for
beginning to play with this kind of stuff on the network more easily
than in the present (v0.7) stuff, which currently takes a lot of work.
So maybe if you can wait a few weeks, it'll be easier to talk about.

But "smart contracts" is a use case, a broad problem domain.  What kind
of smart contracts are you wanting to write?

 - 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/87h7lac36a.fsf%40dustycloud.org.


[racket-users] SOCKS5 usage?

2021-02-17 Thread Christopher Lemmer Webber
Hello,

Has anyone written or used a SOCKS5 type shim around the tcp layer of
Racket?  I haven't found one, wonder if I have to write it myself or
not.

 - 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/87czwy4msa.fsf%40dustycloud.org.


Re: [racket-users] Developing Scribble as a user when Scribble is installed system-wide

2020-11-05 Thread Christopher Lemmer Webber
Matthew Flatt writes:

> At Thu, 05 Nov 2020 13:01:36 -0500, Christopher Lemmer Webber wrote:
>> I'm guessing it's probably due to these error messages:
>> 
>> $ raco pkg update --scope user --clone scribble-lib
>> Inferred package name from given `--clone' path
>>   package: scribble-lib
>>   given path: scribble-lib
>> raco pkg update: package installed in a different scope
>>   package: scribble-lib
>>   current scope: user
>>   installed in scope: installation
>
> The right way to avoid this message in you case is likely to specify
> the same scope as the starting "scribble" copy, which is installation
> scope, via `-i`.
>
>> I see that I can make it happen using the following steps:
>> 
>> cwebber@twig:~/devel/scribble/scribble-lib$ raco pkg install --force
>> [...]
>> 
>> I know you've warned me I don't want to do install --force though. :)
>> 
>> Though... now I've done it for all of the Scribble sub-packages, and
>> things seem to work now...
>> 
>> Might I ask why I shouldn't do the thing I've just done then?
>
> Your installation is now in a state where some packages that depend on
> "scribble" are built against the installation-wide copy, while others
> are (or will become as you run `raco setup` or more package commands)
> built with your user-specific copy.
>
> As long as your work as the same user, and as long as you don't run
> anything that constraints effects to installation scope, then it might
> all work... until it doesn't. Fundamentally, `raco setup` is not
> designed to support dependencies that go backward from installation
> scope to user scope, and so it doesn't make that work reliably.
>
> Most likely, the installation is really all your own, and not
> multi-user. In that case, you should just work at the level of the
> installation to avoid a mismatch.
>
>
> Matthew

I see.  That's a good explaination.

Also all the more motivation to support Guix-based Racket
development... :)

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


Re: [racket-users] Developing Scribble as a user when Scribble is installed system-wide

2020-11-05 Thread Christopher Lemmer Webber
Thanks for your help Sam (and for trying to help me on IRC earlier, even
though I still apparently haven't understoood).

It looks like via that command, I really don't have anything installed:

$ raco pkg show -l --rx scribble
Installation-wide:
 Package[*=auto]   ChecksumSource
 scribble* a5cb923ee68ca75f7c38fa292d0676fd864ce4d8(catalog 
"scribble")
 scribble-doc* 75fc2487c34972216972c28170e27132ea73486d(catalog 
"scribble-doc")
 scribble-html-lib*312698505f94222be672038938cef024f20f8f1f(catalog 
"scribble-html-lib")
 scribble-lib* a103fc2974188b3d007fd4e38f424e3498993ffb(catalog 
"scribble-lib")
 scribble-text-lib*817c9ad5450aec2d7fcdbe217a134b535d32f4fb(catalog 
"scribble-text-lib")
User-specific for installation "7.8":
 [none]

I'm guessing it's probably due to these error messages:

$ raco pkg update --scope user --clone scribble-lib
Inferred package name from given `--clone' path
  package: scribble-lib
  given path: scribble-lib
raco pkg update: package installed in a different scope
  package: scribble-lib
  current scope: user
  installed in scope: installation

I see that I can make it happen using the following steps:

cwebber@twig:~/devel/scribble/scribble-lib$ raco pkg install --force
Linking current directory as a package
...
cwebber@twig:~/devel/scribble/scribble-lib$ raco pkg show -l --rx scribble
warning: tool "scribble" registered twice: "scribble" and 
#
Installation-wide:
 Package[*=auto]   ChecksumSource
 scribble* a5cb923ee68ca75f7c38fa292d0676fd864ce4d8(catalog 
"scribble")
 scribble-doc* 75fc2487c34972216972c28170e27132ea73486d(catalog 
"scribble-doc")
 scribble-html-lib*312698505f94222be672038938cef024f20f8f1f(catalog 
"scribble-html-lib")
 scribble-lib* a103fc2974188b3d007fd4e38f424e3498993ffb(catalog 
"scribble-lib")
 scribble-text-lib*817c9ad5450aec2d7fcdbe217a134b535d32f4fb(catalog 
"scribble-text-lib")
User-specific for installation "7.8":
 Package ChecksumSource
 scribble-lib#f  (link "/home/cwebber/devel/scribble/scribble-lib")

I know you've warned me I don't want to do install --force though. :)

Though... now I've done it for all of the Scribble sub-packages, and
things seem to work now...

Might I ask why I shouldn't do the thing I've just done then?


Sam Tobin-Hochstadt writes:

> Can you post the output of `raco pkg show -l --rx scribble`?
>
> Sam
>
> On Wed, Nov 4, 2020 at 8:10 PM Christopher Lemmer Webber
>  wrote:
>>
>> I've done the following to my git repo of scribble:
>>
>>   raco pkg update --scope user --clone scribble-lib
>>   raco pkg update --scope user --clone scribble-doc
>>   raco pkg update --scope user --clone scribble
>>
>> I also tried removing that and doing:
>>
>>   raco pkg install --scope user --clone scribble-lib
>>   raco pkg install --scope user --clone scribble-doc
>>   raco pkg install --scope user --clone scribble
>>
>> Regardless, like it installed it in userspace.  Okay.
>>
>> But it seems like running "raco scribble" or importing scribble and
>> then checking where the install paths are from, it's still seeming to
>> use the system install verison of scribble.
>>
>> Not sure what I should do... shouldn't it be the case that user packages
>> take priority?
>>
>>  - 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/87eel87goo.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/87tuu34r9b.fsf%40dustycloud.org.


[racket-users] Developing Scribble as a user when Scribble is installed system-wide

2020-11-04 Thread Christopher Lemmer Webber
I've done the following to my git repo of scribble:

  raco pkg update --scope user --clone scribble-lib
  raco pkg update --scope user --clone scribble-doc
  raco pkg update --scope user --clone scribble
  
I also tried removing that and doing:

  raco pkg install --scope user --clone scribble-lib
  raco pkg install --scope user --clone scribble-doc
  raco pkg install --scope user --clone scribble

Regardless, like it installed it in userspace.  Okay.

But it seems like running "raco scribble" or importing scribble and
then checking where the install paths are from, it's still seeming to
use the system install verison of scribble.

Not sure what I should do... shouldn't it be the case that user packages
take priority?

 - 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/87eel87goo.fsf%40dustycloud.org.


[racket-users] Re: Is there a way to use raco to insall packages offline?

2020-10-29 Thread Christopher Lemmer Webber
Bonface M. K. writes:

> Hi Racket!
>
> I've been exploring ways of creating a build
> system for racket in Guix, which essentially means
> providing a way for having racket packages
> directly packaged defined in an *.scm file and
> letting guix handle the rest for you. From my
> research so far, I see that you have to do most of
> the steps of installing the collections, libs, and
> updating the links manually. However, I wonder if
> you could use raco(sorry if that comes off naive)
> to do that work for you, but offline. Is that
> possible, if you provide source files locally,
> could you let raco do the installations for you?
> If that's possible, are thery any weird
> limitations to that?

Hi Bonface,

As I've already told you, I'm very excited that you're taking on this
work. :)

You can usually install raco packages offline, yes, in that you can go
to the source directory (usually wherever the info.rkt file is) and type:

  raco pkg install

This will "set up" that directory as the official place of install.
Does that make sense or answer your question at all?

 - 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/871rhh59kl.fsf%40dustycloud.org.


Re: [racket-users] How hard is it to add @-exp support to racket:text%?

2020-10-16 Thread Christopher Lemmer Webber
... ah I didn't realize that :)

Okay great!  Thanks Robby! :)

Robby Findler writes:

> If the buffer contains #"lang scribble/base" at the start, then it should
> "just work", no?
>
> Robby
>
> On Thu, Oct 15, 2020 at 8:19 AM Christopher Lemmer Webber <
> cweb...@dustycloud.org> wrote:
>
>> This isn't super high priority... but Morgan and I are working on the
>> first mini virtual worlds demo for Spritely, and I've put the extremely
>> nice racket:text% to use for code editing:
>>
>>   https://dustycloud.org/gfx/goodies/fairy-forest-ui-mockup2.png
>>
>> Since there's so much text, it would be even better if I could enable
>> at-exp support.  It doesn't look like the defaults for the racket:text%
>> editor support it nicely though.
>>
>> Just out of curiousity, has anyone already done the work of figuring out
>> how to add such functionality to make the scribble-style at-exp
>> highlighting/indentation/etc look nice with racket:text%?  If not I can
>> just put this off and not provide that feature, but it would be nicer
>> with it I think.
>>
>>  - 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/875z7b4oi3.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/87o8l128jh.fsf%40dustycloud.org.


[racket-users] How hard is it to add @-exp support to racket:text%?

2020-10-15 Thread Christopher Lemmer Webber
This isn't super high priority... but Morgan and I are working on the
first mini virtual worlds demo for Spritely, and I've put the extremely
nice racket:text% to use for code editing:

  https://dustycloud.org/gfx/goodies/fairy-forest-ui-mockup2.png

Since there's so much text, it would be even better if I could enable
at-exp support.  It doesn't look like the defaults for the racket:text%
editor support it nicely though.

Just out of curiousity, has anyone already done the work of figuring out
how to add such functionality to make the scribble-style at-exp
highlighting/indentation/etc look nice with racket:text%?  If not I can
just put this off and not provide that feature, but it would be nicer
with it I think.

 - 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/875z7b4oi3.fsf%40dustycloud.org.


Re: [racket-users] Is it possible to embed a scheme'y text editor in another GUI application?

2020-10-11 Thread Christopher Lemmer Webber
Matthew Flatt writes:

> At Sun, 05 Aug 2018 11:50:09 -0400, Christopher Lemmer Webber wrote:
>> DrRacket includes a nice Scheme editor.  I don't need the whole
>> thing... but some of it would be nice, like the paren matching.  How
>> reusable is DrRacket's text editor tooling?  Reusable enough to embed in
>> another application?  Or would I have to rewrite this?
>
> You can use `racket:text%`.
>
> I usually find that I need something a little different than
> `racket:text%`, for one reason or another, but composing the right
> pieces of the "framework" collection can be tricky. If `racket:text%`
> isn't exactly what you want, you might look at this bit of the
> "slideshow-repl" package (which embeds a Racket editor into a Slideshow
> presentation) as an extra example:
>
> https://github.com/mflatt/slideshow-repl/blob/master/slideshow/private/editor.rkt

Been a while since I originally asked this, and I did put racket:text%
to use!

  https://dustycloud.org/gfx/goodies/fairy-forest-ui-mockup2.png

Out of curiosity, how hard is it to compose in other #lang type things
into this?  At the very least, it would be nice for my purposes to be
able to enable something scribble-like or at least the at-exp feature.

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


[racket-users] Spritely website launches (plus, Goblins + networked programming)

2020-09-28 Thread Christopher Lemmer Webber
Hello all,

First of all, Spritely's website has finally launched:

  https://spritelyproject.org/

If you're wondering what on earth I've been doing, and where all my work
is going, this is a good explaination as any.  There's also a video you
can see on that page that I gave for a presentation for ActivityPub
Conference 2020:

  https://conf.tube/videos/watch/18aa2f92-36cc-4424-9a4f-6f2de946fbd2

Also, here's a fun easter egg:

  https://conf.tube/videos/watch/285e7580-8281-4ae4-842e-81c687237c69

But of course, the main thing of interest to most racketeers is Spritely
Goblins, the ocap'y actor model'y distributed transactional programming
library thingy I've been building in Racket.  The most recent release
(v0.7) has added the beginings of distributed programming support:

  https://docs.racket-lang.org/goblins/captp.html

However it isn't as easy to use as it could be.  More will be coming in
v0.8, which is when I can start recommending people start building
programs on top of it (and when I think we'll switch from alpha to
beta).

There is much more to say about Spritely Goblins, and I will be also
giving a talk at RacketCon about it, much more focused on the code side
than my APConf talk was.  (I'm still trying to restructure it based on
feedback!  Getting close!)  So more then.

 - 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/87k0wd4tr6.fsf%40dustycloud.org.


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

2020-09-03 Thread Christopher Lemmer Webber
Cool!  Thanks for sharing :)

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


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

2020-09-02 Thread Christopher Lemmer Webber
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.
> <https://github.com/racket/racket/issues/1710>) 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.


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

2020-09-02 Thread Christopher Lemmer Webber
Ah, I didn't know one could just write a function for the guard... but
that makes a lot of sense!

Sam Tobin-Hochstadt writes:

> The issue is that `struct-guard/c` is slow. If you just write a
> function as a guard it's faster than `struct/contract`.
>
> Sam
>
> On Wed, Sep 2, 2020 at 3:41 PM Christopher Lemmer Webber
>  wrote:
>>
>> I tested the following:
>>
>>   (struct foo (bar baz)
>> #:guard (struct-guard/c any/c list?))
>>
>> and:
>>
>>   (struct/contract foo ([bar any/c]
>> [baz list?]))
>>
>> With the first:
>>
>>   test> (time
>>  (for ([i 100])
>>(foo 'yeah '(buddy
>>   cpu time: 2601 real time: 2599 gc time: 7
>>
>> With the second:
>>
>>   test> (time
>>  (for ([i 100])
>>(foo 'yeah '(buddy
>>   cpu time: 184 real time: 184 gc time: 13
>>
>> Wow, what the heck?  That's about a 10x difference.  What?!?!?
>> Why would #:guard be so damn slow in comparison?  You'd think they'd be
>> doing the same thing.
>>
>> 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?
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/873640arw7.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/87zh67a8cy.fsf%40dustycloud.org.


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

2020-09-02 Thread Christopher Lemmer Webber
I tested the following:

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

and:

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

With the first:

  test> (time
 (for ([i 100])
   (foo 'yeah '(buddy
  cpu time: 2601 real time: 2599 gc time: 7

With the second:

  test> (time
 (for ([i 100])
   (foo 'yeah '(buddy
  cpu time: 184 real time: 184 gc time: 13

Wow, what the heck?  That's about a 10x difference.  What?!?!?
Why would #:guard be so damn slow in comparison?  You'd think they'd be
doing the same thing.

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?

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


Re: [racket-users] Racket GUI: text aligned to the left of other text

2020-08-12 Thread Christopher Lemmer Webber
That's a very interesting idea... I might give that a try!

Simon Schlee writes:

> Another approach might be to use multiple editor-snip% 
> https://docs.racket-lang.org/gui/editor-snip_.html
> within a pasteboard% https://docs.racket-lang.org/gui/pasteboard_.html
>
> Or possibly together with other snip instances, I currently don't have the 
> time to experiment with it
> and no experience with pasteboards, so I am not sure whether that would 
> work well and I am just dropping the idea ;)

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


Re: [racket-users] Racket GUI: text aligned to the left of other text

2020-08-11 Thread Christopher Lemmer Webber
Thanks!  Yes I was looking at a route like that at first but I found
that there wasn't really a way to do fancier markup like links, etc
using just message% (unless I'm missing something...!)

Hence my abuse of an editor that's mostly-locked (idea borrowed from the
racket web browser code) ;)


Justin Zamora writes:

> Another, less lightweight way is to use panels for different parts of
> the chat windows. I put together a sample at
> https://gist.github.com/zamora/1cfc6480f7703735dffa3169facfbf10
>
> On Mon, Aug 10, 2020 at 3:32 PM Christopher Lemmer Webber
>  wrote:
>>
>> Hello,
>>
>> I'm building a little chat application with Racket.  Overall Racket's
>> GUI tools are quite comfortable, and I'm just using Rakcet's text editor
>> stuff to build the chat.  But a fairly standard thing to do with chat
>> applications is to have text like:
>>
>> (Beware, fixed width ascii art ahead)
>>
>>  ..
>>  | FooChat Deluxe  [X]|
>>  ||
>>  | File  Blah |
>>  ||
>>  |  | It's snowing outside!! | alice   |
>>  || In August  | bob |
>>  |  | Nevermind, the snow is a representation of | carol   |
>>  | | collective anxiety about the world | |
>>  || Oh okay it is snowing then | |
>>  ||
>>  | [Better go get some snow shoes then___] [Send] |
>>  ''
>>
>> The core idea there being that usernames left-align to the text.
>>
>> I'm not sure what's the nicest way to do this, though I've taken a guess
>> that maybe the "Show/Hide Line Numbers" in DrRacket is the best example.
>> I'd be happy to look at that but I can't really find it in the drracket
>> repository and am not sure where it would be?
>>
>> (I guess one other complication is that if you copy-pasta text it would
>> be great to still be able to copy paste the names too, but I can think
>> of some kludgery that might make that possible.)
>>
>>  - 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/87lfime1pm.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/87sgcsbryr.fsf%40dustycloud.org.


Re: [racket-users] Re: Racket GUI: text aligned to the left of other text

2020-08-11 Thread Christopher Lemmer Webber
Curious... thank you, I was trying to figure out what set-tabs meant. ;)

Alex Harsanyi writes:

> The simplest thing is to just use tabs.   A line of text would be 
> "\tYour Message here" and an overflowing line would be "\tOverflowing 
> message".  Yes, this will work for variable width fonts.
>
> The `text%` class  has a `set-tabs` method which allows setting the tab 
> stops in drawing units on the canvas, so you can override `on-display-size` 
> to set the tab width to be a percentage of the display, or you can leave it 
> as a fixed width.
>
> Alex.
>
> On Tuesday, August 11, 2020 at 3:32:41 AM UTC+8 cwebber wrote:
>
>> Hello, 
>>
>> I'm building a little chat application with Racket. Overall Racket's 
>> GUI tools are quite comfortable, and I'm just using Rakcet's text editor 
>> stuff to build the chat. But a fairly standard thing to do with chat 
>> applications is to have text like: 
>>
>> (Beware, fixed width ascii art ahead) 
>>
>> .. 
>> | FooChat Deluxe [X]| 
>> || 
>> | File Blah | 
>> || 
>> |  | It's snowing outside!! | alice | 
>> |  | In August | bob | 
>> |  | Nevermind, the snow is a representation of | carol | 
>> | | collective anxiety about the world | | 
>> |  | Oh okay it is snowing then | | 
>> || 
>> | [Better go get some snow shoes then___] [Send] | 
>> '' 
>>
>> The core idea there being that usernames left-align to the text. 
>>
>> I'm not sure what's the nicest way to do this, though I've taken a guess 
>> that maybe the "Show/Hide Line Numbers" in DrRacket is the best example. 
>> I'd be happy to look at that but I can't really find it in the drracket 
>> repository and am not sure where it would be? 
>>
>> (I guess one other complication is that if you copy-pasta text it would 
>> be great to still be able to copy paste the names too, but I can think 
>> of some kludgery that might make that possible.) 
>>
>> - 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/87wo24bs4l.fsf%40dustycloud.org.


Re: [racket-users] Racket GUI: text aligned to the left of other text

2020-08-11 Thread Christopher Lemmer Webber
Ah great, thank you Robby!  I'll give both options a try. :)

Robby Findler writes:

> That code is in the framework:
> https://github.com/racket/gui/blob/master/gui-lib/framework/private/text-line-numbers.rkt
>
> You might also consider having two text%s, one with the names and one with
> the rest. They would scroll independently in that case, but you can hide
> the scrollbars on one and override various callbacks to keep them scrolled
> to the same place.
>
> Robby
>
>
> On Mon, Aug 10, 2020 at 2:32 PM Christopher Lemmer Webber <
> cweb...@dustycloud.org> wrote:
>
>> Hello,
>>
>> I'm building a little chat application with Racket.  Overall Racket's
>> GUI tools are quite comfortable, and I'm just using Rakcet's text editor
>> stuff to build the chat.  But a fairly standard thing to do with chat
>> applications is to have text like:
>>
>> (Beware, fixed width ascii art ahead)
>>
>>  ..
>>  | FooChat Deluxe  [X]|
>>  ||
>>  | File  Blah |
>>  ||
>>  |  | It's snowing outside!! | alice   |
>>  || In August  | bob |
>>  |  | Nevermind, the snow is a representation of | carol   |
>>  | | collective anxiety about the world | |
>>  || Oh okay it is snowing then | |
>>  ||
>>  | [Better go get some snow shoes then___] [Send] |
>>  ''
>>
>> The core idea there being that usernames left-align to the text.
>>
>> I'm not sure what's the nicest way to do this, though I've taken a guess
>> that maybe the "Show/Hide Line Numbers" in DrRacket is the best example.
>> I'd be happy to look at that but I can't really find it in the drracket
>> repository and am not sure where it would be?
>>
>> (I guess one other complication is that if you copy-pasta text it would
>> be great to still be able to copy paste the names too, but I can think
>> of some kludgery that might make that possible.)
>>
>>  - 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/87lfime1pm.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/87zh70bs5v.fsf%40dustycloud.org.


[racket-users] Racket GUI: text aligned to the left of other text

2020-08-10 Thread Christopher Lemmer Webber
Hello,

I'm building a little chat application with Racket.  Overall Racket's
GUI tools are quite comfortable, and I'm just using Rakcet's text editor
stuff to build the chat.  But a fairly standard thing to do with chat
applications is to have text like:

(Beware, fixed width ascii art ahead)

 ..
 | FooChat Deluxe  [X]|
 ||
 | File  Blah |
 ||
 |  | It's snowing outside!! | alice   |
 || In August  | bob |
 |  | Nevermind, the snow is a representation of | carol   |
 | | collective anxiety about the world | |
 || Oh okay it is snowing then | |
 ||
 | [Better go get some snow shoes then___] [Send] |
 ''

The core idea there being that usernames left-align to the text.

I'm not sure what's the nicest way to do this, though I've taken a guess
that maybe the "Show/Hide Line Numbers" in DrRacket is the best example.
I'd be happy to look at that but I can't really find it in the drracket
repository and am not sure where it would be?

(I guess one other complication is that if you copy-pasta text it would
be great to still be able to copy paste the names too, but I can think
of some kludgery that might make that possible.)

 - 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/87lfime1pm.fsf%40dustycloud.org.


[racket-users] Sending a file descriptor along a socket?

2020-07-21 Thread Christopher Lemmer Webber
It looks like ffi/unsafe/port provides ways to read a file desciptor
from a port that is capable of receiving them, and there are tools
to transform that file descriptor into a port or the reverse, but
is there a way for me to *write* a file descriptor to a port
(ie, the equivalent to the sendmsg posix system call)?
(It might be right in front of my nose and that I'm missing it...)

Thanks!
 - 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/87k0yw214s.fsf%40dustycloud.org.


[racket-users] Re: Some stuff about "case".

2020-06-01 Thread Christopher Lemmer Webber
Except maybe for one thing: I wonder if the version of case defined here
is written in such a way that is smart in that it never has to make said
hash table / alist more than once, at compile time.  I'm guessing so?

Christopher Lemmer Webber writes:

> As I started typing this email and looking into the definition of case,
> I realized my assumptions are wrong.
>
> What I needed: something like case which dispatches on symbols, except
> not auto-quoting the arguments... I needed to evaluate them from the
> lexical environment.  So:
>
>   (let ([x 'foo])
> (caseish 'foo
>   [(x) 'got-foo]
>   [('x) 'got-quote-x]))  ; => 'got-foo
>
> I figured: case is fast, and I'm pretty sure semi-magical... my
> intuitive sense was that it did some smart things on a compiler level
> that would probably be anything I'd hand-code (which would either use an
> alist or an immutable hashtable).  So I started writing up an email
> asking if such a thing worked... then I remembered, this is a ~lisp,
> jumping straight to definition is part of the scene... so I did that.
>
> I... was wrong!  From the case macro:
>
> ;; Symbol and "other" dispatch is either sequential or
> ;; hash-table-based, depending on how many constants we
> ;; have. Assume that `alist' does not map anything to `#f'.
> (define (dispatch-hashable tmp-stx alist make-hashX else-exp)
>   (if (< (length alist) *hash-threshold*)
>   #`(case/sequential #,tmp-stx 
>  #,@(map (λ (x)
>#`[(#,(car x)) #,(cdr x)])
>  alist)
>  [else #,else-exp])
>   (let ([tbl (make-hashX alist)])
> (if (literal-expression? else-exp)
> #`(hash-ref #,tbl #,tmp-stx (lambda () #,else-exp))
> #`(or (hash-ref #,tbl #,tmp-stx (lambda () #f))
>   #,else-exp)
>
> Am I reading that right?  Here I was assuming writing something like
> case was for cool kids and I'd never pull such a thing off right.
>
> But... now it looks like, oh, it's actually just using an alist or an
> immutable hashtable... same as I would.
>
> So I almost trashed this email, but thought I'd send it anyway because
> a) either maybe it's interesting to someone or b) actually maybe I'm
> misreading and case really is smarter / more performant and I'm just
> missing it...!
>
>  - 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/87h7vuvchp.fsf%40dustycloud.org.


[racket-users] Some stuff about "case".

2020-06-01 Thread Christopher Lemmer Webber
As I started typing this email and looking into the definition of case,
I realized my assumptions are wrong.

What I needed: something like case which dispatches on symbols, except
not auto-quoting the arguments... I needed to evaluate them from the
lexical environment.  So:

  (let ([x 'foo])
(caseish 'foo
  [(x) 'got-foo]
  [('x) 'got-quote-x]))  ; => 'got-foo

I figured: case is fast, and I'm pretty sure semi-magical... my
intuitive sense was that it did some smart things on a compiler level
that would probably be anything I'd hand-code (which would either use an
alist or an immutable hashtable).  So I started writing up an email
asking if such a thing worked... then I remembered, this is a ~lisp,
jumping straight to definition is part of the scene... so I did that.
   
I... was wrong!  From the case macro:

;; Symbol and "other" dispatch is either sequential or
;; hash-table-based, depending on how many constants we
;; have. Assume that `alist' does not map anything to `#f'.
(define (dispatch-hashable tmp-stx alist make-hashX else-exp)
  (if (< (length alist) *hash-threshold*)
  #`(case/sequential #,tmp-stx 
 #,@(map (λ (x)
   #`[(#,(car x)) #,(cdr x)])
 alist)
 [else #,else-exp])
  (let ([tbl (make-hashX alist)])
(if (literal-expression? else-exp)
#`(hash-ref #,tbl #,tmp-stx (lambda () #,else-exp))
#`(or (hash-ref #,tbl #,tmp-stx (lambda () #f))
  #,else-exp)

Am I reading that right?  Here I was assuming writing something like
case was for cool kids and I'd never pull such a thing off right.

But... now it looks like, oh, it's actually just using an alist or an
immutable hashtable... same as I would.

So I almost trashed this email, but thought I'd send it anyway because
a) either maybe it's interesting to someone or b) actually maybe I'm
misreading and case really is smarter / more performant and I'm just
missing it...!

 - 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/87imgavcqj.fsf%40dustycloud.org.


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

2020-05-01 Thread Christopher Lemmer Webber
Sorawee Porncharoenwase writes:

>>
>> I hate being at the mercy of whatever editor I'm stuck using.
>
>
> I agree with this in principle, but in practice, it's really a matter of
> what mainstream editors support. Editors in the past don't universally
> support automatic indentation, and I could imagine a criticism like
> "Indentation sucks, because I hate being at the mercy of whatever editor
> I'm stuck using." But now, automatic indentation is universal, and the
> criticism goes away.

You don't even need to imagine it... when Python was taking off, one of
the biggest arguments was that it forced people to learn to do
reasonable indentation.  Doesn't seem like as much of a good argument
now as I thought it was then, and that's partly because most code is
indented fine these days due to, as you say, good IDE support.

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


Re: [racket-users] Scribble citations for art history dissertation (AJA style)

2020-03-19 Thread Christopher Lemmer Webber
Philip McGrath writes:

> For a general solution, I'd take a look at the Citation Style Language (
> https://citationstyles.org/), which is an XML language for defining how to
> render citations and bibliographies. A major advantage is that it has libre
> style definitions for a dizzying variety of house styles, including AJA (
> https://github.com/citation-style-language/styles/blob/master/american-journal-of-archaeology.csl),
> many of which seem to be maintained by the relevant publishers. It also
> integrates with Zotero and its competitors, as well as many other tools.

I might also want to explain what we did about moving from Zotero, where
Morgan originally managed her citations, over to a more
Racket/Scribble-centric approach.  This was motivated by Zotero breaking
in some mysterious way between Debian releases and us shrugging our
shoulders and saying "ok, let's just define this in Racket-land".

 - I wrote some code that walked through the Zotero XML export to write
   out some Racket code that represented the citations instead.  It's
   pretty gnarly.

 - The outputted citations look like:

 (define-bibitem Piranomonte2002
  (ref-type "Book")
  (contributors
   (authors
(author "Piranomonte, Marina.")))
  (titles (title "Il santuario della musica e il bosco sacro di Anna 
Perenna"))
  (dates (year "2002") (pub-dates (date "2002")))
  (pub-location "Milano")
  (publisher "Electa")
  (isbn "88-370-2126-7 978-88-370-2126-9")
  (remote-database-name "http://worldcat.org;)
  (language "Italian"))

 (define-bibitem Pensabene-et-al2001
  (ref-type "Book")
  (contributors
   (authors
(author "Pensabene, Patrizio.")
(author "Falzone, Stella.")
(author "Angelelli, Claudia.")))
  (titles
   (title
"Scavi del Palatino I : l'area sud-occidentale del Palatino tra l'età 
protostorica e il IV secolo a.C., scavi e materiali della struttura ipogea 
sotto la cella del Tempio della Vittoria"))
  (dates (year "2001") (pub-dates (date "2001")))
  (pub-location "Roma")
  (publisher "\"L'Erma\" di Bretschneider")
  (isbn "88-8265-119-3 978-88-8265-119-0")
  (remote-database-name "http://worldcat.org;)
  (language "Italian"))

   So basically we converted the entire Zotero file over like this, and
   Morgan then started maintaining this Racket file instead for her
   Bibliography instead.

 - The above "citations" include a bunch of fields that don't always
   exist in Scribble's system (eg "language" or "isbn" above).  These
   are actually then stored in an sxml-like alist for now (for
   historical intermediate purposes of converting from the Zotero stuff
   to this) but a different structure would be better.

 - I then have utilities like "record-sxml->bib-entry" that convert
   these sxml'ish structures over to a bib entry... it's a lossy
   conversion, but this allows Morgan to maintain fields she needs that
   aren't currently handled by Scribble's bibliography tools.

It's a mess, but it does work and did provide us a path from Zotero ->
maintaining stuff directly in Racket.  Of course the main problems right
now are that converting to bib-entry is lossy / doesn't render to the
right format, but the fact that we still have the data before that
conversion means we can just swap out that code once we have something
better.

I'm posing this not as "this is the right way to do it" but as an
opening for a conversation... especially in that right now, the auto-bib
struct makes some very specific assumptions about what fields are
available:

  (define-struct auto-bib (author date title location url note is-book? key 
specific))

The right solution is to provide something more open-ended / extensible
to the needs of the particular domain the user is coming from.

This is what makes me unsure about how to convert scriblib's existing
code... it's making a lot of assumptions.  How to un-assume?  I'm not
sure yet though.

Thoughts welcome, of course.

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


Re: [racket-users] Scribble citations for art history dissertation (AJA style)

2020-03-19 Thread Christopher Lemmer Webber
Philip McGrath writes:

> On Thu, Mar 19, 2020 at 12:40 PM Matthew Flatt  wrote:
>
>> At Thu, 19 Mar 2020 12:38:39 -0400, Christopher Lemmer Webber wrote:
>> > I will spend the rest of the day looking at what scriblib's bibliography
>> > stuff does in further detail and think about how to accomplish what we
>> > need.  It could be that what I do is build a quicker proof of concept
>> > that accomplish *Morgan's* needs so we can get her dissertation out the
>> > door, and then upon examining that, we can think about how to generalize
>> > it for something more universal.  How does that sound?
>>
>> That sounds like a good plan.
>>
>
> For a general solution, I'd take a look at the Citation Style Language (
> https://citationstyles.org/), which is an XML language for defining how to

Oh wow, this is cool.

> render citations and bibliographies. A major advantage is that it has libre
> style definitions for a dizzying variety of house styles, including AJA (
> https://github.com/citation-style-language/styles/blob/master/american-journal-of-archaeology.csl),
> many of which seem to be maintained by the relevant publishers. It also
> integrates with Zotero and its competitors, as well as many other tools.
>
> I'm quite interested in working on this and some related issues as well,
> though properly digging into it keeps getting pushed aside by other things.

Oh that's great!

> But I agree that a general solution might be best deferred until after the
> dissertation—best wishes, Morgan!

:)

> -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/878sjwb7ql.fsf%40dustycloud.org.


Re: [racket-users] Scribble citations for art history dissertation (AJA style)

2020-03-19 Thread Christopher Lemmer Webber
Matthew Flatt writes:

> At Thu, 19 Mar 2020 11:46:44 -0400, Christopher Lemmer Webber wrote:
>> What I thought was the more "Racket'y way" would be to store it as
>> abstract data that then could be rendered to the appropriate style
>> (that's what BibTeX and everything else does).
>
> Well, perhaps the Rackety way is to store it as abstract *code*. That
> abstraction is what the `make-bib`, etc., functions are meant to be.

I'm not sure what "store it as abstract code" means in this case; I
could interpret that a number of ways...

But maybe you mean that the interface, at least, is mostly abstract.  I
agree with that.

> But you're absolutely right that the language of `make-bib` should be
> more extensible. Currently, `location` is clearest the extension point,
> but there are still just a bunch of predefined locations, instead of a
> protocol for adding new ones. And `location` by itself is probably not
> enough extensibility.

Yes I think so.

> And you're right that the way that language renders to references and a
> bibliography needs to be configurable and extensible. You can pick
> among a few styles in `define-cite`, but that mostly just controls the
> way references render, not the bibliography.
>
> You could build something new and better --- or maybe just different
> and more applicable to your case. But if you're interested in improving
> and generalizing `scribble/scriblib`, I'd be happy to work with you on
> it.

Thank you for your clear response, as well as your offer to collaborate
on it.  

I will spend the rest of the day looking at what scriblib's bibliography
stuff does in further detail and think about how to accomplish what we
need.  It could be that what I do is build a quicker proof of concept
that accomplish *Morgan's* needs so we can get her dissertation out the
door, and then upon examining that, we can think about how to generalize
it for something more universal.  How does that sound?

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


[racket-users] Scribble citations for art history dissertation (AJA style)

2020-03-19 Thread Christopher Lemmer Webber
Hello,

As some of you know (since we talked about it in a racketcon talk a
couple of year ago), my spouse Morgan (cc'ed) is writing her art history
dissertation in Scribble.  She's getting close to finishing it (yay!)
and we've been very happy with Scribble for this use in general, except
for one thing that we've been procrastinating on... the apparent
inflexibility of Scribble's bibliography support.

As far as I can tell, both scriblib bibliographies and the
scribble/manual bibliography toolings both just assume "welp, here's the
citation style we support, and we're going to hardcode that":

  (define (bib-entry #:key key
 #:title title
 #:is-book? [is-book? #f]
 #:author [author #f]
 #:location [location #f]
 #:date [date #f]
 #:url [url #f])
(make-a-bib-entry
 key
 (make-element
  "bibentry"
  (append
   (if author `(,@(decode-content (list author)) ", ") null)
   (if is-book? null '(ldquo))
   (if is-book?
 (list (italic title))
 (decode-content (list title)))
   (if location '(",") '("."))
   (if is-book? null '(rdquo))
   (if location
 `(" " ,@(decode-content (list location)) ,(if date "," "."))
 null)
   (if date `(" " ,@(decode-content (list date)) ".") null)
   (if url `(" " ,(link url (tt url))) null)

I was... really surprised when I saw this.  What I thought was the more
"Racket'y way" would be to store it as abstract data that then could be
rendered to the appropriate style (that's what BibTeX and everything
else does).  So it seems like:

  1) This is very inflexibly tied to a specific citation style... the
 format we need is preferably AJA, but Chicago Style or MLA also
 are acceptable.
   https://www.ajaonline.org/submissions/references
  2) What about new fields?  There are some citations we're pulled in
 from Morgan's Zotero database that have important fields that
 don't appear to be in the bib-entry.

I wonder if I'm missing something?  Maybe the bibtex system is what I
should look at, but I'll admit that I really don't understand how it
works based on its documentation.

I suppose if worst comes to worst I can roll my own thing or kludgily
fork one from scribble's modules but I'd rather not if possible.

Thoughts welcome.  Thank you!

 - 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/87d098bb57.fsf%40dustycloud.org.


Re: [racket-users] Showing off Goblins' time-traveling-debugging support in Terminal Phase

2020-01-27 Thread Christopher Lemmer Webber
And then I just noticed you had sent such an email immediately after ;)

Christopher Lemmer Webber writes:

> I'm definitely interested in reactive patterns, so please give me a
> heads up with whatever you have whenever :)
>
> Sage Gerard writes:
>
>> Nice, I'll actually be competing with a flavor of MaiaVictor's library
>> for reactive models. Time travel is a great add!
>>
>>  Original Message 
>> On Jan 26, 2020, 3:07 PM, Christopher Lemmer Webber wrote:
>>
>>> Not the most interesting part of Spritely Goblins (that is in the
>>> async/distributed stuff, to-be-demo'ed), but something I wrote about
>>> recently and maybe I should link here too:
>>>
>>> https://dustycloud.org/blog/goblins-time-travel-micropreview/
>>>
>>> Of course, as functional programmers, time-travel isn't that novel.
>>> What's more interesting is how to make it comfortable* when we have many
>>> independently acting objects.
>>>
>>> More to come later.
>>>
>>> - Chris
>>>
>>> * Without introducing the m-word** (which isn't very comfortable for
>>> many)
>>>
>>> ** monad***
>>>
>>> *** one could argue that Goblins kind of can be perceived of as an
>>> implicit monad but the important thing is that this framing is not
>>> exposed to users
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to racket-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/racket-users/87o8uq2d7s.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/87k15c3k1b.fsf%40dustycloud.org.


Re: [racket-users] Showing off Goblins' time-traveling-debugging support in Terminal Phase

2020-01-27 Thread Christopher Lemmer Webber
I'm definitely interested in reactive patterns, so please give me a
heads up with whatever you have whenever :)

Sage Gerard writes:

> Nice, I'll actually be competing with a flavor of MaiaVictor's library
> for reactive models. Time travel is a great add!
>
>  Original Message 
> On Jan 26, 2020, 3:07 PM, Christopher Lemmer Webber wrote:
>
>> Not the most interesting part of Spritely Goblins (that is in the
>> async/distributed stuff, to-be-demo'ed), but something I wrote about
>> recently and maybe I should link here too:
>>
>> https://dustycloud.org/blog/goblins-time-travel-micropreview/
>>
>> Of course, as functional programmers, time-travel isn't that novel.
>> What's more interesting is how to make it comfortable* when we have many
>> independently acting objects.
>>
>> More to come later.
>>
>> - Chris
>>
>> * Without introducing the m-word** (which isn't very comfortable for
>> many)
>>
>> ** monad***
>>
>> *** one could argue that Goblins kind of can be perceived of as an
>> implicit monad but the important thing is that this framing is not
>> exposed to users
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/87o8uq2d7s.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/87lfps3k2b.fsf%40dustycloud.org.


[racket-users] Showing off Goblins' time-traveling-debugging support in Terminal Phase

2020-01-26 Thread Christopher Lemmer Webber
Not the most interesting part of Spritely Goblins (that is in the
async/distributed stuff, to-be-demo'ed), but something I wrote about
recently and maybe I should link here too:

  https://dustycloud.org/blog/goblins-time-travel-micropreview/

Of course, as functional programmers, time-travel isn't that novel.
What's more interesting is how to make it comfortable* when we have many
independently acting objects.

More to come later.

 - Chris

* Without introducing the m-word** (which isn't very comfortable for
  many)

** monad***

*** one could argue that Goblins kind of can be perceived of as an
implicit monad but the important thing is that this framing is not
exposed to users

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


[racket-users] Terminal Phase hits 1.0

2020-01-19 Thread Christopher Lemmer Webber
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.


Re: [racket-users] telnet postcard.sfconservancy.org 2333

2019-12-21 Thread Christopher Lemmer Webber
Thanks, I'm glad people like it :)

I figured it was extra relevant here since not only is the program
written in Racket, Racket is a Conservancy member project! :)

Happy holidaze,
 - Chris

Caleb Allen writes:

> Very cool! What a creative greetings card :)
>
> Happy holidays!
>
> Sage Gerard  writes:
>
>> Super cool, and a catchy way to send it out!
>>
>>  Original Message ----
>> On Dec 19, 2019, 11:56 AM, Christopher Lemmer Webber wrote:
>>
>>> If you enter the subject of this email into a terminal, you'll see a
>>> cool, live Racket "greetings card" for my friends at Software Freedom
>>> Conservancy's fundraiser:
>>>
>>> https://sfconservancy.org/supporter/
>>>
>>> The animation is itself a Racket program! You can run it yourself, on
>>> your own machine!
>>>
>>> https://gitlab.com/dustyweb/conservancy-postcard
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to racket-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/racket-users/878sn8z235.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/lOFGRGjOP1X06l0sv-FmXvPcLtCKaDpYeMILy9QiGuGGefoCSadWV0fyAQGMJTH7lTk_4ow5q5YH-JbYt5pA6lB4HTXsG9tPzMfJKqYvzVs%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/87tv5tvlpo.fsf%40dustycloud.org.


[racket-users] telnet postcard.sfconservancy.org 2333

2019-12-19 Thread Christopher Lemmer Webber
If you enter the subject of this email into a terminal, you'll see a
cool, live Racket "greetings card" for my friends at Software Freedom
Conservancy's fundraiser:

  https://sfconservancy.org/supporter/

The animation is itself a Racket program!  You can run it yourself, on
your own machine!

  https://gitlab.com/dustyweb/conservancy-postcard

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


Re: [racket-users] What’s everyone working on this week?

2019-12-10 Thread Christopher Lemmer Webber
Stephen De Gabrielle writes:

> New week, new Racket! What are you folks up to? Answer here or
>
> * https://racket.slack.com/ (Sign up at https://racket-slack.herokuapp.com/
> )
> * #racket IRC on freenode.net https://botbot.me/freenode/racket/
> * Tweet @racketlang on Twitter
> * Racket discord
> https://discord.gg/6Zq8sH5
>
> Don’t forget to
> * sign up, or contribute, to Racket News https://racket-news.com/
> * submit your links to Racket Stories https://racket-stories.com/

This week through the holidaze are a bit busy for me.

Nonetheless I am trying to understand CapTP, the capability transport
protocol (for a mutually suspicious networked programming environment):

  http://erights.org/elib/distrib/captp/index.html

I am trying to port its ideas to Spritely Goblins.  I expect the work
will be useful enough by the end of January but we'll see.

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


Re: [racket-users] What’s everyone working on this week (46/2019)?

2019-11-11 Thread Christopher Lemmer Webber
Hendrik Boom writes:

> On Mon, Nov 11, 2019 at 05:09:47AM -0800, Stephen De Gabrielle wrote:
>> New week, new Racket! What are you folks up to? Answer here or over at 
>> /r/racket  !
>
> Trying to figure out pict3d's use of opengl.
> There seems to be a lot of useful code there for openGL buffer
> management, which I'm still finding incomprehensible.
>
> I want texture mapping.  At least texture mapping onto a flat 
> 2D rectangle in 3D space..
>
> Maybe all I'll accomplish this month is a bit of Pict3D internal
> documentation.  Maybe that'll count as a game writing tool for the 
> contest, maybe not.  But I need it for the world-generation I want.
>
> Maybe I'll not even accomplish that.
>
> -- hendrik

Really happy to hear about more eyes on Pict3d.  Really interesting
project that I'd like to see succeed.

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


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

2019-11-11 Thread Christopher Lemmer Webber
Jay McCarthy writes:

> I feel like I might not understand what you want, but it feels like
> you just want to use `make-module-evaluator` from `racket/sandbox`:
>
> ```
> #lang racket/base
> (require racket/sandbox)
>
> (define (read-script s)
>   (((make-module-evaluator s) 'script) 5))
>
> (module+ test
>   (read-script
>"#lang racket/base
> (provide script)
> (define (script x) (add1 x))")
>   (read-script
>"#lang typed/racket/base
> (provide script)
> (: script (-> Number Number))
> (define (script x) (add1 x))"))
> ```
>
> You may want to set the `#:language` argument to control the language.
> And you will also want to set `sandbox-namespace-specs` to link up
> your internal data-structure providing modules so you can communicate.
> But other than those two things, it should be pretty straightforward.
> What is different about this than what you are trying to do?
>
> Jay

I think you're right, the sandbox code is fine enough to use.  I was
trying to remember why I hadn't been exploring this method, but quickly
rediscovered it:

racket-sandbox.rkt> (define evalu8
  (make-evaluator 'racket/base))

; current-load-relative-directory: `exists' access denied for 
/home/cwebber/sandbox/
; Context:
;  
/gnu/store/8iy4dl15yl016vgkd040njzf9351hh7j-racket-7.3/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:716:0
 evaluate-program
;  
/gnu/store/8iy4dl15yl016vgkd040njzf9351hh7j-racket-7.3/share/racket/pkgs/sandbox-lib/racket/sandbox.rkt:853:2
 user-process

Looks like this is because I'm running Racket on Guix; the other source
I can find of this coming up is
  
https://users.racket-lang.narkive.com/A6CLMoNo/question-about-sandbox-rktl-failing-its-unit-test
and it would indeed make sense if it *was* related to symbolic links,
since Guix makes heavy use of symlinks for its functional package
management.

Looks like the problem is security guards really:

racket-sandbox.rkt> (parameterize ([sandbox-security-guard  
(current-security-guard)])
  (define evalu8
(make-evaluator 'racket/base))
  (evalu8 '(+ 1 2 3)))
6

Anyway that's an unrelated bug, but probably one I should file.
Nonetheless I think even in the interim I have a way to move forward,
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/87k186gz2v.fsf%40dustycloud.org.


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

2019-11-10 Thread Christopher Lemmer Webber
Hey Eric!  Thanks, I'll try to soak in this a bit tomorrow. :)

Eric Griffis writes:

> This works:
>
> 1. mkdir foo; cd foo; raco pkg install
>
> 2. create foo/main.rkt:
>
> ```
> #lang racket/base
>
> (module reader racket/base
>   (require racket/port)
>   (provide (rename-out [foo-read read]
>[foo-read-syntax read-syntax]))
>   (define (foo-read port)
> `(module ,(gensym 'foo) racket/base
>(provide the-foo)
>(define the-foo (let () ,@(port->list read port)
>   (define (foo-read-syntax path port)
> (datum->syntax #f (foo-read port
> ```
>
> 3. In the REPL or another file, we can simulate the game's interaction with
> the player's connection through an input port:
>
> ```
> (define foo-source #< #lang foo
>
> (define bar 1)
>
> (+ bar 2)
> END
>   )
>
> (define player-input (open-input-string foo-source))
>
> (define source
>   (let ([define-mod (parameterize ([read-accept-reader #t])
>   (read player-input))])
> (define mod-name (cadr define-mod))
> `(begin ,define-mod (let () (local-require (quote ,mod-name))
> the-foo
>
> (println `(GOT ,(eval source (module->namespace 'racket/base
> ```
>
> The value-extraction code is kind of messy, so you might want to stow it in
> a `port-read-handler`, like this:
>
> ```
> (port-read-handler
>  player-input
>  (let ([default-handler (port-read-handler player-input)])
>(case-lambda
>  [(in) (define original-handler (port-read-handler in))
>(define define-mod
>  (parameterize ([read-accept-reader #t])
>(port-read-handler in default-handler)
>(begin0 (read in) (port-read-handler in original-handler
>(define mod-name `(quote ,(cadr define-mod)))
>(eval `(begin ,define-mod (let () (local-require ,mod-name)
> the-foo))
>      (module->namespace 'racket/base))]
>  [(in source) (datum->syntax #f (read in))])))
>
> (println `(GOT ,(read player-input)))
> ```
>
> Eric
>
>
>
> On Sun, Nov 10, 2019 at 12:19 PM Christopher Lemmer Webber <
> cweb...@dustycloud.org> wrote:
>
>> Hi Eric!  Thanks very much for the reply.
>>
>> Eric Griffis writes:
>>
>> >> It appears there must be; when I look at `build-program` in
>> >> sandbox.rkt it also looks like it's wrapping things in a module
>> >> structure... but I don't see how it then exports from that module or
>> >> how the code evaluating it imports its export.  Or does it actually
>> >> do so via an effect?  I see there are some channels involved
>> >> (input-ch / result-ch) so maybe it's passing back the result through
>> >> there, but I am having trouble figuring out how.
>> >
>> > Apologies for stating the obvious, but to get a value out of a module, we
>> > `provide` it:
>> >
>> > In foo/main.rkt:
>> >
>> > ```
>> > (define-syntax-rule (foo-module-begin form ... final-form)
>> >   (#%module-begin (provide the-foo) form ... (define the-foo
>> final-form)))
>> > ```
>> >
>> > Then we can produce and consume foo-based modules like this:
>> >
>> > ```
>> > (module bar-mod foo (define bar 1) (+ bar 2))
>> >
>> > (define my-bar (let () (local-require 'bar-mod) the-foo))
>> > ```
>>
>> This approach works, but I'm not sure it works for my use case, because
>> `module` is appearing at compile-time.
>>
>> Let me try to lay out the use case, and maybe it helps.
>>
>>  - We are in a MUD, or some other interactive game.  The game is running
>>live.  Some players have capabilities to provide new code for game
>>characters in the system or other interesting features.
>>
>>  - The users are able to write scripts that return things... however,
>>they are providing the scripts as the game is running.  (This will be
>>ocap safe, but I'll explains how that works in a separate
>>email... just trust me that I believe that if I can run it with in a
>>special restricted language and return a value from that module which
>>is loaded *at runtime* somehow, I can pull off this goal safely.)  As
>>such, we cannot at the time that we are starting the program actually
>>know or load all of the modules, because the users are providing some
>>of them live.
>>
>>  - As such we need to be able to do something along the lines of what
>>you just did, but we have to do it at runtim

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

2019-11-10 Thread Christopher Lemmer Webber
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.


[racket-users] Understanding sandbox.rkt

2019-11-10 Thread Christopher Lemmer Webber
> Jay McCarthy writes:
>> Modules don't evaluate to values. They have effects and they have
>> exported symbols. If you want to observe the evaluation of your
>> language's module, you'll have to look at one of those two things.
>> Both are used by existing Racket languages and infrastructure: `raco
>> test` relies on test modules making effects on a global box that
>> counts how many tests ran and failed. `scribble` relies on inspecting
>> an export named `doc`. In either case, I think you want to make
>> `#%module-begin` capture the last expression and expose its value via
>> an effect or an export.

Christopher Lemmer Webber writes:

> Well I gave it a try and couldn't quite figure out how to make it work.
> I tried writing out this file, dungeon/room-ch.rkt:
>

[...]

> It just hangs, so I assume that the module never wrote to that channel.
> I guess it probably wouldn't until it's required, but I have no idea how
> to "require" this dynamically-read-in module to prime it?

Wow, ok.  So I figured, "this must be possible to talk to a module
loaded at runtime, because I see in sandbox.rkt that when the user
specifies a lang to the sandbox that it makes a module":

  (define (use-lang lang) `(module program ,lang . ,body))

So I figured that ok, there must be some way to evaluate a module and
get it to "run", and it must be taking either of the approaches Jay
mentioned.  So I spent about an hour digging around in sandbox.rkt and
taking notes thinking I'd find out where it did that.

Well... I was in for a surprise.  My assumptions appear to be wrong.
As far as I can tell:

 - sandbox.rkt first sets up a fresh namespace to do the evaluation in
   (ok, expected)
 - Then later in evaluate-program:

  (define ns
(syntax-case* program (module) literal-identifier=?
  [(module mod . body)
   (identifier? #'mod)
   (let ([mod #'mod])
 (lambda ()
   (for ([submod-name (in-list submod-names)])
 (eval `(when (module-declared? '(submod (quote ,mod) ,submod-name) 
#f)
  (dynamic-require '(submod (quote ,mod) ,submod-name) 
#f
   (module->namespace `(quote ,(syntax-e mod)]
  [_else #f]))

   sandbox.rkt is then piecing apart the module and taking the module
   path and adding it to the namespace?!  Or at least preparing to,
   since this is wrapped in a lambda to be run later.

 - It actually appears that the program (the whole `(module ...)`
   structure is actually just eval'ed first, and *then* I guess the
   namespace is set up:

(if (and (pair? program) (eq? 'begin (car program)))
  (eval* (cdr program))
  (eval program))
(when ns (set! ns (ns)))

 - At the end of it the current-namespace is set to ns if indeed
   evaluate-program is dealing with a (module ...) thing:

  (when (namespace? ns) (current-namespace ns))

 - Then later on when the user uses the sandboxed evaluator and passes
   in expressions, I guess that namespace is used and evaluation takes
   place in it.

That is NOT what I was expecting.  What I figured when I saw the
`(module program ,lang . ,body) stuff was that the module would be
evaluated on some sort of very generic
module-dynamically-loaded-at-runtime way.  That doesn't quite seem to be
the case.

This was a useful read; I'm still unsure if I'm reading it right
though.  I guess it seems to say "this tooling doesn't quite exist out
of the box, but you can assemble something resembling it on your own"?

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


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

2019-11-10 Thread Christopher Lemmer Webber
Christopher Lemmer Webber writes:

> I guess a question remaining then is: if I'm doing this kind of dynamic
> import of the module, is there a way to require from it (especially if
> it isn't assigned to a "filename" on disk?).  It appears there must be;
> when I look at `build-program` in sandbox.rkt it also looks like it's
> wrapping things in a module structure... but I don't see how it then
> exports from that module or how the code evaluating it imports its
> export.  Or does it actually do so via an effect?  I see there are some
> channels involved (input-ch / result-ch) so maybe it's passing back the
> result through there, but I am having trouble figuring out how.
>
> Having said all that, maybe I can envision a way to make it work:
>
>  - Have a parameter that, when parameterized, sets up the expected
>channel that a module, upon being loaded, is expected to return its
>"result" from.
>  - When evaluating the module, parameterize that channel; read from
>it after evaluating and extract the value.
>
> Does that seem like the right approach?  I guess I will give it a try,
> anyway.

Well I gave it a try and couldn't quite figure out how to make it work.
I tried writing out this file, dungeon/room-ch.rkt:

```
#lang racket/base

(provide current-room-channel)

(define current-room-channel
  (make-parameter #f))
```

Then I tried writing test-read-ch.rkt:

```
#lang racket

(require dungeon/room-ch)

(define test-prog
  "#lang racket/base

(require dungeon/room-ch)

(channel-put (current-room-channel) 'foo)")

(define (try-reading)
  (parameterize ([read-accept-reader #t]
 [current-room-channel (make-channel)])
(eval (call-with-input-string test-prog read))
(channel-get (current-room-channel
```

It just hangs, so I assume that the module never wrote to that channel.
I guess it probably wouldn't until it's required, but I have no idea how
to "require" this dynamically-read-in module to prime 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/87woc7hado.fsf%40dustycloud.org.


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

2019-11-10 Thread Christopher Lemmer Webber
Thanks Jay for the helpful response as usual Jay; I really do appreciate
it.

It sounds like what I want is the case of the export.  I think I can
figure out how to modify the #%module-begin to do that.

I guess a question remaining then is: if I'm doing this kind of dynamic
import of the module, is there a way to require from it (especially if
it isn't assigned to a "filename" on disk?).  It appears there must be;
when I look at `build-program` in sandbox.rkt it also looks like it's
wrapping things in a module structure... but I don't see how it then
exports from that module or how the code evaluating it imports its
export.  Or does it actually do so via an effect?  I see there are some
channels involved (input-ch / result-ch) so maybe it's passing back the
result through there, but I am having trouble figuring out how.

Having said all that, maybe I can envision a way to make it work:

 - Have a parameter that, when parameterized, sets up the expected
   channel that a module, upon being loaded, is expected to return its
   "result" from.
 - When evaluating the module, parameterize that channel; read from
   it after evaluating and extract the value.

Does that seem like the right approach?  I guess I will give it a try,
anyway.

 - Chris

Jay McCarthy writes:

> Modules don't evaluate to values. They have effects and they have
> exported symbols. If you want to observe the evaluation of your
> language's module, you'll have to look at one of those two things.
> Both are used by existing Racket languages and infrastructure: `raco
> test` relies on test modules making effects on a global box that
> counts how many tests ran and failed. `scribble` relies on inspecting
> an export named `doc`. In either case, I think you want to make
> `#%module-begin` capture the last expression and expose its value via
> an effect or an export.
>
> Jay

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


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

2019-11-09 Thread Christopher Lemmer Webber
(Caveat: I know the sandbox evaluator exists.  I'm trying to understand
how to do this without it, to understand the evaluation machinery for
something.)

Let's say I write "#lang foo".  For whatever reason, I have programs
that are coming in from users that are not necessarily being saved
to a file on disk... they may be coming from a GUI, read over the
network, etc etc.  The only important thing is that at the end of the
program, the last expression returns some value, and I want access to
that value.  Simplest example, let's say we have the following program

```
  #lang foo

  (define bar 1)

  (+ bar 2)
```

I'd like to read this in and evaluate it, so presumably I'd want to get
3 returned.

I've tried to figure out how to do this from trivial examples but I'm
not having success.  I can see that I can read in a module:

```
racket-sandbox.rkt> (parameterize ([read-accept-reader #t])
  (call-with-input-string "#lang racket/base
(+ 1 2)"
(lambda (ip)
  (read-syntax 'foo ip
#
```

Cool, ok.

But when I pass this module-wrapped structure to eval, the result is void.

What should I do?  Help appreciated!

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


Re: [racket-users] What's the best way to do these syntax transforms?

2019-11-08 Thread Christopher Lemmer Webber
Jay McCarthy writes:

> On Fri, Nov 8, 2019 at 9:51 AM Christopher Lemmer Webber <
> cweb...@dustycloud.org> wrote:
>
>> I have a need to do two things in a #lang:
>>
>>  - Most importantly, make all strings that appear in the source code
>>immutable
>>
>
> Make #%datum turn literal strings `s` into `(string->immutable-string s)`

Philip has seemed to suggest that maybe this isn't necessary (?)
but it's useful to understand how #%datum helps here

>>  - Second and not as urgent, I'd like to add a "dot" notation, so that
>>(foo.bar 1 2 3) expands into (foo 'bar 1 2 3)
>>
>
> Turn on `read-cdot` and then make the `#%dot` macro put a quote on the RHS
> and have #%app notice a #%dot and unwrap it
>
> Jay

Okay thanks, I'll give that a try!

>> It seems to me that both of these needs are similar.  I can imagine how
>> to do both by thinking of the syntax tree like a list structure and
>> rewrite via recursive descent.  I guess I would re-append the src
>> locations to the new structure.  This seems doable.
>>
>> But is it the best way?  I'm guessing maybe there's a more racket'y way
>> but I'm unsure.
>>

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


Re: [racket-users] What's the best way to do these syntax transforms?

2019-11-08 Thread Christopher Lemmer Webber
Philip McGrath writes:

> On Fri, Nov 8, 2019 at 9:56 AM Jay McCarthy  wrote:
>
>> On Fri, Nov 8, 2019 at 9:51 AM Christopher Lemmer Webber <
>> cweb...@dustycloud.org> wrote:
>>
>>> I have a need to do two things in a #lang:
>>>
>>>  - Most importantly, make all strings that appear in the source code
>>>immutable
>>>
>>
>> Make #%datum turn literal strings `s` into `(string->immutable-string s)`
>>
>
>  But the default `#%datum` (which expands to `quote`) already does this:
>> (immutable? "foo")
> #t
> Or, for another way of thinking about it, strings that go into syntax
> objects are interned. The upshot is that literals are immutable by default:
> a language that wanted mutable literals would have to make special effort
> via `#%datum`.
>
> -Philip

Huh... somehow I had thought that I had heard that Racket has mutable
strings by default.  It cropped up on my TODO list because of that.  I
wonder what gave me that impression?

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


[racket-users] What's the best way to do these syntax transforms?

2019-11-08 Thread Christopher Lemmer Webber
I have a need to do two things in a #lang:

 - Most importantly, make all strings that appear in the source code
   immutable
 - Second and not as urgent, I'd like to add a "dot" notation, so that
   (foo.bar 1 2 3) expands into (foo 'bar 1 2 3)

It seems to me that both of these needs are similar.  I can imagine how
to do both by thinking of the syntax tree like a list structure and
rewrite via recursive descent.  I guess I would re-append the src
locations to the new structure.  This seems doable.

But is it the best way?  I'm guessing maybe there's a more racket'y way
but I'm unsure.

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


[racket-users] Terminal Phase: building a space shooter that runs in your terminal

2019-11-07 Thread Christopher Lemmer Webber
I published a blogpost here:

  https://dustycloud.org/blog/terminal-phase-prototype/

It also talks quite a bit about my experiences with doing gamedev in
Racket, a bit on using Spritely Goblins, etc.

The prototype is finished for the technical stuff I needed to do, but
I've decided that since this work is fairly hard to fund, and games are
fun, that I'd set making it a polished game as a milestone on my Patreon
account.  We aren't far away from it if you're interested in supporting
that kind of thing:

  https://www.patreon.com/cwebber

I should have more to say about Goblins soon.  A lot has happened.  I
need to finish the distributed programming stuff and then publish new
docs.  But I think the design is quite interesting, and for me at least,
writing this game prototype in it was very pleasant.

 - 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/87r22jiwxn.fsf%40dustycloud.org.


Re: [racket-users] Does match against list traverse the whole list?

2019-10-29 Thread Christopher Lemmer Webber
Thanks everyone.  I guess I misread the docs.  Great to hear re:
caching.  Guess I wasn't screwing things up as I momentarily feared. :)

Sam Tobin-Hochstadt writes:

> Here are some quick numbers on the traditional Racket VM:
>
> ```
>> (define v (build-list 1000 values))
>> (time (list? v))
> cpu time: 47 real time: 47 gc time: 0
> #t
>> (time (list? v))
> cpu time: 31 real time: 31 gc time: 0
> #t
>> (time (list? v))
> cpu time: 13 real time: 13 gc time: 0
> #t
>> (time (list? v))
> cpu time: 15 real time: 16 gc time: 0
> #t
>> (time (list? v))
> cpu time: 4 real time: 4 gc time: 0
> #t
>> (time (list? v))
> cpu time: 1 real time: 1 gc time: 0
> #t
>> (time (list? v))
> cpu time: 2 real time: 2 gc time: 0
> #t
>> (time (list? v))
> cpu time: 1 real time: 1 gc time: 0
> #t
>> (time (list? v))
> cpu time: 1 real time: 0 gc time: 0
> #t
>> (time (list? v))
> cpu time: 1 real time: 0 gc time: 0
> #t
>> (time (list? v))
> cpu time: 1 real time: 0 gc time: 0
> #t
>> (define v2 (drop v (/ 1000 2) ))
>> (time (list? v2))
> cpu time: 0 real time: 0 gc time: 0
> #t
> ```
> Here's some RacketCS numbers, which are a little different:
>
> ```
> [samth@huor:~/.../extra-pkgs/typed-racket/typed-racket-test (master)
> plt] racketcs
> Welcome to Racket v7.5.0.4 [cs].
>> (define v (build-list 1000 values))
>> (time (list? v))
> cpu time: 77 real time: 77 gc time: 0
> #t
>> (time (list? v))
> cpu time: 73 real time: 73 gc time: 0
> #t
>> (time (list? v))
> cpu time: 53 real time: 53 gc time: 0
> #t
>> (time (list? v))
> cpu time: 37 real time: 37 gc time: 0
> #t
>> (time (list? v))
> cpu time: 25 real time: 25 gc time: 0
> #t
>> (time (list? v))
> cpu time: 12 real time: 13 gc time: 0
> #t
>> (time (list? v))
> cpu time: 2 real time: 2 gc time: 0
> #t
>> (time (list? v))
> cpu time: 3 real time: 3 gc time: 0
> #t
>> (time (list? v))
> cpu time: 1 real time: 1 gc time: 0
> #t
>> (time (list? v))
> cpu time: 0 real time: 0 gc time: 0
> #t
>> (define v2 (drop v (/ 1000 2) ))
>> (time (list? v2))
> cpu time: 61 real time: 61 gc time: 0
> #t
>> (time (list? v2))
> cpu time: 50 real time: 50 gc time: 0
> #t
>> (time (list? v2))
> cpu time: 15 real time: 15 gc time: 0
> #t
>> (time (list? v2))
> cpu time: 25 real time: 25 gc time: 0
> #t
>> (time (list? v2))
> cpu time: 22 real time: 22 gc time: 0
> #t
>> (time (list? v2))
> cpu time: 3 real time: 3 gc time: 0
> #t
>> (time (list? v2))
> cpu time: 0 real time: 0 gc time: 0
> #t
> ```
>
> If you want to make that match pattern faster, use `cons` or `list-rest`.
>
> Sam
>
> On Tue, Oct 29, 2019 at 2:18 PM Alexis King  wrote:
>>
>> > On Oct 29, 2019, at 12:41, Christopher Lemmer Webber 
>> >  wrote:
>> >
>> > But the documentation says that the `list?` predicate is O(n).
>>
>> I’m not sure where you’re seeing that, but the documentation actually says 
>> just the opposite. Specifically, it says this:
>>
>> > This procedure effectively takes constant time due to internal caching (so 
>> > that any necessary traversals of pairs can in principle count as an extra 
>> > cost of allocating the pairs).
>>
>> In other words, `list?` is amortized constant time.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/4E904F54-3605-4964-AC19-EB6617A5D9F7%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/87k18nxv8c.fsf%40dustycloud.org.


[racket-users] Does match against list traverse the whole list?

2019-10-29 Thread Christopher Lemmer Webber
Imagine the following code:

(let lp ([items '(1 2 3 4 5)])
  (match items
[(list head rest ...)
 (cons (* head 2)
   (lp rest))]))

My gut feeling is "oh, this is just O(n) because it's pulling the top
off the list quite efficient."

But then I realized that:

(match '(1 2 3 4 . 5)
  [(list head rest ...)
   (* head 2)])

throws an exception because it's a dotted list.

But the documentation says that the `list?` predicate is O(n).  I'm
suddenly fearing, have I been writing O(n^2) code this whole time?  Does
match against list actually check the whole list every time?

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


Re: [racket-users] Re: The case, and a proposal, for elegant syntax in #lang racket2

2019-08-21 Thread Christopher Lemmer Webber
Christopher Lemmer Webber writes:

> Gerald Sussman explained Python's success, and the reason for the switch
> from Scheme and SICP to a Python based curriculum, as being because
> Python had for whatever reason libraries that allowed students to be
> able to lego together examples very quickly.  I've made the case that
> Racket is the Python of lisps... even if we aren't continuing to have a
> lispy syntax by default, we should realize that this is a strength we
> don't want to lose.  If there's a syntax gulf between the restricted
> student languages and the "main" language, we'll diminish that value
> we're providing to newcomers.

More on that:

  
https://cemerick.com/2009/03/24/why-mit-now-uses-python-instead-of-scheme-for-its-undergraduate-cs-program/

Though I also saw him explain this in a talk, I forget which one, maybe
it was:

  https://vimeo.com/151465912

... but I don't have time to review again.

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


Re: [racket-users] Re: The case, and a proposal, for elegant syntax in #lang racket2

2019-08-21 Thread Christopher Lemmer Webber
Chris Stephenson writes:

> Parantheses and learners - experience with 14-18 year olds
>
> I have just finished giving a two week intensive course to 14-18 year olds
> at the Mathematics Village near Ephesus in Turkey

Very interesting email all around!

> (a) A change of syntax between the two halves had proved confusing for
> students

You actually touched on something that has been at the back of my mind
for a while.  Else where in this discussion:

Matthew Flatt writes:

> At Sat, 20 Jul 2019 18:07:40 -0400, Christopher Lemmer Webber wrote:

>>  - Are people happy?  Is this meeting their needs?  Get community input.
>>At this point, if the community is happy enough, and if it appears
>>that *newcomers* (including in the educational space) are happy
>>enough, now we can focus on switching the core Racket system over
>>to ~Honu-as-the-basis.
>
> I agree that the process would have to be something like that.
>
> I'm skeptical of starting with teaching languages in the sense of BSL,
> ISL, and ASL. That sets up some different problems --- ones that Pyret
> has directly addressed/explored. (Obviously, we should pay attention to
> Pyret.)

I've been thinking about this, and I think that it's hard enough *for
me* to jump between different syntaxes.  If there was a switch to ~Honu
as being the default, it really should be ~Honu everywhere... not ~Honu
in one place and Pyret like syntax in the other (or vice versa).  That
kind of context switch is really hard.

In my experience, the most empowering thing for students is "being able
to write programs that do cool things".  If we use different syntaxes, I
think this will feel like the worlds between a "beginner's language" and
the "main world of Racket" will feel like too much of a jump... I know
*I* get intimidated by a shift in syntax, and I'm sure that for
students, it's even harder.

Gerald Sussman explained Python's success, and the reason for the switch
from Scheme and SICP to a Python based curriculum, as being because
Python had for whatever reason libraries that allowed students to be
able to lego together examples very quickly.  I've made the case that
Racket is the Python of lisps... even if we aren't continuing to have a
lispy syntax by default, we should realize that this is a strength we
don't want to lose.  If there's a syntax gulf between the restricted
student languages and the "main" language, we'll diminish that value
we're providing to newcomers.

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


[racket-users] Honu thoughts and clarification

2019-08-07 Thread Christopher Lemmer Webber
Today I read the 2012 Honu paper:

  http://www.cs.utah.edu/~rafkind/papers/honu-2012.pdf

Some impressions and a question:

 - Well it's pretty obvious where I stand on my preference for lisp
   syntax.  But!  I'll say the Honu paper is beautifully written and is
   maybe the nicest non-s-expression approach to macros to date.  (Not
   as nice or (heh) expressive as if you use s-expressions, but it's
   great to have this contribution for when you can't.)

 - I was confused a bit by the $ foo ... $ delimiting.  Why $ for both
   the start and end?  I would have thought to do `$( foo ... $)` or
   `^ foo ... $`  or something.  Then it hit me: is this the same reason
   we can't do two ellipses at the same level in pattern matching?
   That's my guess, would love confirmation/denial.

 - The design overall seems to make a lot of sense to me, except for one
   big red flag for me: infix prioritization levels.  Yikes!  Is this a
   good idea?  So many hours wasted trying to make sense of arbitrary
   ordering properties from standard algebraic notations, and now we're
   adding the ability for users to add *new* complications?  It seems to
   me that SRFI 105 had the right idea: a "universal" infix notation
   without ambiguity: {x + {y * z}}

   My friend Lee Spector is more bold about it than I am:

 On the first day of my presidency I will sign an executive order
 banning infix notation, thereby preventing the senseless
 squandering of so many of our precious mathematical and
 computational resources.
  -- https://twitter.com/leespector/status/1159155362957877249

Overall though, I want to say that even though I remain cautiously
skeptical about moving to a new surface syntax (but am more satisfied by
what I think the process for exploring it), it's hard to imagine a
better design for a non-s-expression syntax than what Honu has done,
assuming it isn't an "invisible parentheses" approach (like
Sweet-Expressions or Wisp).  Good stuff, thanks to those who worked on
it.

 - 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/87blx0q1tq.fsf%40dustycloud.org.


Re: [racket-users] Racket2 possibilities

2019-07-20 Thread Christopher Lemmer Webber
Hi Matthew,

As someone who (unintentionally) caused maybe some of the debate to get
out of hand (or did I?) I would like to open by saying that both your
last email to the prior thread and also this email are both very
encouraging.

I'll skip everything else and jump straight to:

Matthew Flatt writes:

> How to Proceed
> --
>
> Ideally, we would first decide on whether we want to try changing
> surface syntax ever. Then, only if we have enough consensus that it's
> worth a try, we could move on to setting overall goals and picking a
> roadmap. Finally, if the planing of the roadmap succeeds, we could
> follow it while getting into the details.
>
> Unfortunately, it doesn't work like that. We need concrete examples to
> discuss the possibility of changing syntax, potential roadmaps to see
> whether there's anywhere we want to go, and so on. Some of the
> discussion will necessarily put a cart before a horse. Delving into
> some details may incorrectly give the impression that prerequisites
> are a foregone conclusion. We've seen all of that already, starting
> with my attempt to open up the discussion in the middle of RacketCon
> and probably continuing with this message. Perhaps we can just accept
> that this is all okay in the spirit of working together.
>
> I originally thought that we should have a more specific process in
> place for discussion at this point, but I think I've been proved
> wrong. Let's just discuss, for now. I'll be posting more myself.

For the sake of discussion, maybe it's easiest to just assume "Racket
attempts a move to a Honu derivative" as its surface syntax, which I'll
call ~Honu for now.  (I'm not saying that we know that will happen, I
just think it's a good place to start discussing.)  As you have already
said, this will not prevent the existance of "#lang racket" keeping the
syntax many in the community (including myself) already love.

As you said, changing the surface syntax is high-risk, possibly
high-reward.  I agree with that, though I think Racket is uniquely
positioned to lower the risk dramatically *because* of the #lang
infrastructure.  Is a "try it before we fully buy it" approach maybe
possible?  Maybe, for one thing, this could reduce community anxiety
and improve our chances to explore.

Here, maybe is a way it could be done:

 - First, port the teaching languages and etc over to Honu.  Try
   teaching some classes with just-Honu syntax.  This is *before*
   trying to switch the "internals" of Racket over.
 - Encourage a large portion of the community to try to write as many
   tools using ~Honu as possible.  How do people like it?  What can be
   improved?
 - Begin switching the core docs over, maybe even as a fork.  It might
   be a pain to maintain two doc forks, but maybe it is worth it.
   I suspect that Scribble might even make the task easier, since
   autogenerating two manuals from mostly the same source might not
   be too hard.
 - Switch all the default examples on racket-lang.org over to ~Honu.
 - Are people happy?  Is this meeting their needs?  Get community input.
   At this point, if the community is happy enough, and if it appears
   that *newcomers* (including in the educational space) are happy
   enough, now we can focus on switching the core Racket system over
   to ~Honu-as-the-basis.

What do you think?  This seems like a clean transition plan to me that
also allows for us to test, readjust, and even allows us to "stage
before we commit", which seems like a big win.

Thoughts?
 - 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/87tvbgz7f7.fsf%40dustycloud.org.


Re: [racket-users] Re: The case, and a proposal, for elegant syntax in #lang racket2

2019-07-17 Thread Christopher Lemmer Webber
Hendrik Boom writes:

> On Wed, Jul 17, 2019 at 04:52:37PM -0700, Maria Gabriela Guimarães wrote:
>>
>> Does Racket wants to be popular in the industry? Then Racket must focus on
>> being a language-oriented programming ecosystem on a popular VM, like the
>> ErlangVM, the JVM, and the WebAssemblyVM. This means to stop working on the
>> RacketVM, if there's such a thing, and to start moving Racket's
>> language-oriented programming features into these popular VMs.
>
> There may be performance advantages to the Racket VM, so I wouldn't
> stop developing it.  But adding those other popular VMs may well be a
> win.
>
> -- hendrik

The work that Matthew Flatt is doing on Racket-on-Chez should be opening
up the possibility of running Racket on multiple other foundations, is
my understanding from conversations in the past.  So I don't think we
need to pivot, since opening up the possibility for this is already on
track.

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


Re: Backing up [was: Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2]

2019-07-16 Thread Christopher Lemmer Webber
Matthew Flatt writes:

> The idea that the Racket project leadership is discussing this is
> entirely plausible, of course, given the way things have operated in
> the past. Let me emphasize again, however, that you should take Aaron
> Turon's keynote as evidence that we do not want to do things the same
> way this time.
>
>
>> So if Matthew wanted to decree that he's been working on this a
>> quarter century and just wants to change surface syntax, next
>
> Just in case anyone has forgotten, since the live stream was recorded,
> I can quote myself verbatim:
>
>  I am not standing here today saying this this is the direction we
>  should go. I want to get the idea out there and start a conversation
>  about what we should do.
>
>
> Apologies for answering your message very sparsely, but it's because I
> think your message part of a discussion that we should organize in a
> different way. Of course, I'm not stopping anyone from posting, anyway.
>
> I regret that I did not understand the importance of setting up a good
> forum for discussion before even offering the idea. Live and learn.

Hi Matthew,

Thanks for your response.  FWIW I really appreciated Aaron Turon's
keynote and I think it did give good indication that leadership hopes
to involve the community in the process.

In a way, Racket is also uniquely positioned to be able to experiment
here.  The #lang aspect of Racket means we can take a "try it before
we buy it" approach, or rather, before we go all in on buying it.  I
have been thinking the last few days that this even gives us
flexibility that whatever syntax is decided on could start out as a
"merely surface syntax" approach before moving to "core idioms": we
could try as a community to put that language's syntax on most of the
introductory documents and etc and teach courses with it for a period
before deciding to switch any key semantics, even if any were to
change.

I can't think of any other language environment that has the
opportunity for that level of experimentation, and that seems like a
feature to me.

That said, I do think that all of Greg's comments are useful food for
thought. :)

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


Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2

2019-07-15 Thread Christopher Lemmer Webber
Jack Firth writes:

> Matthias, I ask that you please not respond to discussion about the
> diversity of the Racket community by saying it's a political topic and
> politics have no place here. That statement alone is political and makes
> many people feel unwelcome, including me.

Likewise... and I find it troubling that I did not specify a mechanism
for improving diversity, just stated that it would be nice to see it
improved, and this was stated as a problem.

>> Our policy has always been that everyone, absolutely everyone, is
>> welcome on this technical list to discuss technical issues. We don’t
>> exclude anyone. And everyone gets treated the same and gets productive
>> responses if possible. In particular, politics stays off this list; it’s
>> divisive enough in the rest of the world.

If absolutely everyone is welcome, why is not absolutely everyone here?

It does not seem to be controvercial to state that we would like more
middle schoolers using Racket; indeed, this appears to be the goal of
Racket 2.  If we extend that logic, there is no reason we cannot wish
for aiming for that level of success for other groups.

I agree that programming should be absolutely for everyone, that is part
of what brought me to Racket and I think it is uniquely positioned to
meet that goal.  I look forward to coming to RacketCon in the future,
looking around, and feeling that it looks like we are achieving that
dream.

 - 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/87muhfqj2o.fsf%40dustycloud.org.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Building "#lang dungeon"

2019-07-15 Thread Christopher Lemmer Webber
Konrad Hinsen writes:

> Hi Chris,
>

Hi Konrad,

> While I understand the general goal you are aiming at, it isn't quite
> clear to me who you are trying to protect against who. There's a wide
> spectrum of people involved, ranging from language designers via library
> developers and application developers to end users. Who is going to
> define your capabilities? Who is supposed to be protected by them?  And
> who is the potential villain whose evil doings need to be checked for?
>
> Your example doesn't help much with this, as playing a game of solitaire
> from the Racket REPL is not a relevant real-life scenario. The typical
> solitaire player is an end-user who double-clicks an application and
> wouldn't understand the implications of granting access to a single
> window.

Of course I don't expect someone to launch solitaire from the REPL, and
indeed there are UX considerations once we move from the REPL to actual
program launch.  There *are* paradigms for that that have been
developed, and intuitive behaviors such as drag and drop compose nicely
with a capability discipline.

However, I am talking to language people about how we give authority to
parts of our programs, so something that works at the REPL can help us
think more at this level of abstraction, aside from the other ones :)

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


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

2019-07-15 Thread Christopher Lemmer Webber
Maciek Godek writes:

> Maybe the direction similar to where "I think we should be heading" is 
> somewhere between Mathematica notebooks and Smalltalk's object environments.

I had similar-ish thoughts while watching the excellent Fructure talk at
this year's RacketCon: maybe intro courses would be more willing to pick
up Racket and not be scared of its syntax if the default educational
language was more like Scratch.  One nice thing about Fructure is that
it didn't present any parentheses, but I suspect that the way that it
presented grouping meant that if you eventually switched from that mode
of writing code over to textual parenthetical notification, it would
feel like a fairly natural shift.

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


Re: [racket-users] Building "#lang dungeon"

2019-07-14 Thread Christopher Lemmer Webber
ra...@airmail.cc writes:

> There is http://shill.seas.harvard.edu/ it runs on freebsd.

Yes, it's a good source of inspiration.  However it's really meant for
shell scripting and isn't quite a good fit for the case I need, which is
for more general racket programming.

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


Re: [racket-users] Building "#lang dungeon"

2019-07-14 Thread Christopher Lemmer Webber
Hi Dionna, thanks for your reply!

I gave a response to you IRL that I think I hadn't conveyed here which
is that there's a reason I'm taking the lambda-approach to capabilities
(which is explicit) vs an ambient/dynamic approach of continuation
marks.  One reason is that the work I'm trying to build can have
references that cross machines (Goblin[oid] has preliminary support for
this, but it isn't really fully implemented yet); in order for those to
work, we can't rely on runtime scope behavior since we also are going to
compose with remote capabilities as well, which do not have access to
our inner runtime.

I hear your concern that this is too much explicit argument passing; the
only thing I suppose I can respond with is that this is how previous
ocap systems have worked.  One thing that helps a lot is that we can
compose capabilities by enclosing over them, and often times doing this
enclosure can abstract the necessary things we need, but it does indeed
result in more argument passing.

Dionna Amalie Glaze writes:

> Capabilities can be tracked with continuation marks. For a language to
> grant a subset of capabilities to a required module, you can do something
> like contract-in that will wrap identifiers with a with-continuation-marks
> capability restriction. The tricky part becomes how to make all I/O
> subsystems etc. actually consult and respect the capabilities that are
> marked on the continuation. That will take a really invasive change to the
> runtime, or a flawed approach of a wrapper language around #%kernel such
> that everything that builds on top of it respects capabilities.
> Unfortunately we can't treat existing modules like functors for which we
> can replace the underlying #%kernel.
>
> On Sun, Jul 14, 2019 at 10:25 AM Christopher Lemmer Webber <
> cweb...@dustycloud.org> wrote:
>
>> Every day the threats facing our computing environments are getting
>> worse.  Recent incidents in both gems and npm have shown modules
>> exfiltrating information from developers' machines or production
>> servers.  It is likely that soon package managers will also be targeted
>> to install cryptolockers to attack developers' machines, or worse,
>> install backdoors that allow an attacker to perform arbitrary execution.
>> How can we make Racket not only a fun and fulfilling development, but
>> also a safe one?
>>
>> Thankfully, Jonathan Rees did the kind work of laying out the recipe for
>> dramatically improved safety over two decades ago:
>>
>>   http://mumble.net/~jar/pubs/secureos/secureos.html
>>
>> It turns out that the lambda calculus already provides the fundamental
>> layer of security we need; code can only perform actions it has
>> references to.  This is called "object capability (ocap) security";
>> a decent (ok, I'm biased) intro to the ideas can be found on this
>> podcast episode if you are interested:
>>
>>
>> https://librelounge.org/episodes/episode-13-object-capabilities-with-kate-sills.html
>>
>> Racket already has most of the pieces in place; we just need to add one
>> more thing.  Consider and contrast the following scenarios:
>>
>> Conventional Racket scenario:
>>
>>   ;; Runs a game of solitaire.
>>   ;; Also has access to your entire filesystem, can secretly exfiltrate
>>   ;; data or install backdoors, etc etc.
>>   (solitaire)
>>
>> A more desirable scenario:
>>
>>   ;; Runs a game of solitaire.
>>   ;; *Only* has access to a stream of input when the window is active,
>>   ;; the ability to draw to a *specific* window on the screen, the
>>   ;; ability to read/write from a single file on disk, the save file.
>>   (solitaire get-input
>>  display-graphics-to-window
>>  save-file-access)
>>
>> Now the amount of damage that solitiare can perform is significantly
>> curtailed.  It can perhaps display images we would not like to see
>> or write nonsense to its save file, but it cannot do anything else.
>> (We could also put limits in the save-file-access procedure on how
>> large of a file it is allowed to write, if we were worried about that.)
>>
>> The key idea here is that authority flows through the system the same
>> way that data naturally flows through a program.  You simply don't have
>> more access than what you allowed to flow through.
>>
>> So what is necessary to make Racket ocap-secure?  The primary problem is
>> the assumption of "require", that any module can "reach out" and gain
>> access to anything it likes, be it network access or file access or etc.
>>
>> What I would like instead is to allow modules to be "g

Re: [racket-users] The case, and a proposal, for elegant syntax in #lang racket2

2019-07-14 Thread Christopher Lemmer Webber
I sent this about 5 minutes before Jay announced
https://github.com/racket/racket2-rfcs :)

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


[racket-users] The case, and a proposal, for elegant syntax in #lang racket2

2019-07-14 Thread Christopher Lemmer Webber
The context of this email is the proposal by Matthew Flatt that we move
to an easier-to-accept surface syntax for #lang racket2.

Matthew Flatt has heard more than enough from me of concern about this
proposal.  But I should indicate that I'm highly sympathetic to the
goal.  I would like to lay out the following observations:

 - The challenge with s-expressions is largely in anxiety with something
   that looks extremely alien.  I suspect there's more fear from
   instructors than students in encountering a lisp syntax; my
   experience is that introducing someone who doesn't know differently
   to a parenthetical syntax isn't scary for them, and they tend to like
   it.  But people who have *started out* with experience in a non-lispy
   language tend to find it scary.

 - Nonetheless, assumptions that various math operators should be infix
   is understandable because that's what people see today.

 - I am indeed very for growth in the community, though my main interest
   in growth is in seeing a wider diversity of participants than just
   raw numbers.  Obviously other peoples' mileage may vary.

 - We are at serious risk in this pivot of losing some key things:

   - Many communities I have been in that have undertaken such a large
 pivot to increase popularity expend enormous energy in the move to
 the new thing, and in that process, the project actually collapses.
 What I'm trying to say is that a pivot is a gamble; we should
 calculate our odds carefully.  (Indeed, the first thing I thought
 when I heard that this might happen was, did I make a mistake in
 shifting my work to Racket?  It is unlikely I would have come to
 Racket if there wasn't an equivalent amount of elegance.)

   - I'm not sure if I could have understood Racket Week with a syntax
 that didn't have the elegance of s-expressions.  This is not to say
 that *no* syntax can have that level of elegance where things can
 be so clear, however.

IIRC Matthew's proposal for "#lang racket2" was something like the
following:

 a) function(args ...) should work.
 b) infix is necessary for math, such as 3 + 4
 c) parentheses should be possible for grouping

The weird thing about the last one being that this is already kind of
true in s-expressions, but by ~default this also results in application.

Let me add one more suggested design goal:

 - the new syntax should must not be significantly less elegant than
   s-expressions.

Is there a way to achieve this?  I actually think the best path forward
is to have a surface syntax that actually maps completely to
s-expressions, which is in fact universal that it can work with *any*
s-expression syntax.

I would suggest starting with Wisp as the basis for examining this:

  https://dustycloud.org/blog/wisp-lisp-alternative/
  https://srfi.schemers.org/srfi-119/srfi-119.html

Sweet-expressions may also be an alternative to explore.  However, I
think Wisp is a more elegant base; it can transform *any* wisp code into
s-exp code.  Not discussed in my blogpost about Wisp is that it also
supports infix via {3 + 4}.  So ok, now we have that.  And we can still
group:

  {3 + {8 + 4}}

So that's points b) and c), but we don't have a) yet.  Could we add it?

I think we can extend wisp with one thing and get everything we want: if
you have func(arg1 arg2 arg3) where the parenthesis comes *immediately*
after the symbol, that is rewritten to (func arg1 arg2 arg3).  I will
call this version ~Wisp.

With all this, observe the following code rewritten from Scheme to ~Wisp:

  (define (rgb-maker mk)
(lambda (sz)
  (vc-append (colorize (mk sz) "red")
 (colorize (mk sz) "green")
 (colorize (mk sz) "blue"

  define rgb-maker(mk)
lambda(sz)
  vc-append(colorize(mk(sz) "red")
colorize(mk(sz) "green")
colorize(mk(sz) "blue"))

Here is another chunk of code, taken from HTdP2:

  (and (or (= (string-length "hello world")
  (string->number "11"))
   (string=? "hello world" "good morning"))
   (>= (+ (string-length "hello world") 60) 80))

To:

  and(or({string-length("hello world") = string->number("11")}
 string=?("hello world" "good morning"))
  {{(string-length "hello world") + 60} >= 80})

And in fact the latter can transform itself *directly* into the former.
And the former technically is also still valid Wisp: you can embed
s-expressions into it and they still work.

I think this satisfies the requirements that Matthew laid out.

There's another major advantage of this.  We can now write languages
that work either like:

  #lang s-exp "mylang.rkt"

or:

  #lang wisp "mylang.rkt"

The main thing that Wisp is missing right now is editor tooling so that
doing indentation is convenient.  But that's more than feasible to add,
imo.

I think this is the best way to move forward without creating
significant divisions, throwing out valuable things we have, or making

[racket-users] Building "#lang dungeon"

2019-07-14 Thread Christopher Lemmer Webber
Every day the threats facing our computing environments are getting
worse.  Recent incidents in both gems and npm have shown modules
exfiltrating information from developers' machines or production
servers.  It is likely that soon package managers will also be targeted
to install cryptolockers to attack developers' machines, or worse,
install backdoors that allow an attacker to perform arbitrary execution.
How can we make Racket not only a fun and fulfilling development, but
also a safe one?

Thankfully, Jonathan Rees did the kind work of laying out the recipe for
dramatically improved safety over two decades ago:

  http://mumble.net/~jar/pubs/secureos/secureos.html

It turns out that the lambda calculus already provides the fundamental
layer of security we need; code can only perform actions it has
references to.  This is called "object capability (ocap) security";
a decent (ok, I'm biased) intro to the ideas can be found on this
podcast episode if you are interested:

  
https://librelounge.org/episodes/episode-13-object-capabilities-with-kate-sills.html

Racket already has most of the pieces in place; we just need to add one
more thing.  Consider and contrast the following scenarios:

Conventional Racket scenario:

  ;; Runs a game of solitaire.
  ;; Also has access to your entire filesystem, can secretly exfiltrate
  ;; data or install backdoors, etc etc.
  (solitaire)

A more desirable scenario:

  ;; Runs a game of solitaire.
  ;; *Only* has access to a stream of input when the window is active,
  ;; the ability to draw to a *specific* window on the screen, the
  ;; ability to read/write from a single file on disk, the save file.
  (solitaire get-input
 display-graphics-to-window
 save-file-access)

Now the amount of damage that solitiare can perform is significantly
curtailed.  It can perhaps display images we would not like to see
or write nonsense to its save file, but it cannot do anything else.
(We could also put limits in the save-file-access procedure on how
large of a file it is allowed to write, if we were worried about that.)

The key idea here is that authority flows through the system the same
way that data naturally flows through a program.  You simply don't have
more access than what you allowed to flow through.

So what is necessary to make Racket ocap-secure?  The primary problem is
the assumption of "require", that any module can "reach out" and gain
access to anything it likes, be it network access or file access or etc.

What I would like instead is to allow modules to be "granted" access.
The idea is in fact the same as with the solitaire-as-procedure solution
above: modules gain access not by reaching out and grabbing whatever
they want, but by being "handed" access.  Imagine your module as one big
procedure where we pass in access to other modules/values/macros and
you'll get the idea.



#+BEGIN_SRC racket
  #lang dungeon

  ; passed in, already fully "empowered"
  (require match
   graphics-tools
   keyboard-tools
   ;; the parent module must trust us a lot, they gave us full
   ;; filesystem access!
   general-file-io
   ;; solitaire needs picture constructors to generate graphics
   (empower solitaire graphics-tools))

  (provide run-solitaire)

  (define (get-input input-source)
...)

  (define (display-graphics-to-window ...)
...)

  (define (make-save-file-access filename)
(match-lambda
  [(list 'read) (call-with-input-file filename port->bytes)]
  [(list 'write bytes)
   (call-with-output-file filename
 (lambda (p)
(write-bytes bytes p))
 #:exists 'replace)]))


  (define (run-solitaire [save-file "~/.racket-solitaire"])
(solitaire get-input display-graphics-to-window
   (make-save-file-access save-file)))
#+END_SRC

I've handwaved over a couple of things, but this module shouldn't be
afraid that the solitaire procedure that comes from the empowered
solitaire module has access to dangerous things such as the full
filesystem (even though the importer of *this* module trusted it to have
full filesystem access), and neither module has network access.

I don't know how to build this fully; I know that:
 - we need code inspectors to prevent evil hygeine-breaking, but good
   news we have that
 - I need a way to make *something like require* work, but where the
   import-er is able to very explicitly pass in which modules are
   allowed.  This seems to mean something *like* controlling the module
   registry.  Note that this also means that the names of the modules
   being imported aren't from a "global registry" anymore, it's the
   names that the empowering-module provided.

There's an alternative, which is the emaker / frozen realms approach.
This approach actually instead gives you an extremely minimal base
syntax that *cannot be extended*.  No new macros.  Instead, the module
that is imported wakes up in a cold world of 

[racket-users] Accomodation on the Racket School 2019 page

2019-03-18 Thread Christopher Lemmer Webber
According to https://school.racket-lang.org/#accommodation
there's subsidized lodgin at the University of Utah dorms.
Sounds great!  But it's not really clear to me which buildings it would
be at or where I should contact them.  Maybe this is useful info to
clarify on the website?

I see that contact info is listed at the bottom of:
https://housing.utah.edu/

Should I just call that? :)

Not really sure myself, so I figured others may also be unsure, and I
don't see a contact link on the Racket School page, so I figured I'd
email the list.  Hope it isn't too awkward!

 - 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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Spritely Golem: Secure, p2p distributable content for the fediverse

2019-02-17 Thread Christopher Lemmer Webber
The "fediverse" means the federated (decentralized) social web.
And Spritely, as I've said here recently, is a series of demos
and writeups which show how to "level up" the fediverse with
some new ideas to make it more powerful and resilient.

I just finished writing the documentation for Spritely Golem, the first
major of these demos:

  https://gitlab.com/spritely/golem/blob/master/README.org

A major problem on the federated social web (and actually web in
general) is that servers go down, and all the associated content goes
down with them.

There is also corresponding code, which I have tried to keep relatively
lean, approximately 500 lines for a proof of concept demo application.
And it's all in Racket!

  https://gitlab.com/spritely/golem/blob/master/golem.rkt

There's more of these to come.  I'm fairly happy with how the first one
has gone, however!

 - Chris

PS: In the future I will probably convert the documentation from
  org-mode to Scribble, but I have a bit of an easier time knocking out
  thoughts quickly in org-mode, and didn't want the demo to be held
  up by me having an internal debate of how to organize it all.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] i18n / translations

2019-02-09 Thread Christopher Lemmer Webber
How are people currently translating their programs?
I expected to see a gettext library or something, but haven't.

I see that DrRacket is translated, but I did a few simple greps through
the DrRacket repo and couldn't figure out how.

Am I missing something?  Or is this tooling that needs to be written?
 - 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Some concern about ChezScheme...

2019-02-08 Thread Christopher Lemmer Webber
Matthew Flatt writes:

> Personally, while my contributions to Chez Scheme so far have been
> modest, I have already factored into my costs the worst-case scenario
> of fully maintaining Chez Scheme as used by Racket. Even if that
> happens, it still looks like a good deal in the long run.

That's nice to hear (though I hope it doesn't need to happen).
Part of the reason I haven't been too worried is that in conversations
with you it's sounded like the goal of Racket-on-Chez has also been to
allow for *multiple* backends (eg, I still think a Guile backend would
be interesting some day).  That seems like it reduces the risk
substantially.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Spritely awarded Samsung Stack Zero grant

2019-01-31 Thread Christopher Lemmer Webber
I've mentioned that my goal has been to advance the
federated/decentralized social web in Racket on here before.  Here's
some news:

  
https://samsungnext.com/whats-next/category/podcasts/decentralization-samsung-next-stack-zero-grant-recipients/

I'm being funded for the next two years to work on this stuff!  And I'm
planning on doing it all in Racket.

In fact, I'm at a hackathon right now kicking it off, and I'm on the
verge of releasing the first major demo.

Anyway, there's been some conversation about
wouldn't-it-be-nice-if-more-people-were-paid-to-do-web-dev-in-racket
so... here's one case! :)

I hope I can use this to help raise the profile of how great Racket
is for this kind of work!

 - 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] sxml vs xexpr frustrations

2019-01-31 Thread Christopher Lemmer Webber
Is xexprs really maintained either?  At any rate, not all software needs
very active maintenance; sxml seems to be fairly stable.  Maybe you
disagree. :)

At any rate, I don't think xexprs support namespaces, which sxml has
tooling for, which is one important thing.

Matthew Butterick writes:

> I (ab)use xexprs for Pollen because they're used in the Racket web
> server, and because at the time, SXML seemed largely abandoned — no
> traffic on its mailing list [1] and today, even Oleg's SXML page is a
> 404. [2]
>
> I wouldn't try to pry SXML from anyone's fingers. But dragging around
> open-source software abandoned by its owner tends to incite conditions
> of madness. (Insert your favorite 80s typesetting system here.)
>
> [1] https://sourceforge.net/p/ssax/mailman/ssax-sxml/
> [2] http://pobox.com/~oleg/ftp/Scheme/SXML.html
>
>  On Jan 30, 2019, at 10:27 AM, Christopher Lemmer Webber 
>  wrote:
>
>  IMO, it makes more sense to have sxml be the "right" one, since it has
>  wider user outside of just Racket, and there are some much nicer tools
>  available for it:
>
>   https://docs.racket-lang.org/sxml-intro/index.html#%28part._.Tools%29
>
>  (That, and I find the @ property syntax a bit easier to follow, but that
>  barely 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket v7.2

2019-01-31 Thread Christopher Lemmer Webber
Vincent St-Amour writes:

> Racket version 7.2 is now available from
>
> http://racket-lang.org/
>
> Racket-on-Chez is done in a useful sense, but we'll wait until it gets
> better before making it the default Racket implementation. For more
> information, see
>
> http://blog.racket-lang.org/2019/01/racket-on-chez-status.html

So exciting!  What a great time to be in the Racket world.  :)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] sxml vs xexpr frustrations

2019-01-30 Thread Christopher Lemmer Webber
Neil Van Dyke writes:

> 'John Clements' via Racket Users wrote on 1/30/19 1:46 PM:
>> Fundamentally, I think that what you’re proposing is sensible … and probably 
>> a lot of work that’s not currently at the top of anyone’s list.  :)
>
> Yes, the xexprs and SXML stuff is mostly very old (perhaps most of it
> from so far back that Racket even had its own little Web browser),

This one?

  https://docs.racket-lang.org/browser/index.html

Or is there another one I ought to know of? :)
Believe it or not, I may have good reason to make use of some of that
code, in my upcoming work...

  https://dustycloud.org/misc/mmose.pdf

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] sxml vs xexpr frustrations

2019-01-30 Thread Christopher Lemmer Webber
One very frustrating thing for me is the inconsistency between which
sexp xml representation is the "right" one, sxml or xexpr.  Different
tools support different things, and thus don't interoperate when they
easily could have.  I wish the Racket community could collectively make
a decision and "deprecate" one of them.

IMO, it makes more sense to have sxml be the "right" one, since it has
wider user outside of just Racket, and there are some much nicer tools
available for it:

  https://docs.racket-lang.org/sxml-intro/index.html#%28part._.Tools%29

(That, and I find the @ property syntax a bit easier to follow, but that
barely matters.)

Possibly opening a can of bikeshed,
 - 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Serving my web application and some static files

2019-01-30 Thread Christopher Lemmer Webber
Thanks!  It's true that the #:extra-files-paths works fine if I'm happy
enough with its contents not being "mounted" under a separate path.  I
guess that's fine for now, though I really would like to figure out how
to compose servlets and dispatchers the "proper" way. :)

Stephen De Gabrielle writes:

> Hi
>
> The contine tutorial has a good bit on serving static files:
>
> The bit on #:extra-files-paths:
> https://docs.racket-lang.org/continue/index.html#%28part._.Leaving_.Dr.Racket%29
>
>
> This is what I did
> https://github.com/spdegabrielle/clash
> main.rkt
>
> Sorry bit of a rush- let me know if I’m making sense - I can do a smaller
> example to your spec this evening.
>
> Stephen
>
>
> On Wed, 30 Jan 2019 at 16:42, Christopher Lemmer Webber <
> cweb...@dustycloud.org> wrote:
>
>> It seems like it should be so simple, and like Racket has the tools
>> already, but I can't figure out how to do it.
>>
>> I have the following:
>>
>>   (serve/servlet start
>>  #:servlet-regexp #rx""
>>  #:launch-browser? #f)
>>
>> I'd like to do something like the following:
>>
>>   - Serve static files for urls matching /static/*
>>   - Serve those very files from the ./static/ directory
>>
>> I'd expect I'd do something like combine that all with:
>>
>>   (file-dispatch:make #:url->path (make-url->path
>> (build-path cwd "static")))
>>
>> But I'm lost.  I can figure out how to serve static files OR use the
>> controllers in my start function, but combining them???  I'd like to
>> serve some static files *in addition* to my the above code.  Between
>> dispatchers and servlets and even the file serving dispatchers, I
>> thought I could figure out something relatively easy out of the box.
>> But hours later I'm still scratching my head about how to combine
>> servlets or dispatchers or what have you.
>>
>> I've read a bunch of things:
>>  - https://www.greghendershott.com/2013/03/serve-static-files.html
>>  - https://docs.racket-lang.org/web-server-internal/dispatch-files.html
>>  -
>> https://docs.racket-lang.org/web-server-internal/dispatch-sequencer.html
>>  - and pretty much everything under
>> https://docs.racket-lang.org/web-server/
>>
>> ... but I can't figure out how to do it without reinventing all the
>> machinery that appears to already exist in Racket.  There must be
>> something obvious and simple right in front of 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.
>> For more options, visit https://groups.google.com/d/optout.
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Serving my web application and some static files

2019-01-30 Thread Christopher Lemmer Webber
It seems like it should be so simple, and like Racket has the tools
already, but I can't figure out how to do it.

I have the following:

  (serve/servlet start
 #:servlet-regexp #rx""
 #:launch-browser? #f)

I'd like to do something like the following:

  - Serve static files for urls matching /static/*
  - Serve those very files from the ./static/ directory

I'd expect I'd do something like combine that all with:

  (file-dispatch:make #:url->path (make-url->path
(build-path cwd "static")))

But I'm lost.  I can figure out how to serve static files OR use the
controllers in my start function, but combining them???  I'd like to
serve some static files *in addition* to my the above code.  Between
dispatchers and servlets and even the file serving dispatchers, I
thought I could figure out something relatively easy out of the box.
But hours later I'm still scratching my head about how to combine
servlets or dispatchers or what have you.

I've read a bunch of things:
 - https://www.greghendershott.com/2013/03/serve-static-files.html
 - https://docs.racket-lang.org/web-server-internal/dispatch-files.html
 - https://docs.racket-lang.org/web-server-internal/dispatch-sequencer.html
 - and pretty much everything under https://docs.racket-lang.org/web-server/

... but I can't figure out how to do it without reinventing all the
machinery that appears to already exist in Racket.  There must be
something obvious and simple right in front of 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Multipart HTTP requests

2019-01-30 Thread Christopher Lemmer Webber
Jon Zeppieri writes:

> On Tue, Jan 29, 2019 at 4:17 AM Christopher Lemmer Webber <
> cweb...@dustycloud.org> wrote:
>
>>
>> Any thoughts on how I should move forward?
>
>
> I think that using a `data-procedure/c` of a particular sort should allow
> you to implement this without needing access to the struct internals or
> needing to read everything into memory at once.
>
> (Though, it would be a bit nicer if the write proc allowed you to specify
> an offset and length into the string/byte string.)
>
> Something like:
> ===
> #lang racket/base
>
> (require net/http-client
>  file/sha1
>  racket/random)
>
> (define (http-conn-send/multipart! hc uri multipart-body
>#:version [version #"1.1"]
>#:method [method #"POST"]
>#:close? [close? #f]
>#:headers [headers '()]
>#:content-decode [decodes '(gzip)]
>#:boundary [boundary (random-boundary)])
>   (define content-type-header
> (string-append
>  "Content-Type: multipart/form-data; boundary="
>  boundary))
>
>   (http-conn-send! hc uri
>#:version version
>#:method method
>#:close? close?
>#:headers (cons content-type-header headers)
>#:content-decode decodes
>#:data (multipart-body->data-proc boundary
> multipart-body)))
>
> (define (mime-escape s)
>   (regexp-replace* #rx"[\"\\]" s "\\0"))
>
> (define (make-string-part field-name field-value)
>   (λ (write-chunk boundary)
> (write-chunk
>  (format
>   (string-append "--~a\r\n"
>  "Content-Disposition: form-data; name=\"~a\"\r\n"
>   "Content-Type: text/plain; charset=utf-8\r\n"
>   "\r\n"
>   "~a\r\n")
>   boundary
>   (mime-escape field-name)
>   field-value
>
>
> (define (make-file-part field-name file-name content-type in)
>   (λ (write-chunk boundary)
> (write-chunk
>  (format
>   (string-append "--~a\r\n"
>  "Content-Disposition: form-data; name=\"~a\";
> filename=\"~a\"\r\n"
>   "Content-Type: ~a\r\n"
>   "\r\n")
>   boundary
>   (mime-escape field-name)
>   (mime-escape file-name)
>   content-type))
>
> (define buffer (make-bytes 4096))
> (let loop ([n (read-bytes-avail! buffer in)])
>   (cond
> [(eof-object? n)
>  n]
> [else
>  (write-chunk (subbytes buffer 0 n))
>  (loop (read-bytes-avail! buffer in))]))
>
> (write-chunk "\r\n")))
>
> (define (multipart-body->data-proc boundary parts)
>   (λ (write-chunk)
> (for ([part parts])
>   (part write-chunk boundary))
> (write-chunk (format "--~a--\r\n" boundary
>
> (define (random-boundary)
>   (string-append
>"--"
>(bytes->hex-string
> (crypto-random-bytes 8

Oh, this is useful!  I didn't see this when asking for data-procedure/c
examples earlier on the list :)

BTW do you mind specifying a license for your code above so I might
incorporate parts of it into my work?  Maybe either LGPL or Apache v2?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Multipart HTTP requests

2019-01-30 Thread Christopher Lemmer Webber
Philip McGrath writes:

> I've put up the code I mentioned for email-sending and a proxy server at
> https://github.com/LiberalArtist/multipart-writing-examples As noted, these
> are not general-purpose solutions to either of those problems—I know of a
> bunch of cases I don't cover, and I basically only have to use these with
> trusted input—so caveat utor! But hopefully they're useful. I'd be very
> happy to contribute to this effort, as well: a proper multipart writing
> library would go a long way to getting some of the little bits of code I've
> produced into good enough shape to post as a package, enough so that I've
> thought about tackling it myself.

Thank you!  While not perfect, still probably helpful for my purpose :)

> Maybe you've already seen this, but most of the functions in this family
> support supplying post data as a `data-procedure/c
> `,
> which lets you stream using chunked content transfer encoding. I think the
> most explicit documentation for that is under `http-conn-send!
> `.

I have seen this but admittedly I do not understand how to use it.
Maybe it is a failure on my part to understand the contract
descriptions.

Could someone supply an example of use?  I'd really appreciate 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Multipart HTTP requests

2019-01-29 Thread Christopher Lemmer Webber
I see... yeah, I thought about going this route but the reason it didn't
seem particularly "robust" to me is that I would have to read the entire
object into memory at once before passing it in as bytes.  IMO it would
be better to have the option to provide ports with file data so the data
could be streamed in without reading the whole data into memory.
However that would, I still think, require being able to access the
http-conn struct accessors at the very least.

At any rate, if you don't mind, send what you have!  I'm in the middle
of a hackathon and it might help me deliver some cool things faster :)

Please do mark your work with a libre license if you upload it so I can
safely incorporate it :)

Philip McGrath writes:

> I don't think there's a multipart-writing library yet, and it would be a
> great thing to have.
>
> I've written little multipart-writing functions for a small proxy server
> built on `http-sendrecv/url` and for sending email using `net/sendmail`
> with html and text/plain alternatives. I'm happy to share code if it would
> be helpful, but nothing I've written is especially robust—for example, I
> just use a boundary that I know won't appear in legitimate input in my
> cases—which is why I haven't posted it publicly yet.
>
> One thought I've had about making a library is that it would be nice if the
> writing API corresponded in some sensible way to the API from `net/mime
> <https://docs.racket-lang.org/net/mime.html>` (which only handles parsing).
>
> -Philip
>
>
> On Tue, Jan 29, 2019 at 4:17 AM Christopher Lemmer Webber <
> cweb...@dustycloud.org> wrote:
>
>> I'm looking to do multipart HTTP requests in Racket, though it looks
>> like there's no support at the moment.
>>
>> I thought I might add a utility using the net/http-client library,
>> starting with making an adjusted http-conn-send! function.  However, the
>> http-conn-(host/port/etc) struct accessors aren't made available, so it
>> appears I can't build a utility that uses the same http-conn struct.
>>
>> Any thoughts on how I should move forward?  Has anyone else written a
>> multipart library I don't know about, for instance?
>>
>>  - 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.
>> For more options, visit https://groups.google.com/d/optout.
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Multipart HTTP requests

2019-01-29 Thread Christopher Lemmer Webber
I'm looking to do multipart HTTP requests in Racket, though it looks
like there's no support at the moment.

I thought I might add a utility using the net/http-client library,
starting with making an adjusted http-conn-send! function.  However, the
http-conn-(host/port/etc) struct accessors aren't made available, so it
appears I can't build a utility that uses the same http-conn struct.

Any thoughts on how I should move forward?  Has anyone else written a
multipart library I don't know about, for instance?

 - 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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Thoughts/questions on the DOS package

2018-11-30 Thread Christopher Lemmer Webber
Hello all,

This is a conversation I had with Jay earlier earlier this month.  I
asked if I could forward it and Jay said that's fine, so I'm doing so in
case it's of use to anyone else.

For those not in the know, Jay's DOS package stands for
"Delimited-continuation-based Operating-system Simulator" and the docs
can be found here:

  https://docs.racket-lang.org/dos/

I presume some inspiration has been taken from "Delimited Continuations
in Operating Systems" though I have not confirmed with Jay:

  http://okmij.org/ftp/continuations/ZFS/context-OS.pdf

Anyway, for the most part what it's currently used for is defining a
functional way to do game behavior using prompts in one of several
layers... I was trying to figure out how I might do some more complex
game behavior and so hence this email exchange.  I'm still processing
it, admittedly ;)

Anyway, maybe you'll find it interesting or useful!

Jay McCarthy writes:

> Your understanding at last isn't correct :)
>
> The environment after one round of `win-boot` (and the state after one
> round of `os2-boot` or `dos-boot`) is always the result of the monoid
> operation. In the case of `win`, that means that the various
> environment updates that each process writes are merged. If there is a
> key `k1` in the old environment that is not written in the current
> round, then it is not included at all in the next one.
>
> ```
> #lang racket/base
> (require dos/win)
>
> (module+ test
>   (define w
> (win-boot
>  (win-env-replace
>   (win-mbr
>(λ (old-env)
>  (win-write 'new-key
> (add1 (env-read1 old-env 'old-key 0)
>   'old-key (list 41
>
>   (require chk)
>   (chk (win-env-read w 'old-key) '()
>(win-env-read w 'new-key) '(42)))
> ```
>
> As far as your conversation...
>
> First, the `win` environment is strictly for global things. If you
> want local things, then you can use the closed-over state of the
> continuation for that. For example, in the win test, the
> `mouse-tracking-ball` function is using the `r` parameter to have its
> own internal state. It calls itself with `env-write`, which returns
> the environment after synchronization with all the other entities
> (i.e. at the next frame.) This means that the `r` part and the
> control-state of what the ball is doing is embedded in the captured
> continuation.
>
> So, in your example, there's two ways I look at it.
>
> In one case, the player state is global, so there are two effects
> posted a (was-damaged amount) and (was-upgraded amount) and the monoid
> operation has to determine what the effect is. You could reproduce the
> race condition by saying that that the monoid plus is (lambda (x y) x)
> or (lambda (x y) y) and just ignore one of them. (The idea, btw, of
> the the win environment being a set is that most consumers will
> `foldr` the result and have a monoid per key.) Or, you could actually
> inspect the values and have a rule like "teleport always goes first,
> otherwise sum effects." Etc.
>
> In the other case, the player state is local and the collision
> information is global, so the player update process should consult
> that information and you need to decide how to deal with multiple
> collisions at the same time inside that function.
>
> Basically, the first case is where the objects (missiles) read the
> player state and try to update it but the changes must be merged. In
> the second case, the player reads about the missiles and decides how
> it will update its state.
>
> The dos model allows all behaviors that race conditions/etc provide,
> but you have to be a little more particular about what you want.
>
> On Sun, Nov 11, 2018 at 11:58 AM Christopher Lemmer Webber
>  wrote:
>>
>> Aha!  It's clear to me at last.
>>
>> If any process writes to the registry on that turn, they participate
>> in overwriting the value... if multiple processes write, multiple values
>> are written, but if it's just one it's just a list of one value.  If
>> nobody writes to that key, it doesn't change that turn!
>>
>> Christopher Lemmer Webber writes:
>>
>> > Hello Jay,
>> >
>> > I've read through all of the DOS code and docs now.  It's beautiful
>> > stuff!  I love that the main kernel is 50 readable lines and the layers
>> > on top of it aren't much larger.
>> >
>> > The only thing I think I don't understand at this point is the code in
>> > the big-bang usage of the Win example.  From my reading, on each "turn"
>> > a process takes for both mouse-tracking-ball and decaying-ball it's
>> > performing win-write to gfx, adding a new thing to rend

Re: [racket-users] Is this parameters-using code O(n^2)?

2018-11-11 Thread Christopher Lemmer Webber
Matthew Flatt writes:

> At Sun, 11 Nov 2018 13:55:32 -0500, Christopher Lemmer Webber wrote:
>> It struck me recently that I tend to think of parameters as O(1) when in
>> reality they're O(n), where n is the number of frames on the stack,
>> right? 
>
> No, parameter lookup is amoritzed O(1).
>
> Well, actually it's up to O(log N) for N parameters and distinct
> continuation-mark keys. But thinking of it as O(1) is normally
> justified, unless you create extremely many distinct parameters or
> extrmely many distinct continuation-mark keys.
>
>> Due to that reason, I figured the following code would absolutely trash
>> my computer:
>> 
>>  (let ([limit-param (make-parameter 100)])
>>(let lp ([n 1])
>>  (if (= n (limit-param))
>>  '()
>>  (cons n
>>(lp (add1 n)
>>(void)); return void just to avoid printing that all out
>> 
>> Nope, runs almost instantaneously.
>> 
>> What's going on?  It's nice to see my computer *not* trashed, but now
>> I'm unsure about my understanding of how parameters work.
>
> A parameterization is stored in a continuation mark. If
> continuation-mark lookup has to traverse N continuation frames to find
> a value, then it stashes the result half-way at N/2 frames away, and so
> on.
>
> The stash and a parameterization are both implemented using immutable
> hash tables, so that's where the O(log N) part shows up.

Oh ok!  That's very helpful.  I thought it was actually walking back up
frames of the stack, but I see now that was a misconception.

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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Is this parameters-using code O(n^2)?

2018-11-11 Thread Christopher Lemmer Webber
It struck me recently that I tend to think of parameters as O(1) when in
reality they're O(n), where n is the number of frames on the stack,
right?  I was considering writing some code that cons'ed itself on its
natural recursion, but in the process was checking the parameter.
But then I realized it would be O(n^2) in the sense that it's the number
of steps of the application times the number of frames on the stack...
right?

Due to that reason, I figured the following code would absolutely trash
my computer:

 (let ([limit-param (make-parameter 100)])
   (let lp ([n 1])
 (if (= n (limit-param))
 '()
 (cons n
   (lp (add1 n)
   (void)); return void just to avoid printing that all out

Nope, runs almost instantaneously.

What's going on?  It's nice to see my computer *not* trashed, but now
I'm unsure about my understanding of how parameters work.

 - 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] "Dynamic-wind record doesn't match prompt!" error

2018-10-28 Thread Christopher Lemmer Webber
Awesome!

Matthew Flatt writes:

> Thanks! I've pushed a repair.
>
> At Sun, 28 Oct 2018 15:24:27 -0400, Sam Tobin-Hochstadt wrote:
>> Since the dynamic wind error is definitely a Racket bug, I reproduced
>> it in a single file and opened an issue here:
>> https://github.com/racket/racket/issues/2341
>> 
>> I haven't gotten an error in RacketCS yet, but it is about 2x slower
>> than on traditional Racket.
>> 
>> Sam
>> On Sun, Oct 28, 2018 at 2:05 PM Christopher Lemmer Webber
>>  wrote:
>> >
>> > Christopher Lemmer Webber writes:
>> >
>> > > Matthew Flatt writes:
>> > >
>> > >> Is your example something I can run myself to track down the problem?
>> > >> The trigger for these kinds of bugs is often difficult to extract into
>> > >> a small example.
>> > >
>> > > It is, but there's currently another bug intertwined which is causing
>> > > memory exhaustion in this same case.  I don't think they're interrelated
>> > > anymore, but let me fix that one so you can see the problem in isolation
>> > > without blowing through your RAM :)
>> > >
>> > > I'll try to clean it up today/tomorrow and will respond with an example
>> > > you can run once I've done so.
>> >
>> > So I actually didn't get rid of the memory exhaustion problem, but I
>> > *did* get rid of the "Dynamic-wind record doesn't match prompt!" error.
>> > I'm not sure exactly how the "fix" fixed it though, I mostly moved the
>> > code shape closer to the shape it was previously before the error
>> > happened.
>> >
>> > To reproduce, clone goblins:
>> >   https://gitlab.com/spritely/goblins.git
>> >
>> > Now check out the commit 1db58e8, which is the v0.1 release
>> >
>> > Now follow the instructions on the top of:
>> >   https://gitlab.com/spritely/goblins/issues/8
>> >
>> > (the second code block there has some code you can run yourself to
>> > reproduce the bug.)
>> >
>> > More about the "fix":
>> > https://gitlab.com/spritely/goblins/issues/8#note_112548932
>> >
>> > Note that I still am hitting problems, but they aren't this problem:
>> >  - Still have the memory leak.  It's very hard for me to figure out
>> >why references to the promises, promise resolvers, and listeners
>> >are not being cleaned up.
>> >  - A couple of the fixes I've tried have managed to segfault Racket...
>> >one crashed the GC.  I guess those might be of interest.
>> >
>> > I didn't have these problems before I moved to the promise-based
>> > architecture I'm now using.  There's a lot more allocation of
>> > intermediate actors powering things now, and I'm okay with some
>> > performance tradeoff if it means a cleaner design, but I should probably
>> > sort out the leaks and crashes :)
>> >
>> >  - 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.
>> > For more options, visit https://groups.google.com/d/optout.
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] "Dynamic-wind record doesn't match prompt!" error

2018-10-28 Thread Christopher Lemmer Webber
Ah, this is great!  I'm glad to see my code being simplified and put to
good use to identify it.

Sam Tobin-Hochstadt writes:

> Since the dynamic wind error is definitely a Racket bug, I reproduced
> it in a single file and opened an issue here:
> https://github.com/racket/racket/issues/2341
>
> I haven't gotten an error in RacketCS yet, but it is about 2x slower
> than on traditional Racket.
>
> Sam
> On Sun, Oct 28, 2018 at 2:05 PM Christopher Lemmer Webber
>  wrote:
>>
>> Christopher Lemmer Webber writes:
>>
>> > Matthew Flatt writes:
>> >
>> >> Is your example something I can run myself to track down the problem?
>> >> The trigger for these kinds of bugs is often difficult to extract into
>> >> a small example.
>> >
>> > It is, but there's currently another bug intertwined which is causing
>> > memory exhaustion in this same case.  I don't think they're interrelated
>> > anymore, but let me fix that one so you can see the problem in isolation
>> > without blowing through your RAM :)
>> >
>> > I'll try to clean it up today/tomorrow and will respond with an example
>> > you can run once I've done so.
>>
>> So I actually didn't get rid of the memory exhaustion problem, but I
>> *did* get rid of the "Dynamic-wind record doesn't match prompt!" error.
>> I'm not sure exactly how the "fix" fixed it though, I mostly moved the
>> code shape closer to the shape it was previously before the error
>> happened.
>>
>> To reproduce, clone goblins:
>>   https://gitlab.com/spritely/goblins.git
>>
>> Now check out the commit 1db58e8, which is the v0.1 release
>>
>> Now follow the instructions on the top of:
>>   https://gitlab.com/spritely/goblins/issues/8
>>
>> (the second code block there has some code you can run yourself to
>> reproduce the bug.)
>>
>> More about the "fix":
>> https://gitlab.com/spritely/goblins/issues/8#note_112548932
>>
>> Note that I still am hitting problems, but they aren't this problem:
>>  - Still have the memory leak.  It's very hard for me to figure out
>>why references to the promises, promise resolvers, and listeners
>>are not being cleaned up.
>>  - A couple of the fixes I've tried have managed to segfault Racket...
>>one crashed the GC.  I guess those might be of interest.
>>
>> I didn't have these problems before I moved to the promise-based
>> architecture I'm now using.  There's a lot more allocation of
>> intermediate actors powering things now, and I'm okay with some
>> performance tradeoff if it means a cleaner design, but I should probably
>> sort out the leaks and crashes :)
>>
>>  - 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.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] "Dynamic-wind record doesn't match prompt!" error

2018-10-28 Thread Christopher Lemmer Webber
Christopher Lemmer Webber writes:

> Matthew Flatt writes:
>
>> Is your example something I can run myself to track down the problem?
>> The trigger for these kinds of bugs is often difficult to extract into
>> a small example.
>
> It is, but there's currently another bug intertwined which is causing
> memory exhaustion in this same case.  I don't think they're interrelated
> anymore, but let me fix that one so you can see the problem in isolation
> without blowing through your RAM :)
>
> I'll try to clean it up today/tomorrow and will respond with an example
> you can run once I've done so.

So I actually didn't get rid of the memory exhaustion problem, but I
*did* get rid of the "Dynamic-wind record doesn't match prompt!" error.
I'm not sure exactly how the "fix" fixed it though, I mostly moved the
code shape closer to the shape it was previously before the error
happened.

To reproduce, clone goblins:
  https://gitlab.com/spritely/goblins.git

Now check out the commit 1db58e8, which is the v0.1 release

Now follow the instructions on the top of:
  https://gitlab.com/spritely/goblins/issues/8

(the second code block there has some code you can run yourself to
reproduce the bug.)

More about the "fix":
https://gitlab.com/spritely/goblins/issues/8#note_112548932

Note that I still am hitting problems, but they aren't this problem:
 - Still have the memory leak.  It's very hard for me to figure out
   why references to the promises, promise resolvers, and listeners
   are not being cleaned up.
 - A couple of the fixes I've tried have managed to segfault Racket...
   one crashed the GC.  I guess those might be of interest.

I didn't have these problems before I moved to the promise-based
architecture I'm now using.  There's a lot more allocation of
intermediate actors powering things now, and I'm okay with some
performance tradeoff if it means a cleaner design, but I should probably
sort out the leaks and crashes :)

 - 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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Goblins, and actor model library for Racket, gets its first release

2018-10-28 Thread Christopher Lemmer Webber
Hello all,

I've made the first release of Goblins (v0.1), the lightweight actor
model I'm building for Racket which will be the foundation for my future
distributed virtual worlds work in Racket.  It is *not* production
ready, consider this a pre-alpha, but you can get it from Racket's
package repository, and read the docs here:

  https://docs.racket-lang.org/goblins/

I think the docs give a pretty nice overview of what using Goblins
should "feel" like.

The long term goal of Goblins is to bring secure, distributed object
capability computation to Racket, inspired largely by the E programming
language (Goblins borrows many of its good ideas, including the promise
pipelining features).  It doesn't do distributed computation yet, but
I'm hoping to roll that out in the next couple of months.

Be aware that there are bugs.  In particular, I've hit some interesting
bugs involving delimited continuations:
  https://gitlab.com/spritely/goblins/issues/8
(I think I may be poking at some interesting internals of Racket in the
ways I'm pushing delimited continuations to their limits... recently I
even managed to segfault the GC.  I'll follow up on that stuff on the
other thread I started recently shortly.)

Anyway, I think it's an exciting foundation.  I'd love to hear feedback.

 - Chris

If you are curious about what this long term plan about building secure
virtual worlds in Racket is, I wrote a blogpost named "Spritely: towards
secure social spaces as virtual worlds":
  https://dustycloud.org/blog/spritely/

I have recently switched to working on this full time.  I don't have a
funding plan yet, but I am committed to make sure that the Spritely
project as a whole is a public good.  If you think this work is
exciting, consider supporting my work:
  https://www.patreon.com/cwebber

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] "Dynamic-wind record doesn't match prompt!" error

2018-10-24 Thread Christopher Lemmer Webber
Matthew Flatt writes:

> At Tue, 23 Oct 2018 17:24:38 -0400, Christopher Lemmer Webber wrote:
>> Somehow I'm triggering this error in Goblins.
>>
>>   ; Dynamic-wind record doesn't match prompt!
>>
>> I am doing some things with delimited continuations.  I'm guessing
>> that's related, but I'm not sure why/how one might expect to trigger
>> this error.  Any ideas?
>
> That's an internal error, so I think it must be a bug in the
> implementation of delimited continuations and `dynamic-wind`.

Ah!

> Is your example something I can run myself to track down the problem?
> The trigger for these kinds of bugs is often difficult to extract into
> a small example.

It is, but there's currently another bug intertwined which is causing
memory exhaustion in this same case.  I don't think they're interrelated
anymore, but let me fix that one so you can see the problem in isolation
without blowing through your RAM :)

I'll try to clean it up today/tomorrow and will respond with an example
you can run once I've done so.

> Meanwhile, if you're game to try RacketCS, I'd be interested to hear
> whether it behaves any differently. RacketCS has a more reliable
> implementation of delimited continuations.

Oh interesting.  I am interested in trying it, if I can get the
time... are there instructions for building it somewhere?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] "Dynamic-wind record doesn't match prompt!" error

2018-10-24 Thread Christopher Lemmer Webber
Yes I do.  Effectively I want to support message passing across
distributed & asynchronous systems which supports the appearance of
sequential code, even though it's really suspending and then waking back
up again when a response becomes available.

So running something like:

  (<<- my-actor 'some-method)

Triggers the following code, elsewhere:

  ;; ...
(define resume-data
  (call-with-composable-continuation
   (lambda (k)
 (abort-current-continuation actor-prompt-tag k to sys-method
 kws kw-args args))
   actor-prompt-tag))
  ;; ...

So this is during a message send where we want our code to suspend, but
then when the other actor sends a response, this code is woken back up
again.

You can see more here:
  
https://gitlab.com/spritely/goblins/blob/eff201e93bc01e73baef160cfa798e993dddc73b/goblins/actors.rkt#L127
  
https://gitlab.com/spritely/goblins/blob/eff201e93bc01e73baef160cfa798e993dddc73b/goblins/actors.rkt#L338

Linked to a specific commit, as some of that code is about to go through
overhaul.

Matthias Felleisen writes:

> Do you manipulate delimited continuations with explicit prompts somewhere?
>
>
>> On Oct 23, 2018, at 7:38 PM, Christopher Lemmer Webber 
>>  wrote:
>>
>> Christopher Lemmer Webber writes:
>>
>>> Christopher Lemmer Webber writes:
>>>
>>>> Somehow I'm triggering this error in Goblins.
>>>>
>>>>  ; Dynamic-wind record doesn't match prompt!
>>>>
>>>> I am doing some things with delimited continuations.  I'm guessing
>>>> that's related, but I'm not sure why/how one might expect to trigger
>>>> this error.  Any ideas?
>>>>
>>>> Thoughts?
>>>> - Chris
>>>
>>> Hm okay, my code is making things run out of memory I think and that's
>>> causing weird errors :)
>>>
>>> I'll try to figure out the source of that.
>>
>> Never mind, it's still happening regardless of the memory issue, but
>> inconsistently.  I'm not sure of the source of the error.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] "Dynamic-wind record doesn't match prompt!" error

2018-10-23 Thread Christopher Lemmer Webber
Christopher Lemmer Webber writes:

> Christopher Lemmer Webber writes:
>
>> Somehow I'm triggering this error in Goblins.
>>
>>   ; Dynamic-wind record doesn't match prompt!
>>
>> I am doing some things with delimited continuations.  I'm guessing
>> that's related, but I'm not sure why/how one might expect to trigger
>> this error.  Any ideas?
>>
>> Thoughts?
>>  - Chris
>
> Hm okay, my code is making things run out of memory I think and that's
> causing weird errors :)
>
> I'll try to figure out the source of that.

Never mind, it's still happening regardless of the memory issue, but
inconsistently.  I'm not sure of the source of the error.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] "Dynamic-wind record doesn't match prompt!" error

2018-10-23 Thread Christopher Lemmer Webber
Christopher Lemmer Webber writes:

> Somehow I'm triggering this error in Goblins.
>
>   ; Dynamic-wind record doesn't match prompt!
>
> I am doing some things with delimited continuations.  I'm guessing
> that's related, but I'm not sure why/how one might expect to trigger
> this error.  Any ideas?
>
> Thoughts?
>  - Chris

Hm okay, my code is making things run out of memory I think and that's
causing weird errors :)

I'll try to figure out the source of that.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] "Dynamic-wind record doesn't match prompt!" error

2018-10-23 Thread Christopher Lemmer Webber
Somehow I'm triggering this error in Goblins.

  ; Dynamic-wind record doesn't match prompt!

I am doing some things with delimited continuations.  I'm guessing
that's related, but I'm not sure why/how one might expect to trigger
this error.  Any ideas?

Thoughts?
 - 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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Should #; comments be colored as comments or code in Dr Racket?

2018-10-08 Thread Christopher Lemmer Webber
It sounds nice, but I wonder if it would be hard to shift consistently
in the right direction for both light and dark themes...

I guess if the code's opacity was reduced that could be a universal
solution.

Matthias Felleisen writes:

> +1
>
>
>> On Oct 8, 2018, at 11:57 AM, Sam Tobin-Hochstadt  
>> wrote:
>>
>> A suggestion: what if #; comments used the code coloring, but shifted
>> somewhat, or grayscaled, or something along those lines?
>>
>> Sam
>> On Mon, Oct 8, 2018 at 11:56 AM Matthias Felleisen
>>  wrote:
>>>
>>>
 On Oct 8, 2018, at 11:44 AM, Greg Hendershott  
 wrote:

 p.s.

 On Mon, Oct 8, 2018 at 11:41 AM Greg Hendershott
  wrote:
> Another use case (that Mattias might not love) is somewhere for "usage

 Apologies for the typo, Matthias!
>>>
>>>
>>> No worries.
>>>
>>> And for the record, I also use #; for commenting out examples
>>> also when I work thru them. But I still feel code style is good
>>> for those.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to racket-users+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Should #; comments be colored as comments or code in Dr Racket?

2018-10-07 Thread Christopher Lemmer Webber
Daniel Prager writes:

> If only there was a way to have the best of both worlds.
>
> E.g. change the background color for #; to something reminiscent of the
> foreground color of regular comments:
>
> (display #|Comment|#
>  ; comment
>  #;(string-join "comm" "ent")
>  "Hello world")
>
> Or perhaps something like the emacs rainbow-parens that Christopher
> mentioned could help.
>
> Dan

Yeah, and to be clear, no rainbows required: just make the text
comment-colored and the parentheses normal-delimeter-color, for whatever
that happens to be in your editor.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Should #; comments be colored as comments or code in Dr Racket?

2018-10-07 Thread Christopher Lemmer Webber
I agree that they should be shown as comments.

In many ways I like what happens (probably unintentionally) in my emacs
setup: I have rainbow-delimeters enabled, which colors the parentheses.
When I comment out the s-exp with #; the sexp looks commented out, but
the parentheses remain colored.  While an accident, that may be the
optimal behavior: it shows that it's commented out, but indicates
something about the sexp grouping being *structurally* commented out,
as opposed to a line or block comment.

But barring that, they should just render as comments :)

Daniel Prager writes:

> I find the #; construct very convenient for commenting out sexps, but in Dr
> Racket the visual cue of switching to comment-color is missing.
>
> Example (in Racket 6.12):
>
> [image: Screen Shot 2018-10-07 at 10.19.09 pm.png]
>
> Expected:
>
> *#lang racket*
>
> (display #|Comment|#
>  ; comment
>  #;(string-join "comm" "ent")
>  "Hello world")
>
>
> Dan

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Matrix Indexing Operations in "math/matrix"

2018-10-06 Thread Christopher Lemmer Webber
Ricardo Iglesias writes:

> Good afternoon. I'm trying to move away from things like Matlab and SciPy 
> to do linear algebra work. 
> Something I notice I do a lot is indexing operations, such as 
> MATRIX[ row ] [ column ]
>
> I'm looking at the "math/matrix" library provided here: 
> https://docs.racket-lang.org/math/matrices.html, and don't see anything of 
> this sort; I only see things like 
> (matrix-map-rows) 
>
> and 
> (matrix-map-cols)
>
> Being able to access and modify a particular entry in the matrix would be 
> very useful in specifying operations to matrices. For example, given a 
> matrix *G*, one might want to perform indexing operations to get the matrix 
> attached. 
>
> Is this possible with the math/matrix library? 
>
> Additionally, would there be a way to implement a version of 
> matrix-map-row/cols that uses an index? 

Not quite what you're asking, but someone at RacketCon suggested to me
that maybe we should get GNU Scientific Library bindings added to
Racket, so we can better compete with Python and R for scientific /
statistical work...

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] colon keywords

2018-09-19 Thread Christopher Lemmer Webber
I am wary of this.  I really don't have a strong preference either way,
my suspicion is it's mostly "what did you become famliar with initially"
kind of thing.  :keyword is more Common Lisp'ish, #:keyword matches
other Schemes I've used.

But:
 - I'd rather not have *two* keyword syntaxes in Racket at the same
   time.
 - But removing #: from the language would break tons of packages.
 - Maybe if #lang racket2 ever happened that would be a good place for
   this, and the ability to have multiple #langs allows us to survive
   an upgrade easier than say, the Python 2 to 3 upgrade was (which I
   was in the trenches for, and was a decade long headache).
   Let's try to avoid breaking things that exist currently, anyway.
 - It's such a small cosmetic change I don't see why it's worth it.
   If it bothers you a lot, there's a #lang path.

My $.02,
 - cwebb

Neil Van Dyke writes:

> I recall multiple discussions about colon keywords over the many
> years, but (it's 5am) temporarily forgot that Jay did a poll 3 years
> ago.
>
> Jay's results summary quoted and linked below.
>
> I think 3 years means it's time to go from these results, to either
> changing Racket, or expecting "preference #langs" to become more of a
> thing. (Again, from a software engineering perspective, I'd
> discourage "preference #langs"; but, from a love of programming
> perspective, I'd understand.)
>
>
> Jay McCarthy  wrote on Thu, 22 Oct 2015 13:43:50 -0400:
>> It has been a little more than a week and we've stopped getting results.
>>
>> The full results should be publicly available. Here is a summary:
>>
>> https://docs.google.com/forms/d/1HSwtxLhz5HWGMJjMXaO8LQyHJsdMkGbBlRa4fU7Sa34/viewanalytics
>>
>> and here is the raw data:
>>
>> https://docs.google.com/spreadsheets/d/1rZNNGwupMZTybxKRhukLdgA8VIA8oPlQ7nPk8Gv52Es/edit#gid=348615477
>>
>> My interpretation of the data is as follows:
>> - The #:keyword syntax is liked fine with a rating of 5.67
>> - The :keyword syntax is more loved with a rating of 6.9
>> - But change is not popular, average of 5.1 with high standard deviation
>> - People that really like #:keyword do not want a change and do not
>> like :keyword
>> - People that really like :keyword want a change
>>
>> I am genuinely surprised :keyword saw so much support and that
>> change was so attractive to people.
>>
>> Naturally whenever you do stuff like this, you want to ask more
>> questions, like what about keyword:, what about supporting both,
>> etc.
>>
>> Jay
> https://groups.google.com/d/msg/racket-users/3vOTC1FbieA/UsifvfWtBgAJ

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sealers/unsealers in Racket (Re: [racket-users] Questions about module encapsulation guarantees)

2018-09-10 Thread Christopher Lemmer Webber
Good call, I'll be careful about that in future examples.

David Storrs writes:

> This is a very cool thing, but may I suggest choosing a different name than
> 'can'?  '(can-unseal lunch)' reads less like a verb and more like a
> predicate where someone forgot the '?' -- "Are you able to unseal lunch?"
> as opposed to "Unseal my lunch now".
>
> On Mon, Sep 10, 2018 at 11:09 AM, Christopher Lemmer Webber <
> cweb...@dustycloud.org> wrote:
>
>> Jack Firth writes:
>>
>> > If I make a symbol with `gensym` (or do anything else that creates a new
>> > value that's not `eq?` to any other value) in some module, what are the
>> > absolute upper limits on my ability to use that symbol within the module
>> > without allowing any other modules to get ahold of the symbol? What do
>> code
>> > inspectors, namespaces, sandboxes, eval, `unsafe` APIs, the FFI, etc.
>> make
>> > possible for malicious code in external modules?
>> >
>> > Context: I'm exploring a "contract witness" idea whose implementation
>> > currently relies on the eq?-ness of opaque struct instances for security.
>> > But I vaguely recall hearing once that the The Only Way To Be Sure when
>> it
>> > comes to struct encapsulation is to put the definition of a struct
>> inside a
>> > lambda, otherwise some sort of nebulous "bad things" are possible in
>> > external code that wants to break the invariants of  a struct type.
>>
>> Struct inside a function is certainly a way to do it.  You may be
>> interested in the idea of sealer/unsealer pairs from the object
>> capability world.  I borrowed the implementation of this from Jonathan
>> Rees' W7 code.  Consider this waived into the public domain, under CC0,
>> but also with any potential patents waived under the same terms.
>>
>> Imagine the ability to make a magical canning kit and a can opener,
>> where the cans produced can only be opened by the respective can opener.
>>
>>   ; Create a new sealer / unsealer pair and sealed? predicate
>>   ; sealer-name is optional and just for debugging help
>>   (define (new-seal [sealer-name #f])
>> (define struct-name
>>   (if sealer-name
>>   (string->symbol (string-append "sealed-by-" (symbol->string
>> sealer-name)))
>>   'sealed))
>> (define-values (struct:seal seal sealed? seal-ref seal-set!)
>>   (make-struct-type struct-name #f 1 0))
>> (define unseal
>>   (make-struct-field-accessor seal-ref 0))
>> (values seal unseal sealed?))
>>
>> Now let's try using it:
>>
>>   (define-values (can-sealer can-unseal can-seal?)
>> (new-seal 'canning-factory))
>>
>> The traditional ocap example is to seal tuna, but I'm vegetarian.
>>
>>   (define lunch (seal "chickpea salad"))
>>
>>   lunch ; #
>>
>> I'm in control of the sealer from my little canning factory, I don't
>> give it to anyone else.  Only someone with the matching unsealer can
>> open this can.  I can safely put it in the fridge.
>>
>> I can make sure this can is my lunch, in case I forgot:
>>
>>   (can-sealed? lunch) ; #t
>>
>> And I can get to its contents:
>>
>>   (can-unseal lunch) ; "chickpea salad"
>>
>> Not that this looks a lot like decryption, but with lexical scope only.
>> It's possible I am okay with someone else opening my objects, in which
>> case I might give them the can-sealed? predicate and the can-unseal
>> procedure... then they can open it, but be sure it's from me.  And
>> with that you can more or less implement signatures.
>>
>> BTW, you can do powerful stuff with this... here's an example where
>> you implement digital money:
>>
>>   http://erights.org/elib/capability/ode/ode-capabilities.html
>>
>> Here's the same example from that article, written in Racket code:
>>
>>   (define (make-mint name)
>> (define-values (sealer unsealer sealed?)
>>   (new-seal name))
>> (define/contract mint%
>>   (class/c [make-purse (->m nonnegative-integer? any/c)])
>>   (class* object% (writable<%>)
>> (super-new)
>> (define/public (custom-display p)
>>   (display (format "#<~a mint>" name) p))
>> (define/public (custom-write p)
>>   (custom-display p))
>>
>> (define this-mint this)
>> (define/public (make-purse balance)
>>   (define/contract (decr amount

Re: Sealers/unsealers in Racket (Re: [racket-users] Questions about module encapsulation guarantees)

2018-09-10 Thread Christopher Lemmer Webber
Matthias Felleisen writes:

>> On Sep 10, 2018, at 10:09 AM, Christopher Lemmer Webber 
>>  wrote:
>>
>> Jack Firth writes:
>>
>>> If I make a symbol with `gensym` (or do anything else that creates a new
>>> value that's not `eq?` to any other value) in some module, what are the
>>> absolute upper limits on my ability to use that symbol within the module
>>> without allowing any other modules to get ahold of the symbol? What do code
>>> inspectors, namespaces, sandboxes, eval, `unsafe` APIs, the FFI, etc. make
>>> possible for malicious code in external modules?
>>>
>>> Context: I'm exploring a "contract witness" idea whose implementation
>>> currently relies on the eq?-ness of opaque struct instances for security.
>>> But I vaguely recall hearing once that the The Only Way To Be Sure when it
>>> comes to struct encapsulation is to put the definition of a struct inside a
>>> lambda, otherwise some sort of nebulous "bad things" are possible in
>>> external code that wants to break the invariants of  a struct type.
>>
>> Struct inside a function is certainly a way to do it.  You may be
>> interested in the idea of sealer/unsealer pairs from the object
>> capability world.  I borrowed the implementation of this from Jonathan
>> Rees' W7 code.  Consider this waived into the public domain, under CC0,
>> but also with any potential patents waived under the same terms.
>
> Does this really differ from Jim Morris’s sealing?

Not only does it not differ, it's cited on the page... this is just
an implementation :)

>From http://erights.org/elib/capability/ode/ode-capabilities.html :

> Two common forms of rights amplification are sibling communication
> [Hardy, Gosling96, Shalit96] and sealer/unsealer pairs [Morris73,
> Miller87, Tribble95 Appendix D, Rees96]. E primitively provides
> sealer/unsealer pairs. The money example below builds sibling
> communication from sealer/unsealer pairs.

which links to:

  http://www.erights.org/history/morris73.pdf

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Sealers/unsealers in Racket (Re: [racket-users] Questions about module encapsulation guarantees)

2018-09-10 Thread Christopher Lemmer Webber
Jack Firth writes:

> If I make a symbol with `gensym` (or do anything else that creates a new
> value that's not `eq?` to any other value) in some module, what are the
> absolute upper limits on my ability to use that symbol within the module
> without allowing any other modules to get ahold of the symbol? What do code
> inspectors, namespaces, sandboxes, eval, `unsafe` APIs, the FFI, etc. make
> possible for malicious code in external modules?
>
> Context: I'm exploring a "contract witness" idea whose implementation
> currently relies on the eq?-ness of opaque struct instances for security.
> But I vaguely recall hearing once that the The Only Way To Be Sure when it
> comes to struct encapsulation is to put the definition of a struct inside a
> lambda, otherwise some sort of nebulous "bad things" are possible in
> external code that wants to break the invariants of  a struct type.

Struct inside a function is certainly a way to do it.  You may be
interested in the idea of sealer/unsealer pairs from the object
capability world.  I borrowed the implementation of this from Jonathan
Rees' W7 code.  Consider this waived into the public domain, under CC0,
but also with any potential patents waived under the same terms.

Imagine the ability to make a magical canning kit and a can opener,
where the cans produced can only be opened by the respective can opener.

  ; Create a new sealer / unsealer pair and sealed? predicate
  ; sealer-name is optional and just for debugging help
  (define (new-seal [sealer-name #f])
(define struct-name
  (if sealer-name
  (string->symbol (string-append "sealed-by-" (symbol->string 
sealer-name)))
  'sealed))
(define-values (struct:seal seal sealed? seal-ref seal-set!)
  (make-struct-type struct-name #f 1 0))
(define unseal
  (make-struct-field-accessor seal-ref 0))
(values seal unseal sealed?))

Now let's try using it:

  (define-values (can-sealer can-unseal can-seal?)
(new-seal 'canning-factory))

The traditional ocap example is to seal tuna, but I'm vegetarian.

  (define lunch (seal "chickpea salad"))

  lunch ; #

I'm in control of the sealer from my little canning factory, I don't
give it to anyone else.  Only someone with the matching unsealer can
open this can.  I can safely put it in the fridge.

I can make sure this can is my lunch, in case I forgot:

  (can-sealed? lunch) ; #t

And I can get to its contents:

  (can-unseal lunch) ; "chickpea salad"

Not that this looks a lot like decryption, but with lexical scope only.
It's possible I am okay with someone else opening my objects, in which
case I might give them the can-sealed? predicate and the can-unseal
procedure... then they can open it, but be sure it's from me.  And
with that you can more or less implement signatures.

BTW, you can do powerful stuff with this... here's an example where
you implement digital money:

  http://erights.org/elib/capability/ode/ode-capabilities.html

Here's the same example from that article, written in Racket code:

  (define (make-mint name)
(define-values (sealer unsealer sealed?)
  (new-seal name))
(define/contract mint%
  (class/c [make-purse (->m nonnegative-integer? any/c)])
  (class* object% (writable<%>)
(super-new)
(define/public (custom-display p)
  (display (format "#<~a mint>" name) p))
(define/public (custom-write p)
  (custom-display p))

(define this-mint this)
(define/public (make-purse balance)
  (define/contract (decr amount)
(-> (and/c (>=/c 0)
   (lambda (amt)
 (<= amt balance)))
void?)
(set! balance (- balance amount)))
  (define/contract purse%
(class/c [get-balance (->m integer?)]
 [deposit (->m integer? any/c void?)])
(class* object% (writable<%>)
  (super-new)
  
  (define/public (custom-display p)
(display (format "#" balance name) p))
  (define/public (custom-write p)
(custom-display p))

  (define/public (get-balance)
balance)
  (define/public (sprout)
(send this-mint make-purse 0))
  (define/public (get-decr)
(sealer decr))

  (define/public (deposit amount src)
((unsealer (send src get-decr)) amount)
(set! balance (+ balance amount))
(void
  (new purse%
(new mint%))

  (module+ test
(define carol-mint
  (make-mint 'Carol))
(define alice-main-purse
  (send carol-mint make-purse 1000))

(define bob
  (new
   (class object%
 (super-new)
 (define bob-main-purse
   (send carol-mint make-purse 0))
 (define/public (go-on-ride payment)
   (send bob-main-purse deposit 10 payment)
   (displayln 

[racket-users] Re: [racket-dev] (eighth RacketCon) Warp demo

2018-09-03 Thread Christopher Lemmer Webber
David Vanderson writes:

> On Sat, Sep 1, 2018 at 7:02 PM Christopher Lemmer Webber
>  wrote:
>>
>> I checked it out.  Very cool!  Did you ever play Subspace / Continuum?
>> Reminds me a lot of it.  There's more detail here than I initially
>> realized between the different roles of the ships and etc.
>>
>> My only complaint would be that the ships I tried so far were slower
>> than I expected!  I guess most of the fighting is about team strategy
>> rather than fast paced shooting/manuvering?
>>
>> Looking forward to playing this at racketcon!
>
> Great!  Good to hear it!  I'm not sure about Subspace, but I think
> I've played it or something similar.  Warp is more inspired by a game
> called Artemis.
>
> You're right - it's intended to be slower-paced with an emphasis on
> player coordination and planning vs. twitch action.  That said, I'm
> sure I have a long way to go regarding game feel and balancing, and
> I'm hoping to get good feedback like this.  Thanks!
>
> Dave

Maybe it would make sense to add some "fast but fragile" type fighter
ships to the mix?  There are already quite a few "heavy but powerful"
ships, so balancing it out could lead to some good choices for players
to coordinate which actions they'd like to do.

BTW, some videos of Subspace/Continuum... has a lot of good ideas you
may consider borrowing:

  https://www.youtube.com/watch?v=E9W4jJGQU_E (the general "vanilla"
fighting game)
  https://www.youtube.com/watch?v=CwkVrxYZvEE ("Trench Wars", by far the
most popular mod of Subspace, was a team strategy "hold the base"
type game)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Security of continuation web server?

2018-09-03 Thread Christopher Lemmer Webber
Philip McGrath writes:

> My understanding is that continuation URIs are not intended to be
> secret/protected by default, just as a URI like
> https://example.com/comment/confirm?post-id=12345=My+great+comment
> doesn't include any security measures. The main way to add security to the
> URIs, as I understand it, it through the "stuffer" interface. Using
> `HMAC-SHA1-stuffer` (
> http://docs.racket-lang.org/web-server/stateless.html#%28def._%28%28lib._web-server%2Fstuffers%2Fhmac-sha1..rkt%29._.H.M.A.C-.S.H.A1-stuffer%29%29)
> signs the continuation URI to prevent tampering with the contents of the
> represented continuation, and functions like `hash-stuffer` could be used
> to create a stuffer that prevents end-users from inspecting the contents,
> though I haven't needed to do this.

Ah!  OK, I hadn't seen this.  This seems like a good solution.

> I haven't tried to use "stuffers" to enforce authentication or
> authorization requirements, though it might be a good idea. When I've
> needed authentication, I've taken inspiration from the
> web-server/dispatchers/dispatch-passwords module (
> http://docs.racket-lang.org/web-server-internal/dispatch-passwords.html),
> which implements HTTP basic authentication with a function that wraps a
> dispatcher. Because the UX for basic auth is not great for end-users, I've
> made somewhat analogous dispatcher-wrappers based on the
> web-server/http/id-cookie library (
> http://docs.racket-lang.org/web-server/http.html#%28part._id-cookie%29).
>
> I am very eager to hear other people's approaches, though, or flaws in what
> I've been doing! I've used #lang web-server in several projects, most
> extensively Digital Ricoeur (https://digitalricoeur.org/), and I've found
> it an absolute delight to work with, especially coming from a CGI
> background and having spent way too much time doing what I now realize was
> manually serializing continuations. Really the only drawback is that the
> community is small, which at times makes it hard to get a sense of best
> practices. Most of my #lang web-server code isn't public yet, but I'd love
> to factor out reusable parts and try to lower the barriers to entry for
> others.
>
> -Philip

Cool.  Thanks for your feedback.  I'm happy to hear you had such a good
experience.  Racket's web server tools do seem indeed quite cool.

It looks like the flexibility of the manager/stuffer systems are
probably good enough that I can achieve what I want while keeping it
secure enough (well, within the range of what's possible given the
leakiness of security on the modern web).

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   >