freenode/#lisp - IRC Chatlog
Search
7:15:58
no-defun-allowed
bonus points if you write a PARTITION that takes one function and spits out both in one pass
7:16:14
rk[ghost]
if i am dealing with strings, any good list for boolean functions for searching strings? like contains a substring, ect?
7:20:37
rk[ghost]
by the bonus point challenge you mean something that for instance (my-partition #'parity '(1 2 3 4 5 6)) -> ((1 3 5) 2 4 6) ?
7:24:15
jackdaniel
(collecting (o e) (mapc #'(lambda (elt) (if (oddp elt) (o elt) (e elt))) *list*) (cons (o) (e)))
7:25:59
rk[ghost]
well, i presume no-defun-allowed meant it to be generic such that for any boolean function it would return (values (o) (e))
7:26:40
no-defun-allowed
i did one before as a compromise for "what would filter do?" but it wasn't using iterate...iterators? just push and nreverse
7:28:07
jackdaniel
uiop has a (buggy! I don't remember the actual example) while-collecting macro, but I'd recommend using one taken from cmuutil (http://ix.io/1udU)
7:29:31
jackdaniel
I wonder if alexandria would accept this macro (given it is like a thousand years old)
7:33:25
no-defun-allowed
i did make a right-way-around-cl-arrows but it's not as flexible as the real one yet
8:22:49
dim
jackdaniel: as a bit of feedback, I find it hard to get at McCLIM documents for users, like how to implement a presentation thingy, do I need to implement one, how to pick a font-face / list available font-face names / render unicode, how to implement a pointer-button-press-event, etc
8:25:40
jackdaniel
dim: for text, I'd recommend using http://bauhh.dyndns.org:8000/clim-spec/11-1.html#_569 for now (make-text-style), which maps portably to available fonts
8:25:56
jackdaniel
font abstraction is not documented (and not part of CLIM original spec, because fonts are port-specific things)
8:27:51
jackdaniel
regarding presentations: McCLIM manual has an example of how to do that. basically: define-presentation-type is akin defclass. you may look at Examples/hierarchy-tool.lisp or mcclim manual draft to see how they are used
8:29:48
jackdaniel
pointer-button-press-event, pointer click is a gesture called select (events are lower abstraction), you may study gadgets.lisp (push-button-pane) to see how events are handled, otoh select gesture is by default for selecting command arguments (there is also presentation-to-command-translator http://bauhh.dyndns.org:8000/clim-spec/edit/apropos?q=presentation-to-command-translator)
8:35:05
minion
elderK, memo from pjb: notice that p-lists are faster than hash-table when they have fewer than 5-35 elements, depending on the implementation. Also, hash-tables have a size overhead that is way bigger than p-list. So if you need to put just one or two entries on thousands or millions of symbols, better use the symbol-plist. On the other ahnd, if you need to put thousands of entries on a few symbols, then better hash-tables.
8:35:05
minion
elderK, memo from pjb: In both cases, if you attach attributes to symbols at compilation time, you must ensure that data is passed over to run-time if you need it at run-time. basically: (defmacro x (s) (setf (getf (symbol-plist s) 'your-attribute) 'your-value) `(progn (setf (getf (symbol-plist ',s) 'your-attribute) 'your-value) … ))
8:36:55
elderK
I spent a lot of time on the road today, in transit between cities. I spent it wisely, imo, reading CLtL2 and CLHS, lots of things but particularly studying about the compilation environment, and effect of various things like defun, defmacro, structures etc, wrt compilation.
8:37:33
elderK
I would be interested in how I can adequately test that everything is as it should be, eval-whens when needed, that things that should be visible, are visible, at macro expansion time, etc.
8:38:11
elderK
My system can load fine on SBCL and CCL using ASDF. Freshly loaded instances of those systems. But, that to me doesn't make sense - as far as I understand, my system should fail to load.
8:39:01
jackdaniel
then you should create your load.lisp file which loads your system in terms of compile-file and load
8:39:59
elderK
jackdaniel: Thank you. It sounds like a good thing to investigate, too, to get a better appreciation for ASDF, too.
8:40:19
elderK
Although I do use Alexandria. It's not a hard dependency - there's nothing in it I cannot build myself but, you know, I figured use Alexandria.
8:40:39
jackdaniel
also note, that clhs gives you requierments, but implementation may do "better". for instance defconstant in sbcl is visible if toplevel to forms following it in next files, in ccl not so much (you need to either warp it in eval-when or have it in the previous file)
8:40:44
elderK
Other than having (asdf:load-system "alexandria") in the "load.lisp", I'm not sure how I'd go about arranging for it to be present.
8:41:50
dim
jackdaniel: hey thanks for the answers! I'll read this new material and try and figure things out!
8:43:19
dim
about the presentation thing, I want to have my own clickable (select-able) objects, a grid of say 10x20 of them, and at the moment they're just rectangles being drawn, not gadgets, and I just don't know if I should make them gadgets or just handle the select event in the frame, get the coordinates and figure it out myself
8:47:07
dim
well now I should get to work rather than play with McCLIM, but well, maybe late tonight I'll be able to play around again
8:48:04
jackdaniel
elderK: you may load it with asdf first and then experiment with load/compile-file on your own
8:48:15
jackdaniel
but you may load alexandria without asdf like this: http://ix.io/1utu (change paths etc)
8:48:16
dim
goal 1: minesweeper in McCLIM, goal 2: racket tutorial with images in McCLIM, hopefully with a pane having a lisp editor and a pane with a REPL like thingy that can also display images, handling positions for you I guess
8:48:39
scymtym
jackdaniel: when dim asked about fonts yesterday, i said https://irclog.tymoon.eu/freenode/%23lisp?around=1543190146#1543190146 . is there a better way?
8:49:22
dim
scymtym: oh I wasnt' around anymore when you said that, thanks for pointing it now again!
8:50:18
elderK
jackdaniel: I assume a good test would be to compile everything, but not actually load it until everything had been compiled.
8:50:57
elderK
But it seems like it would be a good test to make sure my stuff isn't relying on any side-effects that are you know, not guaranteed to happen during compilation.
8:50:59
scymtym
dim: sure. i just suggested that as stopgap solution until someone more familiar with the subject could point out a better solution
8:51:15
jackdaniel
there is, and it is part of clime: (port-all-font-families port) and on results you may call (font-family-all-faces …) and (font-face-all-sizes …)
8:51:42
jackdaniel
but sadly not documented (afaik); Examples/font-selector.lisp shows (in a messy way) how to use that
8:52:13
jackdaniel
making a text style with arbitrary names will most likely fail on other backends (pdf/postscript etc)
8:55:01
elderK
jackdaniel: An unrelated question: What's the deal with any errors encountered during write-sequence?
8:55:18
elderK
I see that read-sequence returns the position of the unwritten-element. Like, the one after what was read. So, you can test how many was succesfully read.
8:56:09
elderK
I know file-error exists, so, I'm curious as to whether that is generated by write-sequence if, for whatever reason, it cannot write to the stream.
8:57:47
jackdaniel
I'm afraid I can't help you, I'm not sure where that would be described in clhs. but I would indeed expect that file-error (or something similar) happens at some cases
8:58:03
jackdaniel
otoh we do not expect cl:list to list heap exhaustion as one of the exceptional situations
9:00:33
jackdaniel
The type file-error consists of error conditions that occur during an attempt to open or close a file, or during some low-level transactions with a file system. The ``offending pathname'' is initialized by the :pathnameinitialization argument to make-condition, and is accessed by the function file-error-pathname. (from file-error)
9:00:57
jackdaniel
so write-sequence, if it implies a low level transaction which may error, could signal file-error
9:01:05
dim
ok when using (setf mcclim-truetype::*truetype-font-path* "#P/Users/dim/Library/Fonts/") (mcclim-truetype::autoconfigure-fonts) in the REPL then I could have ♣ display properly with (clim:make-text-style :serif :bold 24)
9:02:31
elderK
jackdaniel: I guess I could play with it, like, experimentally :P Give read only access to a file, and try and write to it. Or, have a file that is writable but on an tmpfs with very little space.
17:05:47
tryingoutlisp
I get an unbound-variable error. Let me pastebin an example so I can show you.
17:45:42
jmercouris
so, I'm running (bt:make-thread (lambda () (uiop:run-program "xyz"))), how can I know when xyz has started?
17:46:09
jmercouris
mind you, xyz is a long-running process, and will continue to run, it's not like I'm looking for an exit code or anything
17:52:29
flip214
or you look at the child process' CPU usage - and after 1 sec or so you know it's "up" (and not crashed yet)
17:52:54
flip214
or you can use ptrace and see when it has reached some important point (listening socket open, etc.)
17:54:24
|3b|
but yeah, if you need to interact with it, probably better to just have it tell you when it is ready if possible
17:54:50
flip214
jmercouris: is there some external effect you can watch for? like a http server which you can ask for /status or so?
17:55:06
flip214
jmercouris: signals are not that easy to handle correctly; even less so in multi-threaded programs.
17:59:57
jmercouris
so I'm not sure how to loop on retrying the command until I don't get a connection-refused-error
18:06:11
fortitude
jmercouris: you might want to use that handler case in a function that returns T or NIL based on whether the connect succeeded
18:08:25
fortitude
jmercouris: if it helps, handler-case is known as try/catch in other languages, so if you've ever used that before, you can do the same sort of things
18:09:04
jmercouris
(make-window) in the above code is making the XML-RPC call which depends on the other program to be running
18:10:29
jmercouris
dlowe: ah, so you set the loop expression it is looking out for within the cases
18:18:31
|3b|
ACTION tends to just loop on 2nd value of ignore-errors when i'm expecting lots of errors :p
18:23:04
fortitude
jmercouris: your handler-case form doesn't have any error clauses, and your handler-bind form doesn't have a body (they're two separate ways of handling errors)
18:24:13
fortitude
what you want is (handler-case <your thing> ((sb-bsd-sockets:connection-refused-error () <your handling code>)))
18:26:20
fortitude
jmercouris: if it makes you feel better, I can never remember which syntax goes with which form either
18:31:07
jmercouris
you know, I often look at the hyperspec, and I'm still not that good at understanding it
18:31:49
fortitude
jmercouris: the grammar notation can be a little tricky sometimes, but it helps if you pair it with the examples
18:37:48
malice
However, there is an effort by phoe called CLUS, short for COMMON LISP ULTRASPEC, which tries to provide a better hyperspec: http://phoe.tymoon.eu/clus/doku.php?id=cl:macros:handler-case
18:38:08
jmercouris
I don't want to disparage the ultraspec project, but it is on permanent hiatus afaik
18:39:06
malice
dlowe: On more than one occasion I found that examples weren't clear enough or didn't showcase what I wanted to know (and I do not think I was looking for anything extraordinary).