steveh2009
2018-12-6 14:11:05

I installed the latest Elementary OS, a Linux distro, installed the latest version 6 then 7 of Racket and they both have this problem: when you exit DrRacket, the warning box to save your work only shows the X and you can’t save or even exit the DrRacket.


samth
2018-12-6 14:16:29

steveh2009
2018-12-6 14:20:07

I don’t have a github account and don’t want to open one just for this. It works on Lubuntu so I’ll stick with that.


nathaniel
2018-12-6 14:40:13

I’m familiar with HtDP and SICP. I’m trying to teach basic programming in a week to beginners. My plan is to combine the theories of education promoted by developmental psychologists like Jean Piaget with my personal experience in hackerspaces. Essentially, I want to take a day or two to walk through the basics and then help the students solve their own problems. I would like to ask if anyone else here has done anything similar and for advice on a good, short jumpstart into programming (ideally with Racket :slightly_smiling_face: ). This isn’t one of those commercial “bootcamps”, just a community project aimed at helping creative people gain technical skills they otherwise think is beyond their capacity. Advice appreciated, I’m just some guy not a professor or anything.

Even advice on key selections from HtDP or something like that would be great, I just won’t have the time to methodically work through an entire textbook. I’m tempted to just take from the introduction but I don’t have the personal history of teaching the material to know whether or not that is wise, and thought maybe someone here would have already done the work of finding a good “condensed” place to begin.


greg
2018-12-6 14:45:50

@samth To follow up from last night https://github.com/greghendershott/racket-mode/commit/8180205ef83893e2a99e40168194b6d01b8e3281 should be on MELPA soon-ish. Also if you’re patching locally note this is a different commit than what I shared last night.


samth
2018-12-6 14:46:19

@greg what do I run to upgrade from melpa?


greg
2018-12-6 14:48:43

It’s probably simplest and most reliable to do M-x package-delete and enter racket-mode, then M-x package-install, racket-mode.


samth
2018-12-6 14:49:18

is there an upgrade command if i’m feeling lucky?


greg
2018-12-6 14:49:38

Maybe as step 0 do M-x package-initialize if that’s not already in your Emacs init file.


greg
2018-12-6 14:50:27

The lucky/official way is M-x list-packages, then use its UI buffer to mark packages to upgrade, then say upgrade them.


greg
2018-12-6 14:51:21

I’m not sure that’s really easier ¯_(ツ)_/¯


greg
2018-12-6 14:51:56

At least for a package like racket-mode, on which no other packages depend


diego
2018-12-6 14:57:22

@nathaniel Not Racket-oriented, but there are many good resources at http://code.org\|code.org, both for kids and adults.


diego
2018-12-6 14:58:51

If the audience is adults with no technical expertise, maybe some of the high-school-level resources would be applicable: https://code.org/educate/curriculum/high-school


diego
2018-12-6 15:00:20

And honestly, even for adults, some of those “create your own game in 1 hour” tutorials can be quite fun :slightly_smiling_face:


nathaniel
2018-12-6 15:03:26

thanks for the advice!


diego
2018-12-6 15:15:26

Hope it helps! I’m only learning Racket myself, but have been programming for many many years. Lately I’m also interested in teaching programming, but for my two kids. I’ve used Scratch so far (http://scratch.mit.edu\|scratch.mit.edu - also interesting but more kid-oriented), I’ve been thinking of maybe using Realm of Racket.


diego
2018-12-6 15:15:57

Question: what is “SICP” (from your question)?


nathaniel
2018-12-6 15:19:06

The S tructure and I nterpretation of C omputer P rograms https://en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs


diego
2018-12-6 15:20:18

Ah! Of course :slightly_smiling_face:


diego
2018-12-6 15:29:43

Thanks.


leafac
2018-12-6 16:00:07

I just published a short article about the type of call/cc that may interest Racketeers: https://www.leafac.com/prose/understanding-the-type-of-call-cc/


leafac
2018-12-6 16:00:49

I’d love to hear what you have to say about it.


sorawee
2018-12-6 16:12:04

This is very illustrative. I really like it


leafac
2018-12-6 16:17:21

Thank you.


dario.hamidi
2018-12-6 17:52:50

I like it too; didn’t expect it to approach the topic from a type-system perspective but the types did help in the end


dario.hamidi
2018-12-6 18:10:37

Hi

I’m obviously missing something while trying to write a minimal, gracefully restarting web server.

Given this code: http://pasterack.org/pastes/85563

What I expect:

  • curl localhost:8000 prints “begin”, waits for ten seconds and then prints “end”
  • Pressing Ctrl-C in the window running the server waits until the request has been processed completely and then shuts down the server

What actually happens:

  • curl localhost:8000 waits for ten seconds and then prints “begin” and “end”
  • Pressing Ctrl-C in the window running the server immediately terminates the process

Does anybody here have an idea what I might be doing wrong?


leafac
2018-12-6 18:11:11

Thanks for reading.


samth
2018-12-6 18:13:14

@dario.hamidi my guess is that the exn:break is delivered to another thread than the one you’re catching it in


samth
2018-12-6 18:14:17

and that out is not connected to the network directly, but is a buffer


abmclin
2018-12-6 19:34:23

I enjoyed reading your article, my question is why the constraint that the type of k’s argument must be the same as the return type of call/cc’s function argument and call/cc’s return type? Racket’s call/cc doesn’t appear to have that restriction.

I understand that the motivating examples intentionally ensure that k’s argument type is the same but there’s no a prior reason for that. Shouldn’t it be possible to supply any arbitrary value we want to the k even if they cause an exception to be raised if used incorrectly in the surrounding continuation?

Won’t it make more sense to say call/cc : ((α → β) → γ) → (∪ α γ) where (∪ α γ) denotes the union of the type variables α γ?

I’m not familiar with type theory so don’t know the correct way to express the concept of typing a union of types.


sorawee
2018-12-6 20:02:06

@abmclin as I understand, it’s because traditional type systems (like Hindley–Milner) don’t support untagged union. And when we talk about types, we tend to assume that we are using this kind of type systems.


sorawee
2018-12-6 20:07:32

Untagged union is really complicated. Most programming languages that have it need it because they were not originally designed with type system in mind. Most programming languages that are designed with type system in mind usually don’t need untagged union.


abmclin
2018-12-6 20:11:36

I see that googling tells me there’s the corresponding concept of tagged union or otherwise called disjoint union or sum type. I suppose if we’re using a type system that supports tagged union then the notation would be call/cc : ((α → β) → γ) → α + γ

The question then becomes why do we assume traditional Hindley-Milner type system? Is it safe to assume that @leafac is assuming HM?


leafac
2018-12-6 20:11:44

@abmclin Your observation is correct and it’s closer to the type that call/cc has in Typed Racket. This is part of the complexity I’m trying to sweep under the rug when I say “In Typed Racket the type of call/cc is a bit more elaborate, but for reasons that are beyond the scope of this article.” This topic is already pretty complicated as it is.

@sorawee’s interpretation is correct, I wrote this with a Hindley–Milner type system in mind. These assumptions should be made more clear and I’ll revise the article accordingly.


abmclin
2018-12-6 20:11:56

I guess if the traditional type system can’t cope with tagged unions then why not use a better one? :slightly_smiling_face:


abmclin
2018-12-6 20:15:06

@leafac ok I see, I thought the topic in your article was straightforward, it didn’t seem difficult or complicated and was comprehensible except for that observation


leafac
2018-12-6 20:17:19

Thanks for reading and for the comments.


dario.hamidi
2018-12-6 20:26:48

FWIW I found this thread in the mailing list: https://groups.google.com/forum/#!searchin/racket-users/streaming$20response%7Csort:date/racket-users/fc0mRI-empE/28Q5gUopBgAJ

The important bit being:

> The reason why responses have the lambda rather than a byte string is specifically for streaming like you want. Make sure you specify the correct response size in the headers.

And indeed, specifying the “Content-Length” headers make the “begin” show up before the “end”.

That’s at least a step in the right direction


leafac
2018-12-6 21:56:19

I published a revision with: (1) an appendix addressing this concern @abmclin raised; (2) an alternative argument for k’s return type; and (3) an acknowledgements section thanking you for your contributions.


abmclin
2018-12-6 22:03:14

I like your new rewrite, it’s more satisfying in that it answers my immediate questions and points me to where I can explore more


lexi.lambda
2018-12-6 22:15:05

@mflatt I have a weak hash table containing ephemeron values, and I’ve noticed that it’s possible for a GC to collect the value inside the ephemeron after the key is passed to hash-ref but before ephemeron-value is applied, as illustrated by this program: #lang racket (define h (make-weak-hasheq)) (define (f) (define k (gensym)) (hash-set! h k (make-ephemeron k (gensym))) (ephemeron-value (begin0 (hash-ref h k) (collect-garbage) (collect-garbage) (collect-garbage)))) (f) ; => #f In my situation, I’m not using this table as a cache, so I really do need the value. I can insert a hack so that k is referenced later in the program, but this seems fragile… I don’t know which uses of k the optimizer might optimize away, so I don’t know that I can rely on that working. Is there a proper way to ensure that hash-ref + ephemeron-value is somehow atomic with respect to the reachability of k?


mflatt
2018-12-6 22:18:26

Why not (define (f) (define k (gensym)) (let ([v (gensym)]) (hash-set! h k (make-ephemeron k v)) v)) ?


lexi.lambda
2018-12-6 22:19:11

In my real program, the part of the program writing the value is not the same part reading the value.


samth
2018-12-6 22:19:39

@jeapostrophe I have a student who created the “r-linq” package on http://pkgs.racket-lang.org\|pkgs.racket-lang.org but then deleted it, and it wasn’t deleted but now is in a weird state where it has no author but still exists.


samth
2018-12-6 22:20:08

Also, it seems like the “Create new package” interface no longer adds .git which causes things to break.


mflatt
2018-12-6 22:26:26

That’s interesting problem. The ffi/unsafe library provides void/reference-sink to reliably retain a reference, but it’s in ffi/unsafe because I’ve never seen a need outside of unsafe code. Passing k as the second argument to ephemeron-value fundamentally also has to work, and maybe that should be a designated pattern.


mflatt
2018-12-6 22:29:29

And now that you point it out, probably wrap-key in “racket/private/custom-hash.rkt” should use that pattern. Or maybe that’s already the code that you’re looking at.


lexi.lambda
2018-12-6 22:30:00

That was not the code I was looking at, as it happens, but that sounds right. :) I will use that pattern, then.