freenode/#lisp - IRC Chatlog
Search
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...
19:08:27
emaczen``
dlowe: yep, unless someone else has already tied into C and wrote a wrapping API, then you have to
19:12:40
fourier
emaczen``: in difficult cases I typically write the short C/C++ program which does exactly what I expect from Lisp program to do towards the library I'm dealing with and literally translate all back to lisp
19:20:00
emaczen``
fourier: I'm dealing with images and I think I'm going to have a hard time determining if I'm even getting what I expect
19:21:22
paule32
i search for quantum computer programming by doing lisp - have anyone links, infos ?
21:58:46
drmeister
Let's say I compile a minimal version of Clasp that has a compiler compiled into it.
21:59:34
drmeister
Can I expect to be able to compile-file all of the Common Lisp source code (including CLOS) and then link and load that together.
22:00:09
dim
https://www.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf --- you might already be familiar with it
22:00:25
drmeister
I realize this is not a well formed question and there are implementation dependent stuff here.
22:00:43
Bike
the trick is to make sure that anything the compiler uses is properly defind in the compiler context
22:02:12
Shinmera
fasls that only contain compile-time side-effects, such that you can load this minimal part to compile-file the rest without having to do a full load.
22:02:49
Bike
(eval-when (:load-toplevel) ...this goes in the fasl...) (eval-when (:execute) ...this is only executed when loading as source...) (eval-when (:compile-toplevel) ...in the cfasl...)
22:08:15
drmeister
The slow part of building clasp has been bclasp LOADing and JITting all of Cleavir and clasp's extensions to Cleavir, (~10 min) and then running that code to build all of cclasp (~50 min).
23:34:23
anticrisis
it's not evident from clhs: check-type that it can't be used for structs, or did i miss something?
0:08:17
antoszka
jmercouris: did you try compiling rust to object code/libraries and calling that the same way you'd call C (via cffi)?
0:08:41
antoszka
jmercouris: that's how I'd approach the problem, though I've honestly have zero experience with rust ;)