freenode/#lisp - IRC Chatlog
Search
6:43:55
jmercouris
Ah yes, I was always very good at data structures, but never good at time complexity
6:44:31
beach
And I bet the same people who "need all the performance they can get" are typically ignorant about those things.
6:45:27
jmercouris
Like, I had to implement a tree, and I couldn't remember how to do rotation transformation to keep it balanced
6:46:33
flip214
you'll need to know about various data _structures_ - linked lists, double-linked lists, arrays, hash-tables, binary trees, tries, skip-lists, bloom filters, etc.
6:46:37
jmercouris
flip214: Oh yeah, normally you are 100% right, this was a very particular use case
6:46:42
beach
Most professional software developers don't need to implement balanced trees. But they need to be "good consumers", i.e. knowing the performance characteristics so that they can choose the right data structure. But they typically don't, as flip214 pointed out.
6:48:07
jmercouris
It's very fun when you can get some clever tradeoff by combining several strategies together
6:48:28
jmercouris
or even by having the same data reprsented by several structures for performance gains in indexing, search, deletion etc
6:48:40
jmercouris
usually the memory of the data structure itself is so light weight that you can do so much
6:48:43
flip214
AFAICT, the big problem is not "choosing a red-black tree vs. an AVL tree", but "is it < 10 elements? use a list or simple array. is access needed in O(1)? use a hash-table. etc." (simplified.)
6:48:49
beach
shka_: Sure. I am one of them. My Cluffer library is an example of a data structure that I have been working on for a few decades.
6:48:50
shka_
personally i don't understand guys that have no clue about that structures because common, this stuff is awesome
6:52:04
flip214
jmercouris: see eg. https://news.ycombinator.com/item?id=15199642 for some discussions, also the article
6:53:26
beach
I don't think there is a widely agreed-upon definition of "buffer" as an abstract data type.
6:54:35
jmercouris
beach: In computer science, a data buffer (or just buffer) is a region of a physical memory storage used to temporarily store data while it is being moved from one place to another
9:23:23
phoe_
in other words, you don't. READ is able to return a special EOF value if it encounters an end of file.
10:26:57
phoe_
fourier: I have no means to test it on my own machine. Can you load CCLDOC with your version of CCL-COMPAT on LispWorks?
10:27:20
fourier
the ccl doc will work with these changes and https://github.com/Clozure/ccldoc/pull/9
10:28:10
fourier
they produce almost identical results with 2 exceptions: the class block in documentation is ccldoc:block now and </p> is on a newline in sbcl documentation
10:31:09
fourier
no problem! would be happy to use ccldoc with my code. guess "choice of documentation system" problem is solved for me now :)
10:31:30
phoe_
fourier: exactly our thoughts. our, as in, the group of people that are hacking away at CLUS.
10:32:28
phoe_
just one question remains: if ccldoc runs not only on ccl now, does it become just "doc"?
10:33:10
fourier
its their development after all, hope they will continue to support it and we will just occasionally provide patches :)
10:33:43
phoe_
I know, I know. CCLDOC is still integrated tightly with CCL, and I had to explicitly stub out some functionalities such as source tracking.
10:34:59
phoe_
flip214: it does not work this way. CCLDOC does not use source tracking itself. It only provides input to CCL's source tracking functionalities.
13:13:01
user|2
i was thinking about learning lisp but dont you need a mega memory to remember all those parentheses and is prolog better or another language for AI these days?
13:13:43
beach
user|2: Common Lisp is not particularly for AI. It is a general-purpose programming language supporting multiple paradigms.
13:17:42
beach
user|2: Experienced Common Lisp programmers don't count parentheses. They go by indentation. The editor computes the indentation based on the nested parenthesis. You see a mistake almost immediately.
13:23:47
phoe_
user|2: lispers never count parens or indent their code. It's their editor's job to do that.
13:24:37
user|2
thanks for that now i'm not so scared of trying to learn it. and those scary register names...
13:25:05
Josh_2
user|2: If you already know how to program in other languages I don't think you'll have any problems.
13:26:42
user|2
maybe prolog or i have named it wrong what i'm talking about but it seemed really arcane and non descriptive
13:27:43
phoe_
Prolog is pretty peculiar and has a very hard-defined programming paradigm. Common Lisp is much more freeform when it comes to programming paradigms.
13:27:47
shrdlu68
user|2: Prolog is quite different from most languages, even more so than Common Lisp.
13:29:14
phoe_
like that old joke, a Prolog programmer and his wife had a baby, and they asked him, "is it a boy or a girl?", and he answered, "true"
13:30:48
shrdlu68
user|2: If you're interested in it (python), learn it by all means. But Common Lisp is mostly just like any other language. Build webapps in it, write boring systems code in it, write skynet, write boring sysadmin scripts in it, write other languages in it...it's no more esoteric or domain-specific than, say, Python.
13:32:35
shrdlu68
user|2: I meant if you're interested in prolog above, don't know how python managed to sneak in there.
13:51:52
shka
otherwise, i may not spend my time to develop my own custom documentation generator system
14:04:38
phoe_
https://github.com/sirherrbatka/cl-lore/blob/master/cl-lore.asd#L8 there's no email, yuck
14:35:22
Josh_2
beach: how do I add (optimize (speed 0) (debug 3) (safety 3)) to .sbclrc I get an error when I place it as is into the file
14:48:58
jdz
Josh_2: SBCL also has sb-ext:restrict-compiler-policy which overrides usual declarations.
14:57:28
Josh_2
I haven't done a lot of work with other libraries yet, but I'll add it to my .sbclrc and comment it out for later
15:23:49
Josh_2
Okay, so I'm back to trying to figure out the condition system. I have this here code http://paste.lisp.org/display/358222 and it lets me invoke restarts from the debugger, how do I change it so it is automatic?
15:26:12
Bike
you have restart-bind case with a restart called return-nil, but refer to return-nil nowhere else
15:37:55
Josh_2
"returns a random number between 0 and 100. I the number is a multiple of 5 this will raise an error and return the value of nil"
15:40:29
Josh_2
It's handled higher up so the value returned is just ignored and a nil is put in it's place?
15:41:56
beach
It means that a function should have a well-defined specification that depends on other functions as little as possible.
15:41:59
Josh_2
How about this one "returns a random number between 0 and 100, or signals an error if generated number is a multiple of 5"
15:43:07
shka
"returns a random number between 0 and 100, or signals an error if generated number is a multiple of 5"
15:43:19
beach
"Returns a random number between 0 and 100 that is never a multiple of 5. Around 20% of the time, it signals an error of type NIL-VALUE."
15:44:36
Josh_2
I'm trying to learn to use the condition system, so I'm creating an unexpected situation
15:46:31
beach
Josh_2: Here is how to think about signals and restarts. Some low-level code detects a situation it can't handle, but it does not know what to do with it, so it signals an error. But it has several possibilities of continuing, except that it is unable to choose which one is appropriate.
15:46:32
beach
Higher level code invokes the lower-level code, knowing how to continue in case of a problematic situation. So higher-level code does a handler-bind in which it invokes the appropriate restart.
15:47:10
beach
Josh_2: So in your code, what is the lower-level processing and what is the higher level code that invokes it?
15:47:54
beach
Josh_2: LIST-NUMBER says it creates a list of length len from numbers generated by func.
15:49:15
beach
Josh_2: From the example I gave you, LIST-NUMBER must be the lower-level code, but I don't see it detecting any situations it can not handle.
15:55:16
beach
The name and the docstring of return-type-of-predicate do not agree. Is it supposed to filter the elements of the LIST argument and return only those for which the predicate returns true?
15:56:19
beach
But, it is none of the business of that function to check whether predicate has a problem.
15:56:43
beach
If you do that, you need to check that predicate is a function, that it is a function that accepts exactly one argument, etc, etc.
15:58:58
beach
But you do that in return-type-of-predicate which is wrong. You should do it in the code for the predicate.
16:00:54
beach
Add to this fact that your functions names are strange and your docstrings are wrong, and you have a mess.
16:03:08
beach
I suggest you try to think in the terms I explained. Low-level code that detects a problem AND proposes restarts to fix it. High-level code that invokes the low-level code in a handler-bind and invokes the restart if the error happens.
16:04:39
beach
I also suggest that you look at the examples in PCL and try to identify the parts that I explained.
16:07:17
beach
And, when I look at the name LIST-OF-EVENS and its associated docstring, I think "That is a very complicated implementation of that specification. Why not just do (loop repeat (random m) collect (* 2 (random n)))?
16:16:07
beach
Josh_2: I suggest you start by writing MY-EVEN-P which is like EVENP, except that it proposes one or more restarts if the argument is not an integer. So if it gets a value that is not an integer, it calls ERROR, signaling an appropriate condition, and it has one or more restarts like returning FALSE.
16:17:34
beach
MY-EVEN-P is an appropriate abstraction, and it corresponds to the use case I explained before (i.e. low-level code that detects a problem...).
16:35:19
Josh_2
http://paste.lisp.org/display/358222#1 Now I'm more than happy to talk about everything else that sucks.
16:42:06
_death
now you can rename your RETURN-8008 restart to USE-VALUE, have it take one parameter and set I to it.. then you can (use-value 8008 condition) in your HANDLER-BIND
16:43:09
_death
and then you should have another loop, calling the predicate with the new I until a valid value is used
17:02:21
emaczen`
I'm trying to inspect a foreign array by using #'cffi:foreign-array-to-lisp but I have no idea what to do with the array-type argument
17:09:10
_death
Josh_2: cool.. usually you define a function that invokes the restart, for example (defun use-value (new-value &optional condition) (let ((restart (find-restart 'use-value condition))) (when restart (invoke-restart restart new-value)))) .. in the case of use-value, CL already defines such a function
17:10:17
emaczen`
has anyone used CFFI with opencv before? It is a bit difficult because the C API is deprecated in favor of the C++ API
17:10:50
_death
emaczen: I wrote some opencv bindings years ago, when the C API was not yet deprecated..
17:12:42
emaczen`
_death: I don't know who would remember particulars about cvEncodeImage... Only in the C API the documenatation says that it returns a single-row matrix that contains the encoded image as an array of bytes
17:13:58
Josh_2
hmm well I can't actually define a function called (use-value). I'm going out now so I'll fiddle when I get back. Thanks for all the help everyone.
17:14:15
emaczen`
In the newer APIs it looks like you pass a vector<uchar> and it gets filled with your bytes...
18:14:11
attila_lendvai
emaczen``: pass it something like '(:pointer (:structure my-foo-that-has-been-cffi-defstruct-ed)
18:21:40
emaczen``
attila_lendvai: I'll try it in a second, I thought I was getting a byte array from C but I'm actually getting a CvMat* which has a single row, so I have to defcstruct CvMat* and get that single row byte array first...