sorawee
2021-1-29 09:18:04

I think you need to run the tokenizer


laurent.orseau
2021-1-29 09:25:04

Is it possible to (easily?) extend read-syntax to turn comments into syntax objects too?


sorawee
2021-1-29 09:29:11

I think you can do that by adjusting readtable, but I don’t think it will play well with the rest of the system.

For example, if you have (if x #\| abc \|# y z). Now if have 4 subforms. Suddenly every macro needs to take care of these comment syntax object.

What might make more sense is to attach the comment information to the enclosing syntax object’s syntax property.


laurent.orseau
2021-1-29 09:31:55

Good thinking!


marc.kaufmannmk
2021-1-29 11:32:11

Works for me. However you cannot use ,rr successfully for the first load. What I do is:

Welcome to Racket v7.9 [bc]. > ,rr foo.rkt ; requiring "foo.rkt" > ,r foo.rkt > foo 4 > foo 4 > ,rr foo.rkt ; reloading "foo.rkt" > foo 0 So first ,rr to tell the REPL that I want this file to be reloadable, then you can load it, and then reload.

I don’t know if this is the intended use, I remember being bitten by this in the past, and the documentation is not that clear. With typed racket I never got this to work the way I expected and always had to exit the REPL.


anything
2021-1-29 11:34:19

By the way, Ryan, here’s something I’m not sure your library could provide. Ethereum recovers public keys from signatures and it uses a bit-hint to eliminate an ambiguity in the public key possibilities. This bit-hint seems to come from the ephemeral private key computed by the signing process and I believe your signing process is performed by OpenSSL directly, so it seems you don’t see this ephemeral private key at the crypto-collection level. In other words, I believe you can’t expose that to the user somehow because it’s hidden by OpenSSL. That’s my impression. (I hope I’m wrong.)

When I first read https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md\|EIP-155, I had the impression this bit-hint (encoded in vby EIP–155) was computed from r in the signature. (That’s what EIP–155 says actually.) I still hope this is really the case, but looking at this <https://github.com/indutny/elliptic/blob/master/lib/elliptic/ec/index.js#L91|Javascript implementation>, I can see they are computing the recoveryParam (which is this bit-hint) from the ephemeral private key. I’m investigating all of this still. If you have any easy solutions for that too, I’d love to hear it. Thank you again!


ben.knoble
2021-1-29 11:43:36

Ah. That makes at least some sense, even if it’s awkward


anything
2021-1-29 13:24:01

Here’s the now-obvious workaround for this. Though I don’t have the y-coordinate of r (which is an x-coordinate), I have two possibilities for y: either modsqrt(r^3 + 7) or -modsqrt(r^3 + 7). So I can generate two transactions and then try to recover the public key from both. One of the transactions will give me a public key that does not match the right one (and I know the right one) and I throw the other transaction away. It is not the most efficient thing to do, of course, but I’m happy to have this solution right now. Thanks very much for your attention!


greg
2021-1-29 17:01:14

I didn’t notice this on Slack until just now — thanks!!!


samdphillips
2021-1-29 17:20:29

Yeah, almost anything with intermediate lists could probably be for-ized


samdphillips
2021-1-29 17:21:08

(I mean “could be” by a human refactorer. If a machine could do it safely even better!)


greg
2021-1-29 19:15:48

When talking about expressions in tail position, “tail position” is succinct. Is there some phrase that’s shorter than “the expression with respect to which the expression is in tail position?” :eyes:


greg
2021-1-29 19:16:06

Why I ask: I recently updated Racket Mode to show tooltips for these two things (it can’t draw arrows like DrRacket does).

I settled on showing “head” and “tail” for these two things. I think “tail” is OK but I don’t love “head”. So I’m open to suggestions!


greg
2021-1-29 19:17:27

Shorter is better because tooltips take space. Also a given position might have multiple annotations displayed. e.g. an open paren in typed/racket program might show 3 combined Number; tail; imported from typed/racket/base.


ben.knoble
2021-1-29 19:27:07

“outer” comes to mind? or “parent” maybe?


soegaard2
2021-1-29 19:31:38

Non-tail?


soegaard2
2021-1-29 19:32:43

Nope. That’s different


hectometrocuadrado
2021-1-29 19:43:37

front?


hectometrocuadrado
2021-1-29 19:44:48

top?


laurent.orseau
2021-1-29 19:45:02

‘parent’ seems fine to me


laurent.orseau
2021-1-29 19:45:15

‘enclosing’


samth
2021-1-29 19:47:37

I think “enclosing” is the best so far


sorawee
2021-1-29 20:01:31

It doesn’t need to be enclosing syntactically though, right? (with help of some insane macros)


notjack
2021-1-29 20:14:09

“enclosing” can be a feeling in your heart rather than a rigorous statement about surrounding source code


badkins
2021-1-29 20:24:34

@notjack like a hug?


notjack
2021-1-29 20:24:48

exactly


samth
2021-1-29 20:25:12

and while @sorawee is technically correct that by using mutation you could construct something like that, it would be horrible and you shouldn’t


badkins
2021-1-29 20:25:34

I gotta say that reading, "“enclosing” can be a feeling in your heart" made my day :)


notjack
2021-1-29 21:53:20

Can I get a quick check on something? Is this code: (let ([v &lt;expr&gt;]) (or (and v &lt;expr-not-returning-false-or-referencing-v&gt;) &lt;expr-not-referencing-v&gt;)) Equivalent to this: (if &lt;expr&gt; &lt;expr-not-returning-false-or-referencing-v&gt; &lt;expr-not-referencing-v&gt;)


sorawee
2021-1-29 22:01:26

I think so. I saw a and b or c as a trick to write if somewhere, but it only works when b is not falsy.


notjack
2021-1-29 22:15:12

Hmm so maybe two separate checks then: • One that rewrites (or (and a b) c) to (if a b c) when it can prove that b is not falsey • One that inlines let expressions when the variable is only used once and doing so wouldn’t change evaluation order (though maybe this one isn’t a worthwhile idea?)


greg
2021-1-29 22:33:04

Thanks everyone! I think I’ll go with “enclosing” :people_hugging::people_hugging::people_hugging:


samth
2021-1-30 00:51:52

The second one is a potential compiler optimization but I would assume the let is there for a reason


shu--hung
2021-1-30 01:27:31

The meaning to a human could be different After all, that &lt;expr-not-returning-false-or-referencing-v&gt; won’t be false could be an inferred fact that the programmer should not need to think about


notjack
2021-1-30 01:31:55

@samth in the code I’m looking at, the reason is “this used to be scheme code and shoving let in random subexpressions was the easiest way to make variables”


notjack
2021-1-30 01:33:12

@shu—hung I was only planning on firing in cases where the expression is something like 42 or (list …) or a quoted expression, since those seem like fairly noncontroversial cases


shu--hung
2021-1-30 01:37:21

Personally, I would still treat the two as different programs and won’t apply this rule. This is because the or form expresses the intention to choose the first non-false option. The first option, in this case, is guarded by &lt;expr&gt;. And it could be that &lt;expr&gt; is not intended to be interpreted as a choice between &lt;expr-not-returning-false-or-referencing-v&gt; and &lt;expr-not-referencing-v&gt;.


shu--hung
2021-1-30 01:38:51

So there could be a logical connection between &lt;expr&gt; and &lt;expr-not-returning-false-or-referencing-v&gt; but not &lt;expr-not-referencing-v&gt;.


notjack
2021-1-30 01:46:12

I don’t think either form of the program conveys enough meaning on its own to justify one form or the other purely on programmer intent.


notjack
2021-1-30 01:46:32

The best way to declare that kind of intent is to make a helper function and put the intent in the name.


shu--hung
2021-1-30 01:49:50

Choosing the first non-false values using or is pretty idiomatic in Racket But probably each program is different


notjack
2021-1-30 02:08:33

In general yes, but for the specific case of (or (and a b) c) where b can’t be #f, I think if would be more idiomatic since there’s no way a could possibly be returned anywhere


samth
2021-1-30 02:48:30

I’m having a strange issue with http-easy: &gt; (require net/http-easy) &gt; (define chic-url "<https://raw.githubusercontent.com/Z3tt/R-Tutorials/master/ggplot2/chicago-nmmaps.csv>") &gt; (subbytes (response-body (get chic-url )) 0 50) #"city,date,death,temp,dewpoint,pm10,o3,time,season," &gt; (port-&gt;bytes (response-output (get chic-url ))) #"" I would expect those two approaches to produce the same bytes, but I always get an empty byte string when I look at response-output. @popa.bogdanp


samdphillips
2021-1-30 03:13:06

response-body drains the response output port


samdphillips
2021-1-30 03:14:32

erp. Maybe I should read more carefully that you aren’t reusing the same response twice


samdphillips
2021-1-30 03:18:53

I think you need #:stream? #t in your get call…


samdphillips
2021-1-30 03:20:23

&gt; (port-&gt;bytes (response-output (get chic-url))) #"" &gt; (subbytes (port-&gt;bytes (response-output (get chic-url #:stream? #t))) 0 50) #"city,date,death,temp,dewpoint,pm10,o3,time,season,"


samth
2021-1-30 03:50:25

Aha, thank you!


kellysmith12.21
2021-1-30 05:01:24

(Maybe I’ve asked this before; I can’t remember…) When using define-generics, is there a way to specify that a method is non-optional?


kellysmith12.21
2021-1-30 05:05:51

(Other than using contracts that check for implemented methods.)