freenode/lisp - IRC Chatlog
Search
8:02:11
beach
I'm confused. I thought LdBeth indicated a problem, so I spent this time trying to confirm it, but found that there isn't one. Then LdBeth says "for me it works perfectly fine", and I don't know why I spent all this energy.
8:04:11
Inline
i suppose one should abstain from asking further in such a state and abstain from providing answers too
8:06:34
|3b|
beach: sounded to me like the problem was in usage rather than mcclim and your effort helped resolve it
8:07:26
|3b|
though possibly with a "it would be nice if mcclim could shut things down enough to dump a core" on the side
8:08:04
|3b|
ACTION has no idea if that is possible or not though, or if starting threads breaks cores even if they all shut down nicely
9:50:55
pjb
gorgi: I don't know, but I could find out. Try to find out yourself, it should not be that hard.
9:53:14
pjb
Following some links you get to https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-lisp.html
9:54:18
pjb
The last google search that led to that was: org mode how to specify block code language
10:54:09
gorgi
pjb: I already tried that. I didn't say so because long questions including details like that tend to be ignored. All that does is create a new variable. I've tried modifying ob-lisp.el.gz, but it won't let me.
10:59:33
pjb
gorgi: if it creates a new variable, it means you don't have the right version of org-babel.e
10:59:51
pjb
If you have a more recent version, then you will have to find the new mechanism. If you have an older version, then upgrade.
11:05:13
no-defun-allowed
It's pretty simple, I want to write some stuff to it via a stream and see what it responds with and what it does.
11:06:01
no-defun-allowed
How could I feed it using a kind of "null modem"ish stream? I want to read and write from one end and on the other (but in reverse).
11:06:50
no-defun-allowed
So far the best solution I've thought of is using string streams and a twoway-stream since I can use any number of streams, as the protocol is relatively stateless. Is there a better way to make such a "null" stream?
11:09:48
no-defun-allowed
https://en.wikipedia.org/wiki/Null_modem might be relevant for anyone who's never seen one before. Wait, that's me. ):
11:11:18
|3b|
(looking at the docs for it, probably not unless you need binary or bivalent streams instead of string streams)
11:11:48
no-defun-allowed
Yeah, I just need to work with text, in a way that somewhat replicates a TCP socket without spinning one up preferably.
11:12:23
no-defun-allowed
After making the event loop into an event handler, I can single-step events so I'll just make one, handle one and repeat.
11:59:35
jebes
god to think i'm employed as a dev and highschool was 4 years ago :/ I don't think that's supposed to happen
12:54:21
elderK
Guys, when should you create and use your own conditions? Starting out, I'm not really sure how to signal problems in the Lisp way
12:54:56
elderK
There seem to be many ways to signal errors. So, like, getting a feel for when to use what, would be useful.
12:55:29
pjb
elderK: first you should note that the condition hierarchy in a program is often as numerous if not more than the program class hierarchy.
12:56:26
beach
elderK: In SICL, the idea is that I always signal a particular condition. That way, client code can handle each one separately.
12:56:58
pjb
But then, you may notice that a lot of implementation define an implementation specific set of simple-error and simple-whatever condition, that in addition tot he standard parameters, take a format-control and format-argument string to display a nice simple error message.
12:57:19
beach
elderK: Sometimes I am lazy and I signal a simple-error or something like that, but it's a temporary solution when I am in a rush.
12:58:10
pjb
The question is when you want to catch and handle those errors. This is when you want the most precise condition class, with the most useful slots.
12:58:38
pjb
You cannot count on a format argument list to extract the parameters of the error to process in a handler. This is too brittle.
13:00:36
pjb
And finally, if you create a condition class, it becomes part of the API. client code may expect to receive this condition from time to time. If it never occurs, useless code may be written, transitions not taken and program not working.
13:00:54
|3b|
ACTION thought format-control and format-arguments were part of standard simple-condition
13:01:11
elderK
I guess I'll look around on Github, try and see how often people do like, condition stuff. To try and get a feel for how I should write my stuff.
13:02:24
pjb
elderK: you'd start by using (error "message ~S" argument). Then when you try to handle errors, you will notice what specific errors you want to deal with, and define conditions for them.
13:03:52
pfdietz
I also suggest you do not count on the errors provided by the implementation. For example, (car x) is supposed to throw a type-error if X is not a list, in safe code. But in code with safety < 3 anything could happen.
13:04:36
pfdietz
Using assertions to signal errors rather than as signs something has gone horribly wrong with your program is also bad.
13:04:36
pjb
Yes, CL is way too underspecified about conditions signaled. They're a late addition to the standard…
13:05:17
pjb
pfdietz: this is discutable. assert signals a continuable error when you give places to modify in restarts…
13:05:26
|3b|
ACTION would count on errors from (car x) for safety > 0, and not use any implementation where it doesn't :p
13:06:24
pfdietz
The restatability of asserts is another reason not to use them as error signals, if you don't actually want that restartability. Lots of code gets generated. Internally, SBCL uses AVER which skips the restarts.
13:08:54
pfdietz
I put in a wishlist ticket for SBCL to mark all error signalling code as "cold" and try to move it out of line with other code, so it doesn't clog the instruction cache.
13:09:50
elderK
Well, I'll make sure to use check-type at the "top level" of my stuff. Assertions and things too as per usual. But, those are for me, not for the users.
13:12:55
elderK
I've just been using check-type like an ordinary kind of function, before I do "the stuff" :)
13:13:14
pfdietz
A declare is an assurance to the compiler about what the values of variable will be. The compiler could use it to optimize away the check.
13:14:16
|3b|
(if your implementation isn't smart enough to figure that out for itself, sbcl usually is)
13:14:56
pfdietz
And if A is never assigned to, you don't need the declare. Type propagation from check-type should do what you want.
13:36:12
elderK
I find check-type useful, as it prevents you know, stupid mistakes. And also adds documentation in a sense. Assertions for more "stupid mistake" checking :)
13:42:12
void_pointer
elderK: I think most people do it when the API has converged a bit and they need more performance.
13:43:25
elderK
It seems like, unless you really really need the performance, adding them is like, polish )
13:44:07
elderK
I was also wondering how expensive destructuring-bind is for simple.. destructuring, like, extracting stuff from a cons pair and stuff.
13:44:27
void_pointer
forcing the numbers to say be a fixnum means that you can't handle big integers where the definition of big is implementation dependent
13:45:11
void_pointer
declarations do indeed make it harder to refactor since you have to track them all down, especially for things passed between many pieces of code
13:45:25
elderK
Makes sense, tag requirements etc, impl-dep. And like, they probably would be on 64bit, but not on 32bit.
13:45:44
elderK
beach: Ah, good. So, unless I'm doing something really heavy, I shouldn't feel too bad about using it?
13:46:31
void_pointer
elderK: on most systems, the size of a fixnum is a signed integer with a number of bits equal to the pointer size minus a few bits. So on 64 bit systems, it is often something like 60 bits. On 32 bit systems, it is often something like 28, 29, or 30 bits
13:46:51
elderK
I guess it's too early in my experience to really care about performance too much but like, I'm having a hard time getting a feel for like, how expensive some things are.
13:46:59
void_pointer
but some use much lower values. I think clips uses 29 bits even on 64 bit systems if I remember correctly
13:47:05
elderK
I mean the high level stuff, sure, I can get that. Use the right data structures, etc.
13:47:32
elderK
Sometimes I don't want to add another level of nesting, just to have a let to store the info
13:48:04
ggole
elderK: disassemble might help, if you are comfortable grovelling through low level code
13:48:28
elderK
What are the "good" implementations? I've stuck with SBCL mostly because it seems to be well supported. I use my own package of it. I've seen Roswell before, and that seems interesting. Perhaps a good way to ensure what I write is "portable".
13:48:42
beach
elderK: If there is a function call in between, that call may well result in a CHANGE-CLASS.
13:49:11
elderK
So basically, if I need to use something from a slot several times, I should create a binding to "cache" that, as it wer.e
13:49:23
void_pointer
elderK: there are quite a few good implementations. One approach is to develop primarily in one but at least check if your code works in other ones.
13:49:57
elderK
I started with ECL long ago - but had problems. But then, that was like ten years ago :)
13:50:42
elderK
I have a bunch of questions about CFFI, too, mostly to do with libraries on different systems. But, I think I'll leave them for another day.
13:51:17
void_pointer
elderK: now days, though, it has some issues due to it not receiving much development in a long time
13:54:02
void_pointer
other implementations that some people use are Clasp and ABCL, which are useful for working with C++ and Java respectively. Should mention that if ECL is compiled with C++ support, it works with C++ as well, well enough that it has Qt5 bindings available
14:23:58
void_pointer
buffalofrank: I don't know about scikitlearn, but with regards to jupyter, yes
14:24:49
void_pointer
buffalofrank: in fact it can be used with jupyter with https://github.com/fredokun/cl-jupyter
14:25:09
void_pointer
buffalofrank: and https://github.com/tamamu/darkmatter provides similar functionality
14:25:45
void_pointer
buffalofrank: https://common-lisp.net/libraries is a very good reference for some of the libraries, utilities, programs, etc out there
14:49:14
void_pointer
buffalofrank: it is only really textbooks that have exercises. Most other technical books do not. Some text books do not, even. Writing a textbook is a whole different ball game than other kinds of technical books largely because of exercises. The other kinds of technical books have their own special things.
14:58:18
void_pointer
one of the hard things about making exercises is that one has to make sure it is actually possible to do them and then be able to do them correctly. Otherwise, lots of unsolvable problems and errors slip through. Even with diligence, it can still happen.
14:59:59
beach
"Write a program P that takes a program Q and some input data D to Q and that answers YES if Q always terminates on D and NO otherwise."
15:04:04
void_pointer
beach: well known to be unsolvable unless restrictions are placed on Q. An example restriction would be to make it sub-turing-complete and if it is sub-turing in the right way, it can be done
15:04:39
void_pointer
as in, force Q to be written in a sub-turing-complete language or something like that
15:07:28
kuwze
does anyone know how to get sly to work with company? It looks like sly-company was integrated into sly, going by the repo: https://github.com/joaotavora/sly-company
15:15:19
kuwze
sorry, I meant it doesn't work in the repl. it seems to work fine in a file by comparison.
15:19:34
buffalofrank
void_pointer: The Art of the Metaobject Protocol is another example with exercises :o
15:21:06
void_pointer
since I have been steadily running into a need to customize classes beyond what is doable just with the ANSI standard. That, and the MOP is pretty interesting as a whole
15:25:43
pjb
beach: What does "always" mean when the input data is fixed to D? Do you assume random internal functions, or unspecified input data?
15:26:14
void_pointer
beach: making some slots read-only (like struct), making others so they can't be changed eveh with slot-value to something without a validation function running on them first, etc.
15:27:14
void_pointer
beach: in principle, one can make wrapper types and use those for the slots, but that is a bit of a hack and seems brittle
15:28:00
void_pointer
beach: though I haven't tried it yet. Right now, I just am careful about making my own writers and not using slot-value outside of the package the class is defined in
15:28:52
void_pointer
basically, if I somehow manage to get an instance into a valid state, I want to make sure it can only change states to other valid states
15:30:53
void_pointer
only if one wants to go further and make it work for slot-value, would one need more
15:32:32
void_pointer
but also, it is useful for when others use the code. Easy to discipline oneself, hard to discipline others
15:33:04
void_pointer
but this is for a long ways down the road. Maybe in a year. For now, I just keep myself in line on the protocol
15:34:43
void_pointer
guess it is a bad habit of mine that I almost write more code verifying input and checking internal consistency than code that actually does stuff
15:35:03
loke`
beach: Wrt your never using SLOT-VALUE. I am of the same opinion, but I have ome exception: I sometimes use it in INITIALIZE-INSTANCE methods.
15:35:47
void_pointer
INITIALIZE-INSTANCE is an acceptable place to use it. After all, one already knows one's hands are in the fire
15:36:05
beach
loke`: I see. I tend to use reinitialize-instance instead. That way I am consistent with the protocol, which consists of accessors and initargs, but not slots.
16:05:20
kuwze
does anyone know how to get sly-mrepl to work with company? It looks like sly-company was integrated into sly, going by the repo
16:13:30
mfiano
kuwze: It does, assuming you have the proper company backend available in each buffer
16:14:08
mfiano
You could inspect the company-backends buffer-local variable, and ensure it has company-capf
16:17:35
jmercouris
phrased another way, how can I iterate through all objects for which char-codes returns an integer value?
16:19:56
mfiano
kuwze: No problem. If you need help configuring Sly to be more usable, you can take a look at the common-lisp-sly project, which is a Spacemacs layer I wrote when I was using such garbage (just google for it should take you to my github)
16:21:55
kuwze
I was surprised, it seemed like the author trashed it: https://github.com/joaotavora/sly-company/blob/master/sly-company.el
16:22:46
kuwze
like emacs lisp: https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html
16:22:50
mfiano
It was once an external linux package, requiring more work to integrate with Sly. Now, it's a first-class citizen with no configuration needed
16:22:59
kuwze
it seems to be defined http://www.lispworks.com/documentation/lw60/LW/html/lw-837.htm
16:23:19
kuwze
but company mode isn't showing any completions for defad... so what am I doing wrong?
16:23:20
dim
jmercouris: I just found sb-unicode::char-code-limit which might answer your question if you're using SBCL, see https://github.com/sbcl/sbcl/blob/e98378ca004ef6d101b384f6c3130f24b7a1bc1f/tests/unicode-misc.pure.lisp#L47
16:24:49
jcowan
jmercouris: The best you can do is iterate between 0 and (- char-code-limit 1), calling code-char on each, but being prepared to deal with char-code returning nil.
16:25:43
wusticality
Am I right in assuming that this channel is dedicated mostly to CL? Or are topics like Clojure ok to discuss
16:27:16
jmercouris
jcowan: let me describe what I'm trying to do, and tell me if you think this is a smart or a unsmart idea
16:27:30
jmercouris
(define-key *minibuffer-mode-map* (kbd "b") #'(lambda () (self-insert (mode *minibuffer*) "b")))
16:27:47
pjb
void_pointer: you need to check inputs only in public API functions. ("entry points"). Internal functions can assume correct inputs and types, since you will have proved them.
16:27:52
jmercouris
so I was thinking, it would be nice to write a macro that iterates through all of the supported chars and sets up a self-insert for minibuffer-mode-map
16:28:43
pjb
jmercouris: (loop for code below char-code-limit for ch = (code-char code) when ch do …)
16:28:49
jmercouris
however, with 1 million values on my machine, I imagine that will take some time...
16:29:31
sjl
wusticality: if you have questions about CL, or like "I would do X in clojure, how would I do this in CL?" those would be okay here. But if it's just general chat about Clojure, that would be ->#clojure
16:30:09
pjb
Nope, it's (+ (expt 2 20) (expt 2 16)) #| --> 1114112 |# a perfectly reasonable number.
16:30:49
jmercouris
but I don't imagine many people need to enter chinese characters into the minibuffer
16:31:21
mfiano
The lambda macro expands to (function (lambda ...)) which is the same as #'lambda, just less code. More importantly though, if you're in code position the macro will do the correct thing, or you're in data position and using #'lambda will expand to (function (lambda ...)) which is not evaluated. lambda may not even be cl:lambda so the expansion of (cl:function (pkg:lambda ...)) won't even be valid. So best
16:31:27
jcowan
No Unicode character will ever be assigned a codepoint higher than #3FFFF. (People who have bet against me on this, with a time limit, have always lost.)
16:31:28
pjb
(time (loop for code below char-code-limit for ch = (code-char code) when ch do (identity ch))) took 17,230 microseconds (0.017230 seconds) to run.
16:34:54
jcowan
Not a book, another Lisp language. It was to make ISLisp easily implementable in Common Lisp that the lambda macro (as opposed to ((lambda ...) ...) and #'(lambda ...) was added, almost at the last minute, to Common Lisp.
16:50:10
macaroni_destroy
Hi folks. I'm trying to solve this problem in hopes of helping to get SBCL added to the Kattis online judge. https://open.kattis.com/problems/different
16:54:57
beach
macaroni_destroy: Do you want a suggested solution, or do you want to work on it yourself for a while?
16:59:04
macaroni_destroy
I'd like a suggested accepted solution, yes. I'd also need to provide solutions that result in the various other judgement types, those being 'Wrong Answer', 'Time Limit Exceed', 'Output Limit Exceeded', and 'Compile Error'. They're interested in seeing the different ways the program for the program to crash or run out of memory, as well as what is
16:59:04
macaroni_destroy
safe to return to the user when it comes to output from a crashing program.
17:00:13
macaroni_destroy
I'm still learning Lisp myself, but trying to help get it added to more online judges, because I think they help a lot and are just nice for solving problems in spare time.
17:02:21
macaroni_destroy
Thank you. I'm making a git repo now with various types of submissions. Going to use these when turning in the results.
17:03:03
beach
(loop for first = (read *standard-input* nil nil) until (null first) do (print (abs (- first (read)))))
17:04:07
jmercouris
is a looping approach more memory intensive than using map on a list of objects?
17:04:19
jmercouris
are there any fundamental differences in CPU time and memory? or is it just preference
17:04:40
jmercouris
I guess it is implementation dependent, but I am asking the "in-general" question, whatever that means
17:04:47
beach
jmercouris: If you use MAP, you typically need to create a closure and invoke it several times.
17:05:15
sjl
If you can generate the objects as you go, a LOOP approach would let you avoid ever having to create the list all at once in memory.
17:05:44
pjb
jmercouris: Nothing prevents you to specify a given character set, and to iterate only over that character set. Nothing will prevent users to reject your software if it doesn't support unicode either. That said, if you write the software to drive a time machine, I wouldn't care at all if it used only ASCII.
17:06:57
jmercouris
I will time it, I'm actually quite interested to see how much of an impact it will have
17:09:34
jmercouris
mfiano: it went well, it is not nearly enough to cover the costs, I guess that will come out of pocket :D
17:10:14
jmercouris
beach: I'm so close to the dream that you described approximately a year ago with the lisp core and the separate gui process/framework communicating over IPC
17:10:38
jmercouris
I've grown so much in that time that I look over my old lisp code, and it makes me cry :D
17:19:40
macaroni_destroy
Well I'm going through all the variations of the programs provided, and for the one for output limit exceeded, I don't think I'm getting the appropriate response from the repl. Perhaps compiling it would yield different results? I'm running (loop (repeat 10000) (print "wow")) and getting "The function COMMON-LISP-USER::REPEAT is undefined".
17:22:00
jmercouris
macaroni_destroy: you can read about the loop macro here: http://www.gigamonkeys.com/book/macros-standard-control-constructs.html
17:22:29
jmercouris
macaroni_destroy: you were trying to invoke a function REPEAT with an argument of 10000, and since REPEAT is not a function, that's the complaint you got
17:41:19
dim
(defun sql-lock-waiting-p (waiting) (member waiting '(:nowait :skip-locked))) (deftype sql-lock-waiting () '(or null (satisfies sql-lock-waiting-p))) (defstruct sql-lock (strength nil :type sql-lock-strength) (table-name nil :type (or null string)) (waiting nil :type sql-lock-waiting))
17:44:20
dim
my goal is to simply define what I expect in some struct slots, here it's a member of a list of keywords
17:45:09
dim
for that I had to define a predicate function, then a type that uses it, and then assign the type to the structure... I don't guess it's possible to do something like :type (or null (member :a :b:c)) directly in defstruct?
17:46:26
macaroni_destroy
I have an accepted answer, wrong answer, time limit exceeded, output limit exceeded, and compile error. Any advice on how I could achieve a Run Time Error for the problem (https://open.kattis.com/problems/different)? I am trying to follow https://open.kattis.com/help/judgements#rte to understand how the online judge judges runtime errors.
17:47:56
macaroni_destroy
Also trying to achieve Memory Limit Exceeded (https://open.kattis.com/help/judgements#mle). :P
17:48:49
jmercouris
if I manually write define-key for each key code it works properly, if I do it in a loop, everything is set to the last value in the loop
17:49:28
dim
macaroni_destroy: (handler-case (main-code-here) (condition (e) (format *standard-error* "~a" e) (uiop:exit 1))) at the top-level might get you covered?
17:50:27
dim
jmercouris: loop creates a single binding (ch here) that is assigned the values one after the other, and you keep changing the binding, and everything points to that binding...
17:51:48
jmercouris
that's what perplexes me about it, I'm getting the value of the binding at that time, not using the symbol or anything
17:53:55
dim
jmercouris: yeah but I think the do block in your loop exists only once, you can see that when expanding the loop (macroexpand-1 '(loop ...))
17:54:26
dim
macaroni_destroy: yeah, capture anything that might happen with handler-case and exit 1 in that case, that's your run-time error right?
17:59:02
dim
beware that it will shutdown your lisp process, so kill your Emacs SLIME session if you're using that
18:09:53
pjb
macaroni_destroy: sbcl compliant is not a notion. You can choose to write conforming code, that will run on all conforming CL implementation the same way. Or you can choose to write implementation specific code, which is unintersting to me.
18:10:25
pjb
macaroni_destroy: there's no quit or exit in Common Lisp. Once you start CL, you remains in CL forever.
18:33:09
macaroni_destroy
I think the last thing I'll need is a program that generates a Memory Limit Exceeded error and "a list of the Ubuntu packages for the language that needs to be installed, what directories needs to be available in the sandbox for the language to work well, and a reasonable set of compiler and runtime flags for competitive programming"
18:33:46
macaroni_destroy
As far as particular compiler flags for optimization, I'm a bit stumped there.
18:34:23
puchacz
hi, can I write something like (my-function :size <value-indicating-using-default>) ?
18:35:11
macaroni_destroy
This was the email I got from them, if anyone wondered, so I would guess I'm almost done providing everything https://0bin.net/paste/QdhVj5DR8zDDmM4a#L6T+U8M8V4aHTXyR+VFwoTUyMYMx4QYPXDf6YHQauLD
18:35:55
macaroni_destroy
I'm going to donate to their patreon once I've submitted everything to them so there's extra incentive
18:36:23
puchacz
anamorphic: but I would like to call it with :size, but for certain values I want it to use default
18:36:59
puchacz
so I would have a code (my-function :size size-passed-from-surrounding-code) without any conditionals
18:37:57
puchacz
(defun my-surrounding-function (&key (size 30 size-provided?)) ... (if size-provided? (my-function :size size) (my-function)))
18:40:41
anamorphic
(let ((*size* 30)) (my-surrounding-function)), where (defun my-surrounding-function (&key (size *size*)) .. (my-function)) where (defun my-function (&key (size *size)) ...)
18:42:31
trittweiler
puchacz, (apply #'the-function `(1 2 :foo 23 ,@(when size-p (list :size size))))
18:48:08
trittweiler
puchacz, One another way is to make sure that NIL will be interpreted as the default value to. So in your my-function make sure that you use (or size 30) at the appropriate place
18:52:09
macaroni_destroy
What are some ways to allocate a lot of memory in SBCL? Let's say I wanted to allocate more than 1024MB.
19:00:30
macaroni_destroy
shka_ I'm talking about the simplest program that can allocate 1024MB. Are you saying SBCL can not run programs that grow that large in memory, while running, by default?
19:08:53
macaroni_destroy
going to step out for a moment and will be back to try to make a simple program that can grow past 1024mb
19:19:50
dim
it just feels strange that symbols from any package would "magically" work with loop, and also that would intern all those symbols in the package too, well, I think?
19:51:22
frgo
Hi there. Anybody here having experience with cl-autowrap? I need to pass a "-DFRGO=1" to c2ffi - How would I do that with autowrap? Thx for any hints!