sorawee
2021-6-13 07:49:00

I thought that when a thread is killed, any running system will be terminated as well. But I experimented and found that this is not the case… Hmm.


laurent.orseau
2021-6-13 08:39:53

But call-with-limits does kill them?


soegaard2
2021-6-13 09:52:21

Pre- or post increment? (define a 2) (define b (++ a)) (list a b) Do you feel pre or post increment is the most natural?

The expression (++ a) adds 1 to a and stores it in a. At the same time the result of (++ a) can be the value of a before or after.

I.e. should the result be (3 2) or (3 3)


laurent.orseau
2021-6-13 10:02:59

Personally I prefer to return the new value


laurent.orseau
2021-6-13 10:03:06

I find it more intuitive


laurent.orseau
2021-6-13 10:06:18

But i even prefer to not return a value at all


sschwarzer
2021-6-13 10:07:31

Or that. In any case mutating and returning can be confusing.


sschwarzer
2021-6-13 10:08:14

If ++ “only” returned a value, it would be the same as add1 though, right?


sschwarzer
2021-6-13 10:09:48

And a mutating ++ would be add1! :wink:


soegaard2
2021-6-13 10:53:17

Thanks - I hope to hear more opinions.


laurent.orseau
2021-6-13 12:11:19

Make it a poll! Say (++ a) expands to (set! a (+ 1 a)), would you prefer it to [1] also return the new value of a , [2] also return the old value of a, [3] return (void), [4] something else explained in the comments.


spdegabrielle
2021-6-13 12:22:41

I voted return #<void> because that is consistent with set!


laurent.orseau
2021-6-13 12:23:20

That’s option [3], not [4] :slightly_smiling_face:


spdegabrielle
2021-6-13 12:25:05

Derp! fixed


jagen315
2021-6-13 13:34:39

has someone made something for applying a reader within a block


sorawee
2021-6-13 13:39:00

What do you mean by that? There’s #reader (https://docs.racket-lang.org/reference/reader.html#%28part._parse-reader%29) if that’s what you are asking for.


jagen315
2021-6-13 13:41:21

this consumes the rest of input


sorawee
2021-6-13 13:41:32

Choosing 4 because…

I would choose 3, because it’s consistent with how set! currently works.

But if Racket’s set! returns the set value, then I would choose 1, and I actually prefer this to be the case.


sorawee
2021-6-13 13:42:35

Perhaps you can give some examples?


jagen315
2021-6-13 13:49:12

(define melody #readerralda/lang/reader Clarinet: a b > c d e)


jagen315
2021-6-13 13:49:51

actually now that I think about it, there’s only so much I can do with this because read-syntax in ralda/lang/reader produces a module


sorawee
2021-6-13 13:52:57

Yeah… and I think the “consumes the rest of input” is also specific to ralda/lang/reader. A reader doesn’t necessarily need to consume everything.



jagen315
2021-6-13 13:54:57

yeah I know, I am just trying to figure out if a module reader can be used as an inline reader. which I think is not possible. not in a nice way at least


jagen315
2021-6-13 13:55:22

I would not be here if I had not read that : - )


jagen315
2021-6-13 13:57:43

I think I need a separate reader from ralda/lang/reader, which is delimited and produces an expression instead of a module


ryanc
2021-6-13 14:16:04

Thanks, I’m glad to hear it!


greg
2021-6-13 14:51:40

Well in C++ ++a returns the new value and a++ returns the old. So, I voted for 1 — and also you should customize #%app to implement the latter for (a ++)? :stuck_out_tongue:


greg
2021-6-13 14:54:55

Seriously, if it’s named ++ I think there’s no affordance and you can choose to do whatever you want, so you might as well choose the most-commonly useful thing: Return the new value. OTOH if you named it something set++! then maybe there’s the affordance it should behave like set! and return void. Opinions.


spdegabrielle
2021-6-13 15:01:45

(a ++) LOL (yes I know this is insane)


philip.mcgrath
2021-6-13 15:11:19

I think it can work out if you delimit the reader in some other way, e.g. with at-expressions. I think Jay has done something along these lines.


joel
2021-6-13 15:26:53

Has anyone made a regex or other facility for strictly validating URIs? I know about net/url-string but that module is a lot more permissive than RFC 3986. I could take a stab at converting a regex made for another language, but I’m hoping to get out of it :stuck_out_tongue:


samdphillips
2021-6-13 15:32:27

I feel like you might be able to get the right behavior using a custodian?


massung
2021-6-13 15:53:51

It’s common lisp, but I wrote this a couple years ago and it’s based off the RFC: https://github.com/massung/url/blob/master/url.lisp\|https://github.com/massung/url/blob/master/url.lisp

You want to scroll down to the lexer definition. The regex patterns are Lisa style, but should be straight forward to follow.


massung
2021-6-13 15:54:43

Anyway, if you wanted to port some of that to racket, it might fit your needs.


code
2021-6-13 17:06:52

scheme convention is to indicate mutation by ! and not return a value which always trips me up, because most ‘funtional’ programming style ‘mutation’ does return a fresh value. I do see value in following conventions


soegaard2
2021-6-13 19:00:59

I think the conclusion is, that if the choice is just between “before” and “after”, then everybody prefers “after”. And you are all correct, that ++ isn’t very Scheme/Racket-like.

I am working on implementing a version of Processing in Racket, and a subgoal for me, is to match all the base features. Porting simple Processing programs, should ideally be a matter of changing a little syntax only. Processing is basically Java+Graphics library+branding. Being Java they have both ++a and a++.

Interestingly, the Processing documentation of ++ is simply wrong. They describe a++ as being equivalent to a=a+1. And since Java is a language with both statements and expressions, this is iffy at best.

https://processing.org/reference/increment.html


soegaard2
2021-6-13 19:02:04

That said, I think the most common use of ++ in Processing programs are in for-loops, and we use in-range instead.


samth
2021-6-14 01:32:33

The thread might spawn another thread/create finalizers/etc


rokitna
2021-6-14 06:55:53

I voted other; I find myself without a prevailing opinion. Returning (void) seems the most Rackety, but I think both value-returning versions of ++ in C-like languages are relevant to lots of programmers, so maybe if either of them is available, both should be. I think Arc’s (++ a) returns the updated value, like ++a in C, but I’ve usually just ignored its result.