freenode/#lisp - IRC Chatlog
Search
12:09:30
dmiles
if someone use LABELS at the toplevel of a file, are these declared in the global environment?
12:13:35
jackdaniel
so if you define functions A and B in labels and you call B from A, it will call this B you have defined
12:14:11
jackdaniel
if you define them in flet, then it will call B from the environment in which you put flet/labels
12:15:12
jackdaniel
try (defun a () (pring "hi!")) ; (labels ((a () (print "hi from labels!")) (b () (a))) (b)) ; (flet ((a () (print "hi from flet!")) (b () (a))) (b))
12:21:57
elonopea
anyone know how to turn off auto-repeat-mode in CLX for the duration the program is running, and then ensure it's turned back on before gracefully exiting? I currently have the auto-repeat-mode turned off globally before the loop, and turn it back on on a key-release event, but this doesn't work unless I return nil from the key-release clause. if I close/destroy the window/display within the key-release clause, auto-repeat-mode gets
12:23:14
elonopea
I then issue Abort and get back to REPL with key repeat back on, but how to do this cleanly?
12:24:03
elonopea
sorry, auto-repeat-mode gets turned ON if I destroy the screen/display within the clause
12:25:43
elonopea
I thought I could just add the call to turn auto-repeat-mode off into the key-release event clause (within event-case) as that would return T, but although the program exits auto-repeat-mode stays off
12:28:57
elonopea
I'm not sure how to go about this. yes, key repeat remains off globally in X after the program exits.
12:31:50
elonopea
here is the code: https://pastebin.com/UTq1FXRr (sorry about horrid indentation, comments and stray parens, I've been moving stuff around in desperate attempt to fix this)
12:32:36
jackdaniel
I would appreciate if you could fix the indentation before I try to tread the code
12:51:12
elonopea
jackdaniel: https://pastebin.com/7qLiWsrq - hopefully better, though not necessarily perfect by the book...
12:54:22
elonopea
apparently sneaked in an indent inconsistency with the key-repeat declarations. I've been splitting the keywords on separate lines for clarity, and try to condense when I think I'm done twiddling with them
12:57:52
elonopea
jackdaniel: when I release key 's', the key-repeat is turned back on, but it throws me into debugger: https://pastebin.com/Nv6un6Yv
12:59:22
elonopea
I tried to put it after the event-case form, but it never changed the key-repeat, so when I get back to REPL it's off
13:00:45
elonopea
same if I only leave the change-keyboard-control call to turn repeat back on inside the key-release clause within event-case, then the program exits but key-repeat is still off. I don't get it to be honest.
13:02:29
jackdaniel
btw, what clx do you use? I see `require' call – what is your lisp implementation?
13:03:27
elonopea
with the current code, key-repeat is on (as supposed), but it throws me into the debugger. I don't really understand the event handling well, seems like it's async and I don't know how to bring the whole thing down in controlled manner
13:04:12
elonopea
the xembed is for something else entirely, it's from quicklisp. not sure if I even need it (for something else I'm doing)
13:15:38
elonopea
alright, thanks... I've been reading the manual but frankly the lack of examples is killing me. even google has been quite unhelpful on this particular topic and I've had to resort to somewhat unrewarding studying of random (mostly uncommented) code
13:16:35
jackdaniel
when you grok it, and if you are willing to spend some time, you could write a tutorial for CLX
13:22:14
elonopea
I glanced at it but often my problem with reading other people's CL sources is the (IMO) over-eager abstraction... people toss way too many layers upon layers of code for the sake of making everything general, tidy and purpose-built, but hiding the simple and obvious logic and structure in the process. or that's how I often feel. when I'm trying to get friendly with a new API I appreciate really, really stupid code that I can then h
13:23:30
elonopea
anyway I'm going to take a more careful look at the demos now... if I get somewhere with this stuff I'll take the tutorial into consideration :-)
13:29:25
pjb
elonopea: on the other hand, I don't find that most lisp code is too high level or abstracted at all; on the contrary, I find it rather rare to find multi-layered abstraction levels. The reason being that it's costly to produce (in time and IQ).
13:29:47
|3b|
Shinmera: isn't that a protocol problem, so clients can at best be "more conservative" rather than "not broken"?
13:30:38
Shinmera
|3b|: There is a way to make it perfect, but even just having an arbitrary limit that is low enough to not just split your messages is better than trimming your messages and not realising.
13:30:58
pjb
elonopea: you may want to read/study sicp Structure and Interpretation of Computer Programs http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/
14:11:08
elonopea
pjb: thanks. I know SICP but never got around to reading it. meanwhile I've acquired a ton of other literature on Lisp.
14:19:53
mfiano
It is conforming for a client of IRC to either continue or cut off text consisting of more than 503 characters.
14:29:08
mfiano
Reading it again, it's kind of funny though, because character encoding is not mentioned at all.
14:30:21
|3b|
ACTION thought it also includes host names, making it harder to predict where it will be further truncated during transmission
14:31:32
Shinmera
|3b| is correct. You can't know your own hostname because the server might change it somehow
14:31:49
Shinmera
So you need to first probe for your own hostname, remember that, and then calculate the proper prefix length to split "perfectly".
14:40:11
pjb
mfiano: and indeed, in practice you have channels using any coding system. Some are ASCII, some are Latin-1, some are utf-8, some are KOI, etc. You can find any encoding.
17:53:28
jasom
Bike: nope, it's still being noted, but that line of code is being run as far as I can tell
18:14:11
scymtym
jmercouris: a "note" is the least severe type of condition signaled by SBCL's compiler. more severe ones are style-warning, warning, error
18:17:03
Bike
jmercouris: in this case, sbcl is signaling a(n errant) note that a line of code is being deleted by the compiler.
18:25:44
earl-ducaine
Hi Lispions! q: about quasiquote syntax -- is the dot notation excatly the same as the at notation, or is there some subtle difference I'm not see? e.g. https://gist.github.com/earl-ducaine/bce5e27248c806027b824e8162b381c3
18:27:38
beach
"Anywhere ``,@'' may be used, the syntax ``,.'' may be used instead to indicate that it is permissible to operate destructively on the list structure produced by the form following the ``,.'' (in effect, to use nconc instead of append). "
18:30:44
earl-ducaine
I was just looking at that page , but got discouraged when trying to do a text search for: .
18:36:58
_death
the parenthetical remark is also interesting, since just before that paragraph there's an example of building up a vector
18:38:47
|3b|
ACTION wonders if that interpretation means `# is required to fail when used with more than call-arguments-limit values
18:45:20
jmercouris
Bike: How can a compiler delete a line of code? what does that mean in practice?
18:46:00
Shinmera
If a branch can never be reached, the code is useless and can be deleted to save on code cache.
18:46:02
sjl
the first print can never happen, so the compiler might not even compile it into the function at all
18:47:21
sjl
another example: (disassemble (lambda (x) (declare (type integer x)) (typecase x (number :foo) (symbol :bar))))
18:48:34
jmercouris
sjl: what does declare ignore do from a compiler perspective? does it for example avoid passing that arg?
18:51:02
jmercouris
(Disclaimer: I've already brought this up on this channel before, but the conclusion wasn't a really good one)
18:51:33
jmercouris
I have this problem, I want to make a minibuffer input, my GUI does not have a blocking "read" function like a terminal
18:52:20
jmercouris
Why do I want to do this? because minibuffer input in my program is kind of strange
18:53:09
jmercouris
here's a gist illustrating what I'm saying: https://gist.github.com/jmercouris/944e60992fd391fc9008485788342ce6
18:55:25
sjl
so you have a widget in the UI the user can put some text into, edit, copy, paste, etc etc
18:55:48
jmercouris
sjl: Here's the issue, people can write functions that say "Ask the user for some input"
18:56:08
jmercouris
instead of asking the user for input, getting the input, and then calling some function with that input
18:56:50
jmercouris
the reason being that it makes it much more complex for the end user when they have to consider 2 or more user inputs into a function, they would have to prompt the user and chain several funcetions together
18:58:45
jmercouris
Anyways, the other user here on #lisp said it was a mistake to use semaphores and to make new threads for for every input, they said it would cause huge problems
18:59:04
beach
It sounds like you need CLIM. It does a good job of turning event-style backends into stream-style application code.
19:00:30
beach
Like I said, I don't quite know what your problem is, so I am not sure how to answer that question.
19:02:17
jmercouris
4. Users of of my program write functions that except the following sequence of events I. Ask user some question II. User types input into GUI Textbox III. User presses the return key
19:03:17
jmercouris
5. Currently users of my program can only get input in the following way (get-input-from-user "Some Prompt Message" function-to-call-with-input)
19:03:24
beach
Right, so in CLIM, you would just call an ordinary Common Lisp READ function. It would work automatically.
19:03:43
jmercouris
6. So, the program will say to the user "Some Prompt Message", collect their input, then fire off (function-to-call-with-input)
19:04:43
sjl
But instead of providing a callback, you'd rather (get-input-from-user) suspend computation at that point, wait for the input to happen, and resume computation once it's ready, with the result value being the input
19:04:51
jmercouris
beach: That's the functionality I'm trying to imitate , I can't exactly use CLIM though as I am already using Cocoa/GTK
19:06:10
|3b|
so every other plugin/whatever blocks if it takes a while to do something (including wait for input)?
19:07:27
sjl
one option is to write a macro that lets you write code that LOOKS like what you're asking for, but translates into the callback-style code
19:07:52
jmercouris
sjl: Yeah, there are some things I think (compositors?) that can do this kind of translation but are unreliable or so
19:08:57
jmercouris
jackdaniel: can you expand on that, what do you mean by a channel? each function has it's own channel? how does it prevent code from executing until some evenet?
19:09:43
|3b|
ACTION is wondering if this is a special case of a problem you would still need to solve (or if already solved could be used here as well)
19:10:11
jackdaniel
you have an event-distributing-thread which calls read on a thread-safe queue (blockingly)
19:10:44
jackdaniel
I've used word channel, because lparallel has abstraction for that (with a pool of workers)
19:11:20
scymtym
jackdaniel: callbacks are not necessarily like events. they may have to return a value
19:13:42
jackdaniel
that's for one, the second is that I had an impression, that you are interested in computation in some kind of singleton loop
19:17:53
sjl
jmercouris: this is the kind of macro I was talking about before: http://paste.stevelosh.com/5a3965b759b43700087a54b5
19:18:08
sjl
to be able to write something vaguely normal-looking and have it translated into callback-hell style
19:19:03
jmercouris
jackdaniel: I still see an issue though, would the thread with (some-user-function) not freeze?
19:20:15
jmercouris
sjl: You know, that's lookign more appealing, I guess the user is just constrained to using it with a "with-result"
19:21:58
|3b|
and how does waiting for minibuffer input differ from spending 5 seconds doing some image processing or whatever?
19:24:23
|3b|
so minibuffer input is a special case, but some-user-function still needs to be written in CPS if it wants to sleep, read a file from somewhere, etc?
19:24:56
sjl
jmercouris: yes, and you can make it friendlier to allow multiple sequential bindings, e.g. http://paste.stevelosh.com/5a39676a59b43700087a54b6
19:27:06
jmercouris
I need something more like with-result* so that intermediate results can be used too
19:27:53
sjl
if you look at the macroexpansion, the second read-from-minibuffer is called with the first result already bound (by the lambda arglist)
19:27:58
smurfrobot
Can CL deal with raw memory addresses the way C does? I think I remember someone creating a language like that.
19:30:32
sjl
jmercouris: though if you want to do non-callback-based stuff in between, you'd need to interleave that with the with-results macros (or use something like fare's nesting macro to flatten it out)
19:31:13
_death
jmercouris: there are many approaches to this problem.. here's a recent-ish toy https://gist.github.com/death/9ebfb1ae524c9c3dcdf780762ce0362d
19:33:14
smurfrobot
hmm just curious what I could use the language for. I am rather fond of the uniform syntax etc- but interested in problems like binary analysis.
19:33:33
beach
smurfrobot: In the case of CL, it requires an extension provided by the implementation. In the case of C, it requires using unspecified behavior of a particular compiler.
19:33:51
fourier
smurfrobot: check this out: https://common-lisp.net/project/cffi/manual/cffi-manual.html#Basic-Pointer-Operations
19:36:35
smurfrobot
and possibly stuff like instrumentation. i have been looking into stuff like pintools
19:38:06
smurfrobot
yeah been looking at tools that do the disassembly for me so i can focus on working on the dataflow etc.
19:38:42
fourier
its too generic. tell exactly what is the problem language-wise you have. there are at least 2 approaches: using ffi to access "foreign" memory and tweak it and 2) read the data into byte-array and do the same stuff as you would do in c/c++ etc
19:39:56
smurfrobot
yeah i think its possible from what you are telling me but might require some effort with ffi and perhaps writing some c code as well.
19:40:01
_death
smurfrobot: you can do better than C :)... here's a very recent toy https://gist.github.com/death/5ec259ef473b982898a3c5e36b21b1cd
19:41:19
fourier
smurfrobot: this maybe of interest https://github.com/samanthadoran/potential-disco
20:32:58
pjb
emaczen: it is useless: (find-package :name) is already a test for the presence of a package.
20:40:44
|3b|
probably better to use separate files + asdf systems with explicit dependencies rather than enabling optional features at read time anyway... always fun when things behave differently depending on load order
20:41:53
|3b|
some random thing 3 layers deep in the dependency chain from your code decides to add another dependency, and suddenly an unrelated thing loaded later behaves differently, and everything breaks :)
20:42:49
|3b|
or gets compiled from a project that uses the optional thing, then you load the fasl from something that doesn't, and again everything breaks
20:48:11
Xach
a dependency loaded cl-ppcre first, and then wilbur, and then when wilbur was loaded solo from fasl, crash with no ppcre package
20:53:57
rpg
Xach: I have definitely seen this flavor of error. It's very odd to see code getting failed package errors from systems that (you think) are irrelevant!
20:55:22
Xach
rpg: reminds me of an old-school bug that has disappeared. people would sometimes write (in-package foo), and FOO would actually be SOME-PREVIOUSLY-REFERENCED-PACKAGE::FOO, and that would end up in the fasl, and break stuff
20:56:22
smurfrobot
the two projects i know of for binary analysis are bap and bitblaze. I think both are written in ML derived languages. I have however been wondering if there are other choices for doing binary analysis. my understanding is that ML is highly regarded in the academic community especially for compiler type stuff. I was wondering if lisp could be adapted for this as well.
20:58:58
jmercouris
sjl: I know what happened now, I had somehow entered your previous paste in twice, so I didn't see the new one you sent
21:03:02
jmercouris
_death: That's an interesting example you've got there, I don't understand where you make a new thread though
21:07:32
_death
jmercouris: that's one example of communicating processes.. the other I have there is the ping-pong example..
21:07:39
jmercouris
My challenge is a little different and as I will have to do something similar, but with threads, or follow sjl's compositor approach
21:08:25
jmercouris
|3b|: The more I think about it, the more I think that all processing should block on user scripts
21:09:05
jmercouris
_death: Yeah, that's why I thought maybe I should just launch all user commands in new threads
21:09:30
jmercouris
and then just create a semaphore for user inupt, and then release upon the RET key
21:09:32
|3b|
if only 1 can run at once no matter how long it takes, then just having a dedicated thread for them sounds easiest
21:10:13
|3b|
then it can just send a request to UI thread and wait for response (with whatever IPC method you prefer)
21:11:00
jmercouris
|3b|: So If user type input X -> function Y, it will launch a new thread and execute whatever stack that command invokes in that thread
21:11:03
|3b|
depends on whether you already have something for dispatching work to other threads i guess
21:11:17
jmercouris
then if user type input Z -> function Q WHILE function Y is still processing, open yet another thread
21:11:38
|3b|
if they need to be serialized you would probably still need a separate thread for serializing them
21:11:46
jmercouris
|3b|: Is there not an easy way in Cl to say something like (with-new-thread (...))?
21:12:07
|3b|
problem is what happens if you get another request to run a user script while that one is running
21:12:19
_death
jmercouris: the point is that you have your own scheduler, not the operating system's, and you don't need threads to achieve multitasking, and this can be simpler for the modules.. even if you actually want preemptive multitasking, threads may be too low-level.. channels/queues have been mentioned..
21:13:24
|3b|
"the more I think that all processing should block on user scripts" suggests it shouldn't
21:14:09
jmercouris
I just meant that all invokations of some command should be blocking for and serially on their own threads
21:14:24
jmercouris
for example if Command A requires some network IO that blocks, fine, no problem, it is on its own thread
21:14:37
jmercouris
if command B is simultaneously blocked waiting on user input, again, no problem, on their own threads
21:15:01
|3b|
ok, for that you probably want a thread per command (or more likely a thread pool, so you don't create threads for tiny things)
21:15:54
jmercouris
Maybe I'll start with the sjl macro way as it will be easy to integrate into my system, and try the thread pool on an experimental branch after the GTK release
21:20:23
jmercouris
|3b|: Yeah, I don't have to cover the general cas at this time with the CPS, just input, if in time I find users writing commands with other blocking operations, then the thread pool solution may make sense
21:20:48
|3b|
either way you might need to be careful with any interaction scripts might make with shared state (like page contents), though amount and type of care probably differs
21:21:19
_death
jmercouris: oh it's just hard, bitter experience.. there are powerful abstractions that are much simpler to use for most purposes.. see lparallel's for example
21:22:52
|3b|
which now that i think about it might be a problem with hidden CPS transforms, might not interact as expected with specials or with-foo macros
21:23:43
jmercouris
|3b|: I was thinking users using that with* macro might make assumptions that don't hold true, consider this example: https://gist.github.com/472724f1e5a11b99dfad3ac3a987538c
21:24:49
_death
jmercouris: there are libraries like green-threads that use call/cc (in turn implemented using CPS conversion, at least in arnesi)