freenode/lisp - IRC Chatlog
Search
11:44:42
drmeister
jackdaniel: My problem is this common scenario: A process is running and taking too long. I hit Control-C and a SIGINT gets sent to the process with an interrupt handler that calls #'break. sldb comes up and lets me inspect things. I decide I want to unwind the stack to above the loop that was taking too long.
11:47:17
jackdaniel
drmeister: in handler you may save, which thread is to be interrupted, and interrupt it from signal handler thread
11:49:01
flip214
so perhaps you'll need to "inject" calling some cleanup-code, that cleans up the caller chain
11:58:40
ogamita
or any other non-local exit destination: a block with a closure to return to it, a catch with an object to throw at, a handler with a condition to signal to.
11:59:56
ogamita
drmeister: sigint can be distributed to any thread by default. If another thread is interrupted, you will have to "go over" the thread you want to debug. Take this into account.
12:05:52
drmeister
I can't unwind to a restart established around the loop from an interrupt handler. It has no way to properly unwind the stack and call destructors when interrupting execution at an arbitrary point.
12:06:14
drmeister
It's a fundamental incompatibility between C++ exception handling and unix signal handler.s
12:07:33
flip214
drmeister: to interrupt a thread, set its instruction pointer to a cleanup function that knows how to unwind the stack frames.
12:08:15
flip214
as you generate the code, you can control whether there's a frame pointer to help you, for example.
12:09:47
drmeister
The only way I see to deal with this is from within the interrupt handler, maintain a thread-local queue that is polled from within the loop from a safe-point, and then from the safe-point unwind the stack. It means I need to insert safe points into loops somehow.
12:12:37
drmeister
flip214: This is what I'm saying, there is no cleanup function that knows how to unwind the stack frames. Unwinding the stack in C++ is a very delicate process. It only happens from 'invoke' instructions that are like 'call' but have a second return path that goes through 'landing-pads' that know how to call destructors and unwind the stack. This is how
12:14:57
drmeister
Interrupting a thread means that after any arbitrary instruction, an interrupt can come in and the stack can be taken over by the interrupt handler. Things can be set up so that the interrupt handler returns to the next instruction, but there is no way to unwind to a frame above that because there is no way to identify an appropriate landing pad to start
12:16:25
flip214
well, how about just _killing_ the thread and running the cleanup fns in another (newly created) thread?
12:20:16
ogamita
drmeister: I don't understand why there would be an incompatibility between unix signal handlers and C++ exception handling.
12:21:05
ogamita
drmeister: Also, if you handle the signal in a specific thread, you reduce the problem to some thread-thread communication.
12:26:20
ogamita
Given the restrictions on what you can do in a signal handler, this thread would be a trampoline to dispatch and process signals.
12:27:03
jackdaniel
shka: check out src/c/unixint.d comment at the top if you are interested in details
12:46:13
drmeister
Thanks everyone for the feedback. I've been mulling this over and reading up on it for a week. I just wanted to get some input from lispers on it.
13:26:32
dwrngr
The way that letter is written I wouldn't expect anything in it to be accurate, even in 1997 :P
13:53:44
nyef
drmeister: I fail to see that C++ exception handlers and unix signal handlers are fundamentally incompatible, though I could easily see the toolset being lazy about adding .eh_frame sections for the entry frame for the signal handler.
13:55:58
nyef
drmeister: Which suggests that it might be patchable at runtime, though that way probably lies madness.
14:58:42
ogamita
gargaml: IIRC, PCL was written with such a DSL. it should be available in some git repo somewhere.
17:03:34
whoman
hi! =) i do not wish to distribute my code until my project matures. is creating executables with ECL a good way to hide the code from reversing or introspection ?
17:06:56
beach
whoman: What is your reason for not wanting your code exposed early? There are some great advantages to that, in that you will get suggestions for improvements.
17:07:03
whoman
hmm. my intuition tells me that making the lisp into C and then compiling, could really help. but it will still link with ecl.dll and run as VM, i think. i've been googling for a little bit with no clear path
17:07:55
whoman
beach, some superstition, and some nervousness. as i am completely alone in the project (not even a single person in my real life who knows anything about computers) it will aid in creativity immensely
17:08:43
whoman
i am quite sensitive and having the code even backed up on a server that is not mine (google drive, dropbox) is also something i am not sure i would like to happen to my code while i am working on it (superstitions.)
17:09:25
daemoz
whoman: I disagree that keeping your project source private will help with creativity, but that's my angle.
17:11:20
beach
I find that any efficient learning experience requires making a fool of oneself by exposing one's naive early attempts.
17:11:23
JuanDaugherty
not distributing sources is contrary to the lisp culture. Getting paid for them isn't necessarily and may be a way forward in that it causes you to retain them till they're worth something
17:12:25
whoman
daemoz, okay, fair enough. but the thing about creativity is that it is personal. consider my immediate environment as my workspace. guaranteed most if not all of it is disagreeable to what inspires your own personal creativity.
17:13:38
daemoz
whoman: well you dont' know anything about me personally so you can't really say, can you?
17:13:56
whoman
JuanDaugherty, the massively grandiose concepts of cultural impact or business economics completely aside, this is a hobby project; it is like when i start to develop feelings for a lady. i wont tell any of my friends until it actually develops into something. maybe i am easy or gullible to "jynx"ing myself.
17:14:14
JuanDaugherty
also, you realize the age demographic in this computing culture is skewed beyond the normal burnout, people here have seen stuff
17:14:32
whoman
i do not wish to hide any secret formulas. but i am not making a generic utility library. i am making something for myself only.
17:15:59
jasom
whoman: I don't know how well obfuscated code compiled with ECL is; most lisps with code compiled with e.g. (speed 3) (debug 0) aren't a whol lot more reversable than C, though the presence of the runtime means there's a debugger already there rather than having to attach one.
17:16:15
whoman
it is simply "dont read my poem until i am finished" or "dont look at my drawing until it is complete".
17:17:05
JuanDaugherty
anyway a solution would be to distribute your thing as an all-in-one with fasls
17:17:15
whoman
jasom, mhmm, true. i will leave my peace of mind right there at that then, i won't worry about uninterning debugger/eval/inspect/do- symbols
17:38:49
JuanDaugherty
most of them actually. Reconstructing from an AST works for statement oriented langs.
17:48:24
jasom
some implementations save some parts ot the code in the debug information, but declaring (optimize (debug 0)) usually stops most of that
18:08:55
otjura
I started wondering why projects such as SBCL are still being developed actively. haven't they matched the ANSI spec years ago could thus be considered complete?
18:10:27
dlowe
You can always be more correct, faster, take fewer resources, behave better with threads
18:13:43
whoman
i had just been looking at sbcl changelog to see if i want to update (im on 1.3.9 and latest is 1.3.15) and they are mostly bugfixes, performance, memory footprint, etc.
18:14:29
whoman
if simply filling in the spec was all that we needed.. there might not be multiple implementations to begin with.
18:17:39
otjura
you know, I recently completed largeish university project in other language where documentation over 6 months old was considered quite obsolete so coming back to lispland for fun and recreation is such a stark contrast
18:20:06
whoman
hehe =) for me now, lisp is stark contrast to everything. thinking about parens and tree forms is my happy place. but i dont watch tv =)
18:24:20
otjura
I know the feeling. I'm so spoiled by this it was difficult to realign to assorted dot-notation with varying parens
18:25:22
otjura
that being said, I do think strong typing and varying syntax has benefits in large projects when returning to code. looking at large lisp projects I have real difficulty understanding what is going on
18:26:35
whoman
it is like the wife of my youth, if i had one. begain accidentally mingling with emacslisp right after C, a good 22+years ago, and following my wild oats to all kinds of linguistics only to end up back home where i'd essentially started. </monolog post>
18:27:42
whoman
yes i agree. being able to "inspect" the tree of a project or program i think would help immensely. but any book has to be read or written to stay fresh as it is static mysterious randomness until then
18:27:54
otjura
dlowe: definitely, always. strong typing simply makes it more intelligble what function accepts
18:28:50
whoman
but! symbolic atoms are unique by their nature. aren't those enough for any strength or strictness?
18:31:11
otjura
maybe from program's perspective. I find it much easier to deduce what goes into variable if its type is declared.
18:33:50
otjura
funny how the more I dabble with different languages the more Java starts making sense (please don't ban me)
18:35:24
TMA
I like even stricter types, like Damage Int, so that the 5 points of damage are incompatible with GoldCoins Int
18:36:56
jasom
dlowe: the limitation of type declarations is that when they aren't everywhere, then you can't have efficient recursive datatypes
18:38:37
jasom
e.g. if you could do (deftype fixnum-list (cons fixnum (or fixnum-list null))) it would be easy to show (cons 2 x) will be a fixnum list *if* x is is a fixnum list, you can't make any efficient assertions if the type of x is unknown.
18:50:16
whoman
TMA, me too. but honestly the gold ints and the damage ints should not come from or arrive at the same places in code. getting paid should not harm a player. unless, throwing money damages hp by monetary value ^_^ hmm.
18:56:06
jasom
There was a C variable naming convention to indicate this; e.g. _px for pixel distance so if you see something like position_x_in + distance_x_px; you could find the bug quickly by inspection (adding pixels to inches is meaningless)
18:58:12
nyef
Basically "our type system can't express this, so we'll shove it into the variable namespace and have the humans do the type checking."
19:02:32
pebblexe
how can I specify the limits of the type accepted for something?: https://gist.github.com/pebblexe/28473dc4b1a172e023c9d6f5a993e29c
19:05:29
pebblexe
Bike: but what's the point of declaring it after the function call except as an optimization? I would like to do something like this (defmethod test ((integer n)) ...)
19:05:46
pebblexe
I mean it would also catch errors, but I mean I am looking to dispatch on the type
19:06:08
Bike
you mean you want it to use one method if it's in that range, and another if it's an integer outside that range?
19:06:14
varjag
but whatever numeric optimization you make there, will be negligible after you cons all that into a list and (i assume) traverse it later
19:06:56
pebblexe
varjag: I am not worried about optimization, I just want to have good looking code
19:07:01
Bike
yeah, you can't do that. you can dispatch on integers and then do a basic (if (< ...) ...) in the body, of course.
19:07:31
Bike
you can't dispatch on types because any value belongs to multiple types that are not subtypes of each other.
19:09:00
pebblexe
Bike: the types are also a tree http://sellout.github.io/2012/03/03/common-lisp-type-hierarchy/
19:09:30
Bike
what is the relationship between "integers between 0 and 10" and "integers between 5 and 15"?
19:10:04
pebblexe
if I have a function that runs if 'x' is true about the variable, it makes sense to run it
19:14:00
Bike
hum, even in that image you can see non-tree-ness at simple-string and simple-bit-vector
19:26:31
scymtym
on a related note: this https://github.com/sbcl/specializable/tree/wip-type-specializer/src/type-specializer (example: https://github.com/sbcl/specializable/blob/wip-type-specializer/examples/type-specializer.lisp ) now mostly works with vanilla sbcl master. the previously mentioned problems w.r.t. sorting applicable methods remain, of course
19:29:45
pebblexe
is it possible to do it this way?: https://gist.github.com/pebblexe/1634baa131afd2c0a7cb236a3002dd89
19:30:29
Bike
no. (standard) generic functions specialize on classes. eql t and a function are not classes.
19:31:52
scymtym
pebblexe: https://github.com/pcostanza/filtered-functions may be interesting for you
19:32:33
jasom
pebblexe: usually if I want to do somethign fancy, I just use etypecase or optima or whatever.
19:33:03
pebblexe
jasom: yeah I've looked at optima, I was just hoping I could get some experience with clos
19:33:19
scymtym
iirc, fortress had a solution for this kind of applicable method ordering. i think it was something like being forced to define a method that is more specific than both of the ambiguous methods. but that seems to prohibit call-next-method
19:34:41
pebblexe
okay I am having issues where sometimes stuff doesn't compile after using defmethods to experiment, like it complains about something that I've commented out
19:35:17
pebblexe
I think it's only happened in ccl, but I think it might have happened in sbcl as well
19:35:50
Bike
when you recompile a function, you replace the definition, but when you recompile a file and you just commented out a method, there's no reason for that method to go away, you know?
19:36:09
Bike
what i do is M-x slime-inspect the generic function, and that brings up a menu where you can undefine particular methods
19:38:17
pebblexe
Bike: I am not sure what you mean, I mean functions go away when I comment them out, right? why are methods different?
19:42:50
Bike
your lisp image has a persistent state, calling load and whatnot just alters that state
19:43:03
Bike
defun adds a new function, but if it's commented out that just means it doesn't add a new function, not that it removes a function
19:43:09
daemoz
Bike: How do I undefine something from the slime-inspect menu? Just delete everything and press enter?
19:43:14
pebblexe
what does this error mean?: https://gist.github.com/pebblexe/31503c36172e43bc4c21ceb176d47d56
19:43:56
Bike
daemoz: you can remove particular methods by going to the line with the method and hitting enter. where it says [remove method]
19:44:25
nyef
pebblexe: I'm not too familiar with CCL, but I think that it's saying that the file underlying whatever stream that is was closed?
19:57:31
pebblexe
now I am getting this error trying to (ql:quickload "optima") https://gist.github.com/pebblexe/fd096a27962d9f81e6a5f7b8cac3c4b8
19:59:37
pebblexe
yeah and in sbcl I get: https://gist.github.com/pebblexe/d30811426c3a0109d6108fedaff04358
20:13:17
websterbudding
I'm having trouble parsing json strings in lisp. Both cl-json and yason require outer double quotes and escaped inner double quotes. But JSON.stringify does not generate escaped double quotes.
20:18:36
pebblexe
how do I use a package in a file that starts with in-package? for example I have (in-package #:cl-msgpack) and I would like to import optima
20:38:38
pebblexe
how do I create/append to a file? it seems that :if-exists :append causes it to error out if it doesn't exist
20:42:18
pebblexe
jackdaniel: okay, I was just going off of practical common lisp, but I'll check there too
20:45:20
pebblexe
how do I use with-open-file to point to a file specific to a directory? I mean slime starts up with what as the home directory to write to?
20:49:29
pebblexe
figured it out! it's (merge-pathnames (asdf:system-source-directory :cl-msgpack) "temp-bytes")