freenode/#lisp - IRC Chatlog
Search
12:16:54
jmercouris
hello everyone, I'm trying to extend cl-webkit bindings http://dpaste.com/2YJ30D6
12:21:29
jmercouris
as you can see I am trying to add a single slot titled navigation-action of type WebKitNavigationAction
12:23:25
jmercouris
You can see the version I've made on this branch: https://github.com/atlas-engineer/cl-webkit/tree/navigation-action
12:23:52
jmercouris
these are the changes I've made: https://github.com/atlas-engineer/cl-webkit/commit/94cfbd961e53eafcac18b0a8b667bd933be9ab72
12:28:42
jmercouris
according to here: https://webkitgtk.org/reference/webkit2gtk/stable/WebKitNavigationPolicyDecision.html#webkit-navigation-policy-decision-get-navigation-action
12:52:14
LdBeth
jmercouris: "Unknown GBoxed type" is signaled when type name can't be found in gobject::*g-type-name->g-boxed-foreign-info*
12:53:15
LdBeth
https://github.com/dmitryvk/cl-gtk2/blob/a3108fbc701dbab93b899e04b9637ded2f813410/glib/gobject.boxed.lisp#L117
16:07:35
jmercouris
is it saying here: https://webkitgtk.org/reference/webkit2gtk/unstable/WebKitNetworkProxySettings.html
16:10:57
Bike
Looks like an array of strings, yes. So you allocate your strings however, and then you allocate an array of char* pointers to them.
16:12:00
jmercouris
I need an array of character pointers which are actually pointing to the first character in each string
16:12:58
Bike
Just wondering what's with the question mark. And yeah, null terminated, and also you need to null terminate the array itself.
16:15:01
Bike
So if you have n strings, you do like (with-foreign-object (array :pointer (1+ n)) ...), where ... setfs a bunch of mem-arefs
16:18:35
jmercouris
there seems to be something here: https://common-lisp.net/project/cffi/manual/cffi-manual.html
16:23:04
Bike
since the other functions in here seem to allocate memory themselves, what i would guess is that it allocates its proxy settings object, and then copies in your ignore_hosts. so you can delete the ignore_hosts immediately. but that's a guess
16:24:44
dlowe
I wonder if there's some way to override malloc() in our lisp image so that it uses the lisp allocator instead.
16:29:03
phoe
in theory, you could allocate an ub8 vector, and then pin it and use its data-pointer when necessary
16:29:29
phoe
that's not covering everything though, you still need some way of keeping track of it when it isn't pinned and used
16:30:24
Bike
I mean think of the performance characteristics here. C programs allocate memory in different ways than lisp ones, and malloc is optimized for C ways
16:30:41
pjb
If foreign-alloc is specified to do it, then you can use it. But otherwise, allocate and fill the foreign stuff yourself.
19:43:10
verisimilitude
I think of Ada, and how you can use Ada types, but with a C convention, so that they're still completely under the control of the Ada side of things. Poor programming practices have killed people, and so even a small memory leak is principally unacceptable. This has me think about how I disagree with some of the design decisions made in other portability libraries, and it has me remark on how designing a library as a collected subset
19:43:11
verisimilitude
of nonstandard functionality will likely result in something suboptimal, compared to how the ANSI would've been able to design it.
19:43:46
Bike
didi: no such operator. PUSH is probably just defined with defmacro (using get-setf-expansion, though)
19:45:24
phoe
verisimilitude: ANSI would not and will not be able to design anything better. Would not, given their time and money constraints; will not, because no one has enough money to revise the CL standard.
19:45:42
Bike
didi: What exactly are you asking? When you can use a setf function versus having to use the macro mechanism?
19:46:01
phoe
didi: seems like defmacro with get-setf-expansion. One cannot have a #'(setf getf) function because functions cannot modify variable bindings.
19:46:36
didi
Bike: I am playing with SETF. Now I'm playing with writing a way to setf a value of an alist.
19:47:59
Bike
alexandria has something for that. probably kind of hard to follow the macrology, unfortunately https://github.com/keithj/alexandria/blob/master/lists.lisp#L29-L71
19:48:34
verisimilitude
The basic point is that portability libraries tend to be suboptimal, when considering their purpose, phoe.
19:48:52
verisimilitude
I've written a very simple one and even that isn't the ideal version of the interface I'd want.
19:48:55
phoe
Bike: non-trivial, but one could macrostep these define-alist-get- forms to get a more sensible expansion.
19:49:47
phoe
verisimilitude: I am aware, and yes, they tend to be suboptimal. They are usually "good enough" for contemporary purposes though, since most people do not want to optimize every single thing possible and instead move to other endeavours.
19:51:33
verisimilitude
Taking a quick look at what LZMA is to refresh myself, there's no reason it shouldn't be written in Common Lisp, in my eyes, phoe. I've only taken a brief glance, however, so is there a reason beyond it already being implemented in C?
19:52:15
verisimilitude
When I wrote of portability libraries, I more meant USOCKET and BORDEAUX-THREADS than simple C bindings.
19:52:25
Bike
didi: If you make the define-alist-get macro global and then macroexpand the (define-alist-get assoc-value ...) form it should be easier to understand.
19:52:52
phoe
verisimilitude: I did not care enough about the project to actually reimplement all of the compressor and decompressor in CL. I prefered to reuse existing and tested code.
19:57:59
phoe
I think I've said everything I have on that matter in the reddit comments related to your blogpost on that. Don't have anything new to add.
20:01:56
verisimilitude
I ask because I understand you'd either be flaming_bird or _priyadarshan, if I'm looking at the correct discussion; it's not much discussion, though, since two of the three messages are bemoaning the license.
20:13:42
verisimilitude
Alright; you may find it amusing seeing your recent advice about :USE had me come here to start with.
20:40:42
jackdaniel
I was going to find some nice relevant quote directed at Shinpachi from Ginatama but I've failed
20:48:41
pfdietz
I will not be going to ELS this year, unfortunately. Last year it was a court appearance, this year a global pandemic. I fear next year will involve vacuum decay.
21:04:21
asarch
When the (with-open-file ...) scope ends, does it automatically close the stream or should I do manually?
21:06:20
jackdaniel
as of corona virus, I've read into it and it seems that it is "just" a nasty flu with higher risk of pneumonia; still very bad but it seems much better than how media has pictured it
21:06:49
phoe
asarch: WITH-* macros are a Lisp idiom that allocate some closeable resource, allow you to use it in the dynamic scope of the macro, and then automatically close it whenever control leaves that macro.
21:08:52
phoe
didi: it is. You might want to see https://github.com/robert-strandh/SICL/blob/8dbb240fc688bc9a28865eb1629f8dbc84ca71b4/Code/Setf-expanders/setf-expanders.lisp for some references on how to use it in trivial cases, and https://github.com/phoe/phoe-toolbox/blob/master/phoe-toolbox.lisp#L538 for two macros that use get-setf-expansion
21:19:37
pjb
asarch: because the REPL is not standardized, it can do whatever it wants to get input from the user.
21:19:42
z147
who's here? why are you looking at me with your eyes? short answer: try clisp or read the sbcl manual
21:22:58
pjb
asarch: it looks to me quite reasonable to get a dialog when calling (read) on a system with a GUI…
21:25:13
pjb
*query-io* is also like this. Don't be surprised if your system reads the prompt aloud when you (progn (format *query-io* "Please enter your age: ") (force-output *query-io*) (read *query-io*)) and it expects you to tell an integer to the speech recognizer…
21:33:41
z147
btw, there's several solutions for quit across implementations, is there something similar for read?
21:39:18
z147
With sbcl, prompting for user input, I had to finish-output nil, which was not needed in clisp
21:40:15
pjb
z147: the problem you may have, is that you learned programming with some language that hides that fact.
21:41:03
phoe
writing to a stream does not necessarily mean that stuff gets sent away, e.g. if output is buffered
21:41:46
pjb
z147: you definitely want to control that, so that your batch programs can be as I/O-efficient as possible, and your interactive programs can be as responsive as possible.
22:15:10
didi
I think I'm getting the hang of `define-setf-expansion'. Expanding the setf form helps, but this thing is brutal.
22:16:35
aeth
Hmm... Reading a stream character by character and matching on the first, longest match unreading at the first point at which the match stops is... well, it's a very brutal macro, but I'm almost there with an unoptimized form and without 0+/1+/ranges/booleans for character matches.
22:17:19
aeth
Once it's complete, though, I get a parser for everything I've wanted to parse via a stream...
22:32:32
p_l
z147: CLISP installs a more complex REPL handler, whereas SBCL goes for minimum. And read and write use separate streams in unix without special handling
22:34:05
z147
If i understand the above correctly, finishing output when appropriate should resolve this
23:27:43
pjb
z147: take for example, punched cards. To punch a card, or to read it, it's a mechanical process. Then it's faster to punch 12 rows of 80 columns at a time rather than to punch 80 colums of 12 rows at a time. Ie. while the data is encoded column by column, mechanically it's way faster to process it row by row (since there are fewer rows than columns).
23:28:07
pjb
z147: therefore a fast card puncher will have to buffer the whole card (80 characters), and will punch them all at once.
23:28:27
pjb
z147: it's similar for line printers. Fast line printers will print a whole line (132 characters) at a time.
23:29:47
White_Flame
aeth: with only a single character buffer for unread, it's the only way to attempt to only read what's necessary, in case something else is going to read the stream next
23:31:06
White_Flame
if you read-line, for instance, and search the array for the first non-included char from that buffer, you can't unread the buffer back into the stream
23:31:28
pjb
z147: and then, there are the magnetic tapes. The magnetic tape drive, again being a mechanical device, will have to start and stop moving the tape between each block. While you can write 80-character records or 133 character records each in a block on a tape, this is very inefficient, given that the inter-block space (and time) is on the order of the size of a 64 kbyte block.
23:31:51
aeth
White_Flame: See, a lot of the time I've just done a read-line because it's a parse-it-or-fail sort of thing. But this can also be used for those old read-line-based approaches
23:32:10
aeth
Messier than those require, but since the macro is written, might as well abstract away the reads and reduce consing, too
23:32:17
White_Flame
my lexer/parser stuff can swap out rules and pass off to other readtables in the middle, so I have to be careful not to read too much
23:32:38
pjb
z147: therefore it's more efficient to store (truncate 65536 80) --> 819 punched card per block or (truncate 65536 133) --> 492 line printer lines per block, on the tape.
23:33:16
aeth
White_Flame: This is going to replace my Brainfuck parser, my Scheme reader function, my UCI chess engine protocol reader, my calculator, and a bunch of other things... since it's general purpose enough. Probably even e.g. parse JSON
23:35:04
aeth
ealfonso: Yes. I think it's just "else if" Make sure that you actually need it (e.g. doing :collect, :sum, etc. conditionally), though because otherwise a COND is way clearer.
23:35:08
pjb
z147: when you use hard disk drives, the important size is the cylinder, since what is slow in this mechanical device, is to move the head from on cylinder to another. In any case, the operating system will use block sizes of at least 4 KB. So when you write files, if you force output of smaller buffers, the OS will have to read the disk (the whole cylinder), modify your little buffer, and write back at least the block-size, if
23:35:21
z147
pjb, what would be the effective "block" for reading user input or text from file, say SSD?
23:35:39
pjb
z147: again, it would be much more efficient in that case NOT to call force-output, and wait the closing of the file to flush the buffers.
23:35:43
White_Flame
aeth: and yeah, mine's fully general purpose as well, with the intent to have other languages inline with each other
23:36:27
pjb
z147: now, in the case of the ssd, it's a little different, because there are no mechanical parts. However, there's still wear, based on a block-size (which depends on the SSD, I would guess it's on the order of the KB still).
23:36:39
aeth
White_Flame: Well that just trivially follows from using streams (and thus the potential of using reader macros), even though I personally won't be doing that...
23:37:28
pjb
z147: when reading or writing from files, given the current diffenrential between memory speed and storage speed, use the biggest buffer you can (and given the size of RAM we currently have, this means, the maximum file size you can process, usually).
23:38:03
pjb
z147: for user input, it's different. Here the question is that of interactivity and responsivity of your program. It depends on the expectation of the user.
23:38:38
pjb
z147: in general, the user wants to give a command line-by-line. Therefore the buffer size will have to be the maximum line length you can take.
23:39:17
pjb
z147: as for the output, you can use force-output for intermediate output (eg. progress logs), and finish-output before expecting input.
23:39:43
pjb
note the difference: force-output is asynchronous, while finish-output is synchronous and waits for the output to be finished before the program can continue.
23:40:38
pjb
z147: there's also the case of socket, for network protocols. You need to force-output to ensure the packets are sent.
23:45:50
aeth
Then you only have to worry about the last char being potentially already read, and otherwise can use your old algo