popa.bogdanp
2019-12-14 09:09:31

Does the GUI code predate multiple return values? I see a lot of uses of boxes to facilitate multiple return values. For example:

(define/public (get-scroll x y) ;; get fake scroll values if available (set-box! x (if hscroll (send hscroll get-value) (get-scroll-pos 'horizontal))) (set-box! y (if vscroll (send vscroll get-value) (get-scroll-pos 'vertical))))


winny
2019-12-14 10:14:36

Hello - when making changes to typed-racket, how does one test them? For example when i do raco pkg install --link it states typed-racket exists in a wider scope (system scope). If i use --force, it doesn’t appear to pick up my changes, and installs with several errors during byte compilation. Do I have to I compile racket and install typed-racket to the in-place racket installation?


popa.bogdanp
2019-12-14 10:28:23

I could use some help testing this in various configurations (mac, windows, linux, mouse, trackpad, etc.): https://github.com/racket/gui/pull/151


mflatt
2019-12-14 12:48:41

Multiple values have always been around, but the GUI API originally had to work across a Scheme-C++ boundary.


popa.bogdanp
2019-12-14 12:53:01

I see. Would there be value in cleaning some of those up now? In particular, do you think replacing all/most of the boxes (where it wouldn’t break backwards-compat) with multiple return values help create less garbage?


mflatt
2019-12-14 12:55:54

The implementation would be nicer, but I don’t think it would have any affect on performance.


popa.bogdanp
2019-12-14 12:56:37

Got it. Thanks!


robby
2019-12-14 13:23:12

I tried out your pull request @popa.bogdanp and it doesn’t seem to be an improvement to me


robby
2019-12-14 13:23:59

What I see is that it takes about the same amount of time to scroll from the top to the bottom of the window (using my brain as a timer which is definitely fraught) but I see many fewer intermediate steps drawn along the way.


robby
2019-12-14 13:24:51

Things that might affect this: I recently got a new laptop (which probably makes the performance better than average) and I have a retina display (which probably makes the performance worse).


robby
2019-12-14 13:24:59

I don’t have an older machine to try but I could compare that.


robby
2019-12-14 13:27:56

That was on a 400 line file. When I switch to a 2400 line file (drracket/private/rep to be specific) it definitely takes less time to scroll from the top to the bottom of the file.


robby
2019-12-14 13:29:58

One other thing I notice: without the pull request, there is a kind “speed up” thing that can happen: when I “throw” the scroll position with the trackpad and then, while things are going by, I throw it again, things speed up. But with it, I can’t really notice that behavior anymore.


robby
2019-12-14 13:31:16

What I wonder is if the os is doing something similar to what you’ve implemented (computing over the stream of scroll events and delivering update messages in a clever way) and Matthew’s recent change makes drracket actually pay attention to that work the OS is doing, but the OS’s version is fancier than the one you’ve implemented.


robby
2019-12-14 13:31:59

I really am sorry to be so negative too. I am very happy to get your help with this pain point! Lets discuss!


capfredf
2019-12-14 14:21:15

@alexknauth It doesn’t look right to me.

here is mine:

# /etc/netplan for current configuration. # To re-enable ifupdown on this system, you can run: # sudo apt install ifupdown # The loopback network interface auto lo iface lo inet loopback # Host-only interface auto enp0s8 iface enp0s8 inet static address 192.168.56.100 netmask 255.255.255.0 network 192.168.56.0 broadcast 192.168.56.255 # NAT interface auto eth2 iface eth2 inet dhcp


capfredf
2019-12-14 14:22:14

Are you on Ubuntu? what version are you using?


philip.mcgrath
2019-12-14 14:56:53

I’m confused about why this program fails to typecheck, but succeeds if you comment out (: add (-> Integer * Integer)): #lang typed/racket (: add (-> Integer * Integer)) (define add (case-lambda [() 0] [([n : Integer]) n] [([n0 : Integer] . [n* : Integer *]) (foldl + n0 n*)]))


popa.bogdanp
2019-12-14 15:32:43

@robby No worries! I am testing this on a 2016 Retina MBP with macOS Mojave so my machine is definitely weaker and probably suffers from more CPU throttling than yours. Also, I am using regular Racket, not Racket CS.

I pinned the “frame rate” in the PR to 30 FPS so that’s probably why the scrollbar itself appears to skip for you (it does for me too — our screens should both refresh at 60hz). I picked 30 FPS as a lowest common denominator, so we could definitely bump it to 60 or, even better, set it to whatever the current display’s refresh rate is, although that would require some more work on all 3 platforms. Would you mind trying to set SCROLL-DELAY to 16 to see how that affects things for you?

The scrolling acceleration should not be affected so I’m surprised that it’s not accelerating for you. My (extremely overpowered!) 2019 MBP should be arriving next week so I should be able to reproduce whatever is happening on your machine then.

You’re right that the OS/HW itself does some of this coalescing. The problem is in part that the GUI code is not always fast enough to be able to process each event in time (at least on machines like my own) so my PR effectively implements a form of frame skipping meaning it won’t look as good, but it should avoid lagging. The other part of the problem that this frame skipping solves is that the events are processed on a queue so, if each event is processed one after the other, and someone makes an up-down-up-down-up motion on their trackpad then the down scroll will have to complete before the up scroll starts and so on, meaning that it’s not possible to “cancel” a scroll while it’s happening.


soegaard2
2019-12-14 16:04:13

I don’t know why TR can’t deduces the type, but you can use (:add (case-> (-> Integer Integer * Integer) (-> Zero))) instead.


wwall
2019-12-14 17:06:58

Hello. exist simple example for tcp-server?


jesse
2019-12-14 19:39:42

you might consider looking at one of the official tutorials (https://docs.racket-lang.org/more/), which builds up a mini HTTP server from scratch


alexknauth
2019-12-14 20:46:38

My VM is Ubuntu 18.04.3 LTS


sorawee
2019-12-14 23:11:36

How do I do the inverted “override” for mixins?

Let’s consider a concrete example.

I am defining a class that satisfies an interface my-print<%>, which only requires implementing one method, get-printable, which consumes nothing and returns an object that Racket knows how to print already. I will then apply a mixin my-print-mixin which expects a my-print<%> and gives printable<%> back. In this way, I only need to implement get-printable and not all those too-complicated-for-my-use-case custom-print, custom-write , and custom-display .

The above is all good. But then I want an ability to say whether this printing should be print or pretty-print . The obvious way is to have my-print<%> requires implementing get-print-mode . However, I want to be able to default to print and only switch to pretty-print when I explicitly say otherwise. I.e., implementing get-print-mode should be optional.

The problem is that with mixin, the structure is inverted, which makes perfect sense, but it also means define/override to optionally implementing something doesn’t work anymore.


robby
2019-12-15 02:13:48

It seems like a variant of what you’re doing that detect’s maybe that we’re getting behind and then goes into the mode you added, but doesn’t when things seem to be working okay? Not that I’m sure what the predicate would be, but perhaps after you get your new machine you could compare?


robby
2019-12-15 02:17:17

I don’t think I can detect a difference between the version with your PR and the version with just matthew’s fixes when I define SCROLL-DISPLAY to be 16.


robby
2019-12-15 02:17:26

SCROLL-DELAY, I mea


robby
2019-12-15 02:17:27

n


philip.mcgrath
2019-12-15 02:18:54

@sorawee If I understand what you have in mind, I think you can do what you want by taking advantage of the fact that Racket’s classes are first-class values. Here’s a little sketch:


philip.mcgrath
2019-12-15 02:19:10

#lang racket (define (mode-mixin %) (class (if (method-in-interface? 'get-mode (class->interface %)) % (class % (super-new) (define/public (get-mode) 'normal))) (super-new) (inherit get-mode) (define/public (show-mode) (printf "mode: ~v\n" (get-mode))))) (send (new (mode-mixin object%)) show-mode) ;; mode: 'normal (send (new (mode-mixin (class object% (super-new) (define/public (get-mode) 'special)))) show-mode) ;; mode: 'special


sorawee
2019-12-15 02:21:20

This is cool! Thank you :slightly_smiling_face:


philip.mcgrath
2019-12-15 02:22:39

Matthias and Robby’s “Programming with Class in Racket” gives good examples of this technique, based on a real-world performance problem with big-bang that first-class classes helped to solve: http://www.ccs.neu.edu/home/matthias/Thoughts/Programming_with_Class_in_Racket.html


ben
2019-12-15 03:03:11

Try raco pkg update.

With high confidence: raco pkg update --clone typed-racket will give you a new copy of TR to edit and test

Low confidence: go to the TR you’ve been editing and raco pkg update --link typed-racket (you may need to do that for typed-racket-test and typed-racket-more etc)


winny
2019-12-15 06:10:59

Hi Ben thanks for the tips! I did attempt to work against the system installation first, but kept on getting problems with the system scope (and no permission to the /usr/share/…). On the other hand a quick make in-place and following your first suggestion (raco pkg update --clone typed-racket) worked perfectly. Thanks!