libera/#commonlisp - IRC Chatlog
Search
8:30:09
Guest86
May someone take a look at https://plaster.tymoon.eu/view/3813#3813 and suggest something? :]
8:39:30
beach
If you want to try things interactively, I suggest you use the CLIM listener. Then you can just issue calls to drawing functions, using *STANDARD-OUTPUT* as the stream.
8:44:57
Guest86
beach thank you for your suggestion to use CLIM listener but I would like to figure out things this way for the time being.
8:49:10
pve
Hi! I'd like to wrap the lambda expression I give to make-method-lambda with symbol-macrolet, like (symbol-macrolet (...) (lambda (...) ...)), but apparently this can't be done. Is there some standard way that I could manually trigger the symbol-macrolet expansion and end up with a lambda expression that I could then give to make-method-lambda?
8:51:29
beach
Guest86: Normally, your pane will be erased for each command in the command loop, so you need to define yourself a display function in which you do the drawing.
8:58:11
jackdaniel
Guest86: try (clime:with-output-to-drawing-stream (stream nil nil :width 800 :height 600) (draw-line* stream 10 10 90 90))
8:59:14
jackdaniel
in principle you may return the stream from the body and use it later for drawing, but remember to call finish-output on the stream to ensure some actual output
9:01:11
jackdaniel
if you want to have the real frame, then set :display-time nil as the argument to the application pane, and define a method that performs drawing, then execute it with execute-frame-command (which is thread-safe)
9:04:07
jackdaniel
you need to go through execute-frame-command because this function takes care of potential race conditions
9:05:00
pve
ok, i tried instead to do (funcall (compile nil `(lambda () (symbol-macrolet (...) ,method-lambda)))) on the resulting method-lambda, and it seems I can make a method instance using that :)
9:05:15
Guest86
beach, jackdaniel you are too fast on your replies, thank you for, but I need some time to think (defclass my-stream
9:14:38
Guest86
beach >your pane will be erased for each command in the command loop, so you need to define yourself a display function in which you do the drawing. May you write an example code that defines a display function in which the drawing is done?
9:26:03
jackdaniel
there's that, and there is also a tool called grep to find numerous examples that make use of handle-repaint
9:28:45
Guest86
beach >That is not something you will need for most applications. May you give me an example of code that is being used in most applications then?
10:16:30
zest
when implementing a network protocol in common lisp, should one concern with using a library like fast-io? or just use the default common lisp I/O functions...
10:25:17
Gnuxie
the messages from IRC aren't making it here, my messages are making it through to there but not yours (see https://irclog.tymoon.eu/libera/%23commonlisp)
10:28:29
ogamita
zest: CL doesn't have network API, so you'd have to target some network API anyways. Most often, Gray streams are used to provide a kind of stream connected to the network, so you may use usual CL I/O operators.
10:29:10
ogamita
zest: but mind that while network API may provide something like a stream abstraction over their connection, it's not always entirely transparent, so depending on the application, you may prefer to use the network API directly. It depends.
10:31:32
ogamita
zest: I tend to use usocket as a portability library (combined with CL I/O operators when using streaming protocols).
10:32:36
ogamita
zest: note also how it depends on the architecture you choose: either multi-thread with usual control flow (and therefore blocking CL I/O operators), or event-loop based, with non-blocking I/O operators.
10:33:28
ogamita
zest: and, what I like most too, you may also implement a network protocol without using any I/O or network API. Just define your up and down API, and let the client hook them to actual I/O or whatever network API he wants.
10:35:13
ogamita
zest: this is what I did eg. in my telnet implementation: https://gitlab.com/com-informatimago/com-informatimago/-/blob/master/common-lisp/telnet/telnet.lisp
10:35:44
ogamita
https://gitlab.com/com-informatimago/com-informatimago/-/blob/master/common-lisp/telnet/telnet.lisp#L345
10:37:55
ogamita
(see test.lisp, it's a kind of mock test of telnet.lisp, which is 100% natural when you structure your code like this with clearly defined APIs and no dependency).
10:40:17
ogamita
zest: in https://gitlab.com/com-informatimago/com-informatimago/-/tree/master/clext/telnet there's a client for the telnet protocol package. (there may remain bugs in that client).
10:40:17
zest
ogamita: i understand what you mean, that was really helpful. I think I will go with your approach and leave the I/O and network for the client
10:42:26
zest
but should the parameters octet-vectors or streams? I know streams can be bufferred and that gives the client more room to play with performance but I also want to unit test my functions...
10:44:14
ogamita
Again, it depends on your requirements. For maximal portability, you may prefer octet-vectors, since that allows the client to use any kind of I/O it wants. On the other hand, indeed, using a streaming operators makes it simple and convenient (this is why eg. CLIM make the effort of using STREAM to let the application communicate with the GUI backend.
10:46:53
hamza
So anyways, in short I wanted to type variables inside my LOOP, I know I could extract it out to a let and then use that in loop typing that with declare, but is there a shorter way/
10:47:54
Guest86
jackdaniel>they are written so people can learn, that's literally their purpose. Well, let's take a look into A guided tour of CLIM Our first application chapter. We find how to define-application-pane and how to make-pane but when we arrive at using a method we can not figure out how it works with hello-world frame. At this point learning process
10:47:54
Guest86
comes to logical end. May be it is a time to revise the guide and examples as well?
10:54:07
ogamita
with a little script to pipe easily: #!/bin/bash \n nc termbin.com 9999 | tr -d '\000'
10:54:21
hamza
zest: I solved the problem in 5 minutes but couldn't optimize it. I am thinking of using primes then
11:01:04
hamza
1 thing is that divisor-count is MUCCCH faster now especially for even numbers, but p12 takes the same amount of time even after timing I know, kind of premature optimization
11:02:05
hamza
Running it, I ccouldn't get an answer under a minute or even after a minute lol so uhhhh probably need to change algo
11:02:53
zest
ogamita: thanks guess I'll go with streams since the protocol I'll use will do file transfers...
11:05:47
zest
hamza: A list wouldn't work, you need a hash-table since a hash-table's efficiency doesn't worsen with size
11:06:28
zest
hamza: I think if you wanted to, you could make a version of p12 that's 3 lines if you used pure recursion
11:23:50
beach
With every new candiate prime, you need to test all previously computed primes to see whether one is a factor.
11:24:21
beach
And it is best to do that from the smallest one, so that you are more likely to hit a factor and decide the candidate is not a prime.
11:27:02
beach
zest: You wouldn't attempt to access the already computed primes in some random order, so a list is just fine.
11:30:12
beach
Oh, maybe I didn't read very carefully. The task was not to implement the sieve, was it? Sorry!
11:30:28
hamza
wait so now that i got the divisors that are primes, now for every prime divisor i found i should go through the list and multiply by each one? and repeat that?
11:58:52
hamza
Actually divisor-count is MUCCHHH faster, However, again, it isn't able to catch all primes
12:02:55
hamza
Here is what I got, I could obviously optimize this ALOT but it doesn't need it getting the divisors of a really large number is sub millisecond
12:26:21
hamza
lol, I kept looking for faster divisor algorithm and they all decieved me because they calculated from 1 to sqrt of n but that missed some numbers!
12:27:10
hamza
I didn't realise that each of the numbers uptill sqrt n, n came in each one of those number's table
12:30:35
zest
loop exists for a reason and that is to stop people like write me from writing recursion functions
12:31:06
hamza
srsly, in the middle after learning haskell i wanted to write everything in recursive functions, turns out that's not always the best ;)
12:32:39
hamza
Uh the entire problem wasn't able to finish even after 1 and a half minute, so there is that. But here, I get the answer in .703 seconds
16:01:09
gilberth
piethesailor: Have you verified that xwd works? I mean, this puzzles me as the only cause for a Match error according to the protocol spec is that the rectangle asked for is not viewable (and thus not really present).
16:04:56
gilberth
Hence I suspect the X server being funny. And: Is it really XLIB:GET-IMAGE causing this error? First thing after you opened the display, please say (setf (xlib:display-after-function dpy) #'xlib:display-finish-output) to make requests synchronous. That's not recommended in general, but aids debugging.
17:03:44
piethesailor
xwd isnt on my machine, or at least in terminal: $ xwd returns xwd: command not found
17:06:23
Nilby
piethesailor: It turns out x11 apps can't do screenshots with X protocol when running under wayland.
17:08:43
Nilby
It exists but it always get that error. Apps like gimp and obs had to be fix to do screen capture under wayland.
17:08:55
piethesailor
hmm, so I suppose my issue is that I am running wayland and that my x11 applications are running under Xwayland?
17:09:54
splittist
People might take pictures of videos, and then what is the point of all that vital CD anti-copying technology?
17:16:40
Nilby
The problem is that in wayland you have to do everything yourself, unless you're using a big toolkit like gtk or qt.
17:38:44
gilberth
The whole story is quite sad IMHO. And you see beginnings of that with the RENDER extension. With that you're also on your own, all RENDER can do is drawing triangles and blittering. So you need to turn your shapes you want to draw into triangles and raster your fonts on your own. I really don't like that idea. I mean, why isn't Cairo with the server? And why isn't font rendering happening at the server?
17:39:13
Nilby
piethesailor: it's even worse because the window system should probably be a glorified pixel shader, but the hardware is proprietary
17:39:30
gilberth
So, when you're on your own and that is modern, moving to a mere blittering protocol and thus Wayland appears to be logical next step.
17:45:16
piethesailor
Is there any kind of answer to this? I suppose there might at least be a linux distro that is just doubling down on staying with Xorg?
17:46:04
gilberth
The original argument for moving to "you're on your own" was that transferring font metrics from the server to the client increases application start-up time. Funny however is that when I want to send you a PS or PDF file, I don't need to ask you for your font metrics first. Magic?
17:48:33
Nilby
gilberth: As you may know, of the "magic" is the font must be embedded, or identical to the server or it renders improperly.
17:50:51
gilberth
Yes, and that is no problem. DVI files e.g. embed a checksum. The client could say "I want to use Times.ttf checksum 269926926 as my font" The server then could check, whether it has that font. In 99% of the cases it already has it. If not, it could ask the client "Please send me a copy of font checksum 269926926". Could also work with a third party in the mix. Both client and server could communicate with a font server, so ...
17:52:06
gilberth
In most cases, no fonts need to be transferred as you always use the same fonts for your Emacs, your shell, and whatnot and thus server and client would already have a copy.
17:52:14
Nilby
Yes, it could be worked out much better. Ancient dvi and tex pdf files always see to render fine.
17:53:24
gilberth
With DVI it is pure luck. The DVI files don't even include metrics, which are needed to at least place glyphs correctly. I just named it as an example where checksums are used to identify a version of a particular font.
17:54:12
gilberth
With PDF you either use one of the default fonts Times, Helvetica, Courier, which have well-known metrics since PS exists. Or you embed that font.
17:55:29
piethesailor
gilberth: Unfortunately the topic might be wrapped up. I don't know that there is an immediate solution for screenshoting programaticly in CL. Of course I could start writing my own library for it I guess
17:56:29
piethesailor
even though that package is a light wrapper. Might need to build on that first
18:00:58
piethesailor
I'll take that advice.. Could use a solution sooner than later. Wayland isnt on ubuntu <21.10, right? being on windows subsystem, I should just downlaod ubuntu 18 and work on that from now on..