sorawee
2021-1-31 08:33:02

I think @laurent.orseau might be objecting to your:

(require (prefix-in + (only-in racket/base +)) ; ++ is now standard + (prefix-in * (only-in racket/base *))) ; ** is now standard * :slightly_smiling_face:


laurent.orseau
2021-1-31 09:48:22

‘Objecting’ might be a strong word, but that’s what i was referring to indeed


laurent.orseau
2021-1-31 10:24:56

You also have filtered-in which would be the right tool if you imported more operators and used the same pattern


soegaard2
2021-1-31 10:57:29

Wasn’t thinking along those lines - but I see your point. Using rename-in would signal the intent better.


laurent.orseau
2021-1-31 10:58:48

Yeah, you wouldn’t need the comment


rokitna
2021-1-31 13:13:02

Are you putting that code somewhere stable? I’d hate to see it fall off the Slack history.


soegaard2
2021-1-31 13:13:43

It’s on the mailing list, so it is in the mailing list archive.


rokitna
2021-1-31 13:14:03

oh, whew :)


laurent.orseau
2021-1-31 13:36:23

How about gist (my preference), gitlab snippets, pasterack or pastebin?


laurent.orseau
2021-1-31 13:36:48

the first two allow you to revise your code without sending a new email :wink:


laurent.orseau
2021-1-31 13:37:40

Although quite frankly, a package would be nice :slightly_smiling_face:


laurent.orseau
2021-1-31 13:41:32

It’s pretty nice to have this for structs—classes are too heavy in many cases.


laurent.orseau
2021-1-31 13:53:22

[unrelated] [compiler] Is there a rule that says something like “If a function is called only once in some other function of the same module and is not exported, inline it, even if it’s huge”?


laurent.orseau
2021-1-31 13:55:17

Or am I missing cases where this can still blow up memory usage?


mflatt
2021-1-31 13:56:17

There’s a rule like that for locally bound functions. At the module level, though, everything ends up being exported, in a sense, by module->namespace.

Well, you can use (#%declare #:empty-namespace) and avoid exporting macros, and then probably the compiler could be made to treat a definition as unexported, but I don’t think that happens right now.


laurent.orseau
2021-1-31 14:00:56

> There’s a rule like that for locally bound functions. Good to know, and pretty cool!

> At the module level, though, everything ends up being exported, in a sense, by module->namespace. Ow, that’s too bad. So this encourages local single-usage functions rather than module-scope single-usage functions.

Thanks


soegaard2
2021-1-31 14:01:58

Wouldn’t define-inline be enough in this situation?


greg
2021-1-31 14:03:43

Speaking of continuation marks (at least we were a couple days ago, maybe in #beginners) I don’t understand the comment here in errortrace-lib/errortrace-key.rkt: ;; Defining `errortrace-key' as a function is a performance hack: ;; the compiler can track function constants, and in particular the ;; fact that it's not an impersonated/chaperoned mark key, so that a ;; `with-continuation-mark' using this key can be dropped if the ;; body expression is simple. (define-values (errortrace-key) (lambda () 'anything))


laurent.orseau
2021-1-31 14:04:27

I’d rather avoid giving hints to the compiler if possible


greg
2021-1-31 14:06:21

I don’t understand why signalling the key is a constant function has anything to do with the body expression being “simple”. That seems apples and oranges?


greg
2021-1-31 14:06:54

Also I’m surprised that a with-continuation-mark could be “dropped”, ever, because of the key or value or body expression or whatever being “simple” enough.


greg
2021-1-31 14:07:06

I feel like I’m missing something really basic here.


soegaard2
2021-1-31 14:09:48

Maybe down the line. This was just an experiment. More polishing is needed for a package.


mflatt
2021-1-31 14:11:15

The expression (with-continuation-mark E1 E2 E3) is equivalent to (begin E1 E2 E3) if E3 is simple in the sense that it never inspects continuation marks and you can’t somehow interrupt the thread and be sure that it is currently in E3. In that case, no mark for the key produced by E1 needs to be set on the current continuation — at least, as long as the key isn’t chaperoned, because setting a mark for a chaperoned key is potentially observable in itself.

It happens that lambda is something that the compiler reliably recognizes as “never produces a value can can be chaperoned via chaperone-continuation-mark-key”, but it’s also sufficiently generative to work as a key.


mflatt
2021-1-31 14:17:32

… or, at least, that’s the case for the BC compiler. I see that it’s a place for improvement in the CS compiler!


greg
2021-1-31 14:24:24

Ah — that makes sense. Thanks!


greg
2021-1-31 14:32:39

So in theory errortrace-lib is relying on this to be “generous” wrapping expressions in wcm.

In theory things like DrRacket and Racket Mode that use errortrace-lib — for better stacktraces, profiling, and/or test coverage — would be at least somewhat slower in CS.

In theory. Not that I’ve noticed that at a user level, so far.


mflatt
2021-1-31 14:35:10

Roughly, yes. Errortrace is still somewhat stingy, but it only tries so hard.


greg
2021-1-31 14:35:39

Thanks again for explaining. I was really just looking to learn. I didn’t mean to create a to-do item, even a someday/maybe one! :disappointed:


mflatt
2021-1-31 14:35:56

:slightly_smiling_face:


mflatt
2021-1-31 17:21:09

It turns out that CS does recognize an identifier bound to a procedure as something other than a chaperoned key (which is the relevant case for errortrace). It just doesn’t recognize an immediate lambda form that way.



soegaard2
2021-1-31 21:16:53

@spdegabrielle For the list of “real world” applications?



spdegabrielle
2021-1-31 21:35:38

Towards a Dynamic Multiscale Personalized Information Space: Beyond application and document centered views of information Amy R. Fox, Philip Guo, Clemens Nylandsted Klokmose, Peter Dalsgaard, Arvind Satyanarayan, Haijun Xia & James D. Hollan. (2020) In Conference Companion of the 4th International Conference on the Art, Science, and Engineering of Programming (’20), March 23–26, 2020, Porto, Portugal. Proceedings of the Convivial Computing Salon at PROGRAMMING 2020. ACM, New York, NY, USA, 8 pages. https://doi.org/10.1145/3397537.3397542\|https://doi.org/10.1145/3397537.3397542


yilin.wei10
2021-1-31 21:48:41

Wow, stateless servlets are really interesting.


spdegabrielle
2021-1-31 21:52:36

Yes! I found another paper(version?) that is dated to 2020 but I’d love to date the Sony deal.


soegaard2
2021-1-31 21:53:08

That would be interesting.


spdegabrielle
2021-1-31 21:53:56

It’s also a fascinating area of research so thanks for that too!


sorawee
2021-1-31 22:00:31

@mflatt is compile-context-preservation-enabled supposed to work in Racket CS in the same way as in Racket BC?


sorawee
2021-1-31 22:00:45

Consider:

#lang racket (define (show e) (pretty-print (continuation-mark-set->context (exn-continuation-marks e)))) (with-handlers ([exn:fail? show]) (for ([x 1]) (/ 1 0)))


sorawee
2021-1-31 22:01:20

Racket BC could report the site of for-loop when compile-context-preservation-enabled is on.


sorawee
2021-1-31 22:02:16

On the other hand, Racket CS’s continuation-mark-set->context gives the same result regardless of the value of compile-context-preservation-enabled.


sorawee
2021-1-31 22:02:43

which doesn’t have the site of for-loop


soegaard2
2021-1-31 22:12:40

FWIW http://racket-stories.com\|racket-stories.com works with no state (except the database). The source is on Github, if you are interested.


mflatt
2021-1-31 22:13:39

For CS, compile-context-preservation-enabled currently disables inlining only at the schemify layer. Probably it should also disable inlining at the Chez Scheme level. I don’t know if that’s what’s going on in this example, though.


kellysmith12.21
2021-1-31 22:38:56

Is there a list of futures-friendly operations? I’ve looked in the docs, but haven’t found one.


laurent.orseau
2021-1-31 22:55:18

fl :)


mflatt
2021-1-31 23:02:33

There is no list, unfortunately. I think the practice has been to use the futures visualizer to find out which things are not futures-friendly. For CS, it’s somewhat easier to guess what is in the list, since a non-friendly operation is one that has to synchronize at the Racket thread level or inspect continuation marks (as opposed to one that happens not to be special cased in the JIT for BC).



jestarray
2021-2-1 04:39:25

is racket 8.0 going to be released tomorrow o: ?