freenode/#lisp - IRC Chatlog
Search
22:45:14
__rumbler31
yea I don't understand this thread, but i'm intrigued, and have to go. Happy V day y'all
23:15:36
otwieracz
https://gist.github.com/otwieracz/db012be5e986dde28d518aeb8ff593dd I've got some lparallel magic here - it breaks read-write lock implementation.
23:16:13
otwieracz
Regular BT threads work just fine, but when I try to use it inside lparallel channel - magic happens and stuff breaks.
0:14:51
dto
i'm curious to know if you have any thoughts or recommendations on day planning? https://i.imgur.com/mym4DKo.jpg i'm working on some lisp to make nice cards
0:18:37
jasom
otwieracz: it looks like you are exiting your lambda without releaseing the lock; did you try a test where your thread performs the lambda many times?
0:23:12
jasom
hmm, I wrote a test that does it and it completes, but the mutex was still being held by an exited anonymous thread
0:24:37
jasom
otwieracz: try running test2 two times in a row, it will deadlock waiting on the mutex the second time
0:33:19
jasom
otwieracz: sorry that was wrong; if you run test2 rwlock-resource is still owned by an exited thread despite the rcount being zero
0:41:27
jasom
otwieracz: adding a (print (rwlock-resource rwlock)) immediately after the release-lock line in read-lock-end shows the lock as still being owned. This is bad
0:43:39
jasom
otwieracz: aha sbcl's mutex release silently returns if the current thread is not the owner. You want a semaphore, not a mutex for rwlock-resource
0:50:36
jasom
otwieracz: I have to go, if you still haven't figured it out in a couple hours I'll comment on the gist with a fix
0:58:48
emaczen
how can I force ASDF to force load all systems or is that what the :force keyword does specify?
3:27:34
White_Flame
but yeah, it probably doesn't know defpackage, so it's trying to evaluate the arguments
5:07:53
whoman
class definitions especially, i think method/generic is quite nicely clean. maybe i will make a macro for myself for defclass, i find it is unnecessary to (slotname :initarg :slotname :initform nil ..) rather than just (slotname) but perhaps it is my reading comprehension that is not verbose enough
5:11:22
whoman
hmm true about java.. i am also overly accustomed to class definitions being in one place/block with the associated methods/interface
5:15:12
pillton
It is wrong to think that generic functions are equivalent to methods/interfaces in C++, Java and Python.
5:23:28
beach
whoman: The reason for the slot options is so that you can apply fundamental principles of software engineering, such as access control, abstraction, data hiding, etc. If you remove those options, those aspects can't be controlled. But perhaps you are not used to programming in large projects where several people need to collaborate and where long-term maintenance is a real concern.
5:27:02
beach
This is also why most people here reject any attempts at "simplifying" class definition by defining a custom macro with fewer slot options. Usually, such attempts boil down to not caring about the difference between interface and implementation.
5:29:04
whoman
i can fully understand these things =) but, to type the same slot name twice i feel could be optional
5:33:47
rme
Lots of people try writing a defclass wrapper macro. Many ultimately decide it was a bad idea.
5:34:13
beach
Because then, when you reload the class, the slot will get a different name, and you will have huge classes in the end with lots of gensymed slot names.
5:34:57
beach
whoman: Furthermore, CLOS needs to know to merge slots with the same name in subclsses.
5:35:26
whoman
hmmm. what do people use as convention for slot/accessor name differences? i've seen '%'
5:36:32
beach
whoman: That's what I use. Some people put a suffix -of on the accessor. Not many people like that convention though.
5:37:11
beach
whoman: You may want to have an exported reader and a private writer, so you need two different names.
5:38:16
pjb
On the other hand, often (99.99%) slots are not sophisticated: their accessors don't do anything but setting or reading the slot.
5:38:51
pjb
And if they do something, often (0.009999%), they do something that is systematical, so you do want to generate them with your own macro.
5:38:55
beach
whoman: Also part of the verbosity you see is that in Common Lisp, you can write :ACCESSOR BLA wheras in Java, you have to write separate get_bla and set_bla functions which is even more verbose.
5:40:48
whoman
pjb, i agree there, but maybe then one should be using structs for the simple objects
5:41:16
pjb
If only you could redefine structs easily, and if only their accessors were generic functions…
5:41:39
beach
whoman: There is just so much variation between :initform or not, between a single :initarg or several, between :reader or :accessor, that it is usually not worth the effort to try to simplify.
5:42:41
pjb
When I say write your own macro, it should not be purely syntactic. It should be motivated by semantic reasons. For example, you can write a define-entity macro.
5:43:24
pjb
At the application level, you don't care about slot names vs. accessors, and what mechanism you have to put into accessors automatically. This should be abstracted in an application-level define-entity macro.
5:44:40
pierpa
defclass being verbose, means one has a few seconds more to think about what they are doing :)
5:45:42
pjb
That said, using a define-class macro with the same syntax as defstruct is a nice way to upgrade your structures to classes.
5:48:07
whoman
all of it agree! thanks guys =) the most i will do for syntax is to split up single slot defs on different lines, for my requirements of visualising my datatypes. then, doing the right thing at the application level.
5:49:07
whoman
i see a lot of lisp code that is too 'bare knuckle' , directly using low level system ops in application level. i definately feel the same, that building up higher level DSL to the application itself is the right way
5:49:44
whoman
i think the gap between "bad" lisp code and "good" lisp code is not as wide as with say, C or Java =)
5:59:37
beach
Well, C is a strange thing. Because of lack of capabilities for abstraction, it is unfit for application programming. And in order to use it for system programming, you often have to rely on behavior that is undefined in the language definition and therefore specific to a particular compiler.
6:13:21
stylewarning
But C is easy to write in the sense you can vomit something into your text editor and it will compile and behave approximately correctly
6:23:17
stylewarning
Yeah, “approximately correctly” should have been “remotely correctly but good enough for managerial sign off”
6:34:32
krwq
are there any recommendations for generic function which returns sequence of values ideally without allocating it? I was considering returning lambda which returns next value with each call and cl-coroutine - are there any recommendations/most popular conventions here?
7:07:43
pjb
krwq: (defgeneric foo (sequence) (:method ((sequence sequence)) (map-into sequence (lambda () (random 1.0))))) (foo (make-array 3)) #| --> #(0.40184024 0.6305135 0.7736664) |#
7:10:53
otwieracz
jasom: Thank you! There was late night already in my timezone, but I will test it right now!
7:15:26
pjb
(let ((pre-allocated (make-array 3))) (print (foo pre-allocated)) (print (foo pre-allocated))) #| #(0.86955583 0.60453916 0.62688285) #(0.96605814 0.63317955 0.62401444) |#
7:18:02
pjb
lazily evaluated sequences… Yes, in CL you can use iterators, ie. functions returning the next element.
7:18:52
Mr_Tea
how do I get a carreer in lisp? do I need to know it beforehand or do people train new hires if they can code.
7:19:22
pjb
Mr_Tea: you start up your own company, you get paying customers, you implement their solution in lisp.
7:20:01
pjb
Mr_Tea: actually, start first by finding paying customers. Then start up your company and implement their solution.
7:20:53
pjb
Mr_Tea: of course, the downside is that you must be prepared to do a lot of sales, hr, and management work, before you can write your first line of lisp code.
7:22:12
pjb
He's having a few talks with his rocket ingineers, but he spends most of his time managing his corporations, and finding paying customers and money to pay his rocket ingineers (and all the carbon fiber and stuff needed to build them).
7:24:08
aeth
Create a rocket company in addition to a Lisp company. Launch Lisp into space and use that to promote the Lisp company.
7:26:35
krwq
beach: how do I return that generator function in another function? I tried wrapping it in another lambda but neither works - only when I use it within body of that with-hash-table-iterator
7:27:44
pjb
krwq: it's useless for your purpose, but as an example, since hash-tables are stored in memory, not lazy data structures.
7:28:14
pjb
(defun make-integer-iterator (&optional (start 0)) (lambda () (prog1 start (incf start))))
7:28:41
pjb
(loop repeat 10 with iterator = (make-integer-iterator) collect (funcall iterator)) #| --> (0 1 2 3 4 5 6 7 8 9) |#
7:28:58
krwq
pjb: this sucks - i can't use both paradigms - I want to have lazy abstraction and use maphash for testing and lazy implementation for normal use
7:28:58
pjb
krwq: if your sequence are finite, you will want to return 2 values, to indicate the end of the sequence.
7:30:00
pjb
(defun make-integer-iterator (&optional (start 0) (end nil)) (lambda () (multiple-value-prog1 (if (and end (<= end start)) (values nil t) (values start nil)) (incf start))))
7:31:03
krwq
I feel like I need yield here: https://github.com/takagi/cl-coroutine - I can't find source code for cl-cont though
7:32:50
pjb
(loop with iterator = (make-integer-iterator 0 7) for (i done) = (multiple-value-list (funcall iterator)) until done collect i) #| --> (0 1 2 3 4 5 6) |#
7:33:45
pjb
krwq: Using closures to generate a single element (or equivalently, a class as in com.informatimago.common-lisp.cesarum.combination) is simplier than using co-routines.
7:38:56
pjb
That's the conforming way to implement them in CL, but it's inefficient, and it requires heavy machinery to wrap the code of the co-routines inside-out.
7:39:40
pjb
Implementing co-routines with threads would probably be a better way than the inside-out thing.
7:40:48
krwq
I don't know what your library does, I need a simple abstract collection which gives me next element when I ask it to
7:41:26
stacksmith
aeth: Don't forget to lose a billion a quarter, and promise to deliver a product that cannot possibly support your burn rate.
7:41:55
pjb
krwq: think about it! hash-tables are NOT sequences, they're direct access data structures!
7:43:40
aeth
If you want something more useful: (defun make-approximation-of-e (&optional (start 1)) (check-type start (integer 1)) (lambda () (prog1 (expt (1+ (/ start)) start) (incf start))))
7:49:09
krwq
returning function sounds good to me but I need to be able to know how to use it with all lisp collections such as hash table
8:01:03
krwq
i like do-children i'll be able to do lazy and non-lazy, will feel lispy and I will be able to pass both name and node as arg
9:35:07
flip214
when using QUUX-HUNCHENTOOT I've got the problem that the browser (and seemingly HT as well?) hangs as soon as I run into an error.
9:35:49
flip214
I'm debugging (interactively) via swank, but upon choosing eg. ABORT the browser still waits for data; further http connections hang as well.
9:38:47
flip214
with the normal hunchentoot taskmaster allows me to debug multiple requests (and abort them ;)
9:41:56
smokeink
http://turtleware.eu/posts/cl-charms-crash-course.html "We are also very drastic with bt:destroy-thread, something not recommended in any code which is not a demonstration like this one." Why is the use of bt:destroy-thread not recommended for recreating threads?
9:55:44
fe[nl]ix
smokeink: on any implementation that uses SMP threads, bt:destroy-thread is a bad idea