krismicinski
2020-1-31 15:08:46

thanks for the perspective, @soegaard2


krismicinski
2020-1-31 17:02:04

This is an interesting thread to read. It actually brings up an interesting philosophical question: to what extent should we change our programming style to allow abstractions that could enable better optimizations


krismicinski
2020-1-31 17:02:40

I think the reason I feel weird about it is that multiple return values do not feel very structural in the language. And I do not like it when my language requires me to work with something that doesn’t feel structural in the same way as I could do with (say) an s-expression.


krismicinski
2020-1-31 17:03:03

My personal take on this is that we should just use lists and have powerful static analyses that can detect idioms like multiple return values and optimize them


krismicinski
2020-1-31 17:04:05

if the concern is over expressivity or style, I think I prefer @notjack’s suggestion, although maybe if I really wanted to go all the way I’d define my own piece of syntax for this via a macro, however, I’d like to clarify that I think there are two orthogonal problems here: one of expressivity and one of optimization hints. I am much more sympathetic to the first goal than the second.


soegaard2
2020-1-31 17:27:38

(define-values (qutient remainder) (integer-division 13 5))


soegaard2
2020-1-31 17:28:22

What’s not clear?! :stuck_out_tongue_winking_eye:


notjack
2020-1-31 18:51:00

The error message of this: (define result (integer-division 13 5))


krismicinski
2020-1-31 19:07:26

@soegaard2 honest answer is that I mostly try to avoid defines and prefer matches, so having to use define-values feels a bit kludgey because it forces me to use define


krismicinski
2020-1-31 19:07:43

also, define-values just feels a bit special and inconsistent for something like this.


krismicinski
2020-1-31 19:07:53

but I don’t think it’s bad, per-se.


soegaard2
2020-1-31 19:07:59

You are in luck. There is a match-values :slightly_smiling_face:


krismicinski
2020-1-31 19:08:13

I actually did not know about that, and maybe it would make me change my opinion :slightly_smiling_face:


soegaard2
2020-1-31 19:08:41

I see your point though - most contexts expect a single value to be returned.


notjack
2020-1-31 20:06:47

@krismicinski Do you use match-define?


slack1
2020-2-1 03:49:55

This might be an ill-formed question but does Racket have “reference” types?


slack1
2020-2-1 03:51:08

Like a reference to a cell for cons, rather than the value


notjack
2020-2-1 04:19:46

@slack1 There’s box, which sounds sort of like what you want


slack1
2020-2-1 04:32:47

Is that what someone might use to pass around references when writing data structures for learning?


notjack
2020-2-1 04:56:52

Yes, I think it could work for that