freenode/#lisp - IRC Chatlog
Search
12:56:58
smokeink
if other objects don't hold references to it, then that obj gets destroyed. I pushing adding that obj into a list but that doesn't make it count as "referenced"
13:00:32
Bike
not that i'm familiar with this system, but if you deal with things through a garbage collector, is "delete this particular object" even a thing the system wants you to be able to do?
13:01:45
smokeink
I want to understand in such a system how am I supposed to delete a blog post from the db, for example
13:04:14
smokeink
http://git.elangley.org/edwlan/blogerate.git/blob/ef839cbf4d96b5ee4aa02ab6d82aa6bf64293301/blogerate.lisp
13:05:00
smokeink
this small app here can add blog posts, but shouldn't I also be able to delete them? (by ID for example, since each post has a unique ID)
13:06:36
smokeink
when I create a blog post, I create a unique ID for it. Then in the HTML I can output that ID for the action of a "delete" button for example
13:07:01
jdz
I may have come to the discussion at a wrong moment, but if you know what you want to delete, then obviously you have some kind of a reference, so it seems very wrong to want to "make object referenced".
13:07:57
smokeink
:) you'll have to explain why you think that if an object exists then it must be referenced by something else.
13:08:28
smokeink
it just exists by itself, it's there, floating in the database. And I want to delete it, since nobody wants it any more (and nobody actually rferences it )
13:09:23
Bike
"you'll have to explain why you think that if an object exists then it must be referenced by something else" because otherwise the gc would delete it
13:09:43
Shinmera
No, because if it's not referenced it simply doesn't exist by the programmer's view.
13:10:19
LdBeth
smokeink: if (1 2 3 FOO) is excluded then other references to FOO alse won't be wiped
13:11:29
LdBeth
since after save into db, the #'lisp-object-to-mptr to the save symbol will always return the same mptr
13:16:38
Bike
i'm just saying, practically speaking, if the post isn't referenced from the database, surely gc will axe it
13:18:35
smokeink
if I make another class (let's call it posts) that references individual post objects, and I tell the gc that I don't want to gc posts, then it'll spare all the referenced individual post objs
13:19:14
smokeink
now, is that the right way to work? to have a class post and then another class posts that references post objects ??
13:22:11
smokeink
I used a class with a slot of type sequence. I 'd like to use a simple sequence directly but I am not sure how to access it
13:34:10
smokeink
but after I restart the lisp system I shouldn't call make-instance again, I should read it from the db
13:44:17
smokeink
yes, sure. The issue was how to delete an individual post. It's solved. Now the second issue is whether it's possible to use make-marray for posts , instead of defmmclass
13:45:21
smokeink
you need an array or a class, that references those posts, otherwise you won't be able to delete individual posts
13:46:59
smokeink
you'll be able to store post objects, ... and you'll be able to delete them all. But if you want to delete them individually, you need a parent structure that references them, and call (manardb:gc (list parent_struct1 parent_struct2) :verbose t) , and that will delete only those objects which are not referenced by these parent structures
13:55:16
smokeink
I also hoped for an elegant way... there shouldn't be a need to have both post and posts objects. And then user & users, comment & comments, and so on...
13:57:45
jdz
The documentation says "manardb is just starting out...", and some ways to improve it include the things you want.
14:12:07
smokeink
I tried elephant and it was always crying and making things complicated, (I forgot the details)
15:17:27
bateman
Hi guys, I'm having some trouble with a basic common lisp program. Could someone look at my code and tell me what I'm doing wrong?
15:19:08
bateman
It's supposed to sum the multiples of 3 and 5 between 0 and LIM. Currently it gives an error when I try to run it.
15:19:16
jackdaniel
bateman: your indentation is all wrong, let doesn't require explicit progn,, you call reduce with an unbound symbol
15:20:42
sabrac
For those of you who. like smokeink, think that postmodern has stuff half implemented, I am interested in hearing people's priorities.
15:20:44
jackdaniel
your question is probably about reduce, try (reduce #'+ mltlst), but this code is not very readable
15:20:50
jackdaniel
bateman: check out http://www.cs.umd.edu/~nau/cmsc421/norvig-lisp-style.pdf for style hints
15:21:43
minion
bateman: direct your attention towards pcl: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
15:22:18
beach
bateman: If you use incorrect indentation, you force the people reading your code to count parentheses, which is not what Common Lisp programmers do. They rely on correct indentation to understand the code. As you noticed I immediately though i was out of scope.
15:26:22
sabrac
Shinmera: Still struggling a bit with method documentation. E.g. all those sql-ops in s-sql in postmodern. Otherwise, I like it. I need to find time to publish a review.
15:46:44
bateman
"Evaluation aborted on #<TYPE-ERROR expected-type: (OR FUNCTION SYMBOL) datum: (+ 1 3)>"
15:48:56
bateman
So is the rule with #' that you have to use it when you're using a function as an argument?
15:49:20
LdBeth
Weirdly, almost all other languages use same namespace for both functions and variables
15:53:03
bateman
Do you ever need to do that with a symbol right after an open paren? (eg, (myfunc arg1 arg2) )
15:55:29
Shinmera
Eg the first and second pairs of parens within this let are not forms, but expressions: (let ((foo 0)))
15:57:50
fouric
actually, on that note, why have i seen older code that has #'(lambda ...) instead of (lambda ...) in it?
15:58:12
Shinmera
Because before CL got standardised, LAMBDA was not yet a macro that expanded to (function (lambda ...))
15:58:28
slyrus1
Xof: would love to take a look at it if you can dig it up. Was thinking of starting my own, but, obviously, starting with yours would be preferable.
16:00:27
Shinmera
"If name is a lambda expression, then a lexical closure is returned. In situations where a closure over the same set of bindings might be produced more than once, the various resulting closures might or might not be eq."
16:01:55
Shinmera
I actually consider #'(lambda ..) an anti-pattern nowadays because some things do expect lambda expressions, and not function expressions, so #'(lambda ..) does not work everywhere, while (lambda ..) does.
16:02:29
Shinmera
Examples being a lambda-expression as the name of a form, and the condition report function.
16:07:23
fouric
to clarify: not all expressions are valid forms, but all valid forms are expressions?
16:09:36
Shinmera
So (let ((a b))) is a form, ((a b)) and (a b) are expressions and b is another form.
16:10:05
Shinmera
well, let and a as symbols are also expressions in that example, just to be complete.
16:12:26
Shinmera
On a tangent, #' and ' are great ways to obfuscate your code! (let #'null (setf null 'null) (funcall null function))
17:06:36
Shinmera
Clearly the ANSI committee had no concern for code obfuscators. We need a new standard to address this.
17:13:40
Shinmera
Here's another progress video from my clipmap implementation. https://www.youtube.com/watch?v=jv3SS_l6Q5I&feature=youtu.be
17:20:17
jasom
Shinmera: Lexical bindings of dynamically determined values doesn't make any sense IMO
17:21:05
jasom
You could imitate a dynamic binding of those via symbol-function and unwind-protect though.
17:26:37
cgay
Is there a thing that takes a type, e.g. (member :a :b :c) or (integer 1), and turns it into an English description of the type? I imagine it being a format directive written by the same person who wrote ~@R, for example.
17:27:20
Bike
check-type allows you to specify your own string, since it sometimes depends on context.
17:28:18
cgay
I have CL type specs leaking into command-line flag --help output and thought it would be fun if there were a converter. :)
17:58:42
Shinmera
I found CLON to be much too heavy-weight. Fare's command-line-arguments is nice and simple.
18:01:40
jasom
for programs with a lot of arguments clon can be nice. If you consider "cat -v" harmful then you probably don't need it
18:08:41
LdBeth
http://www.softwarepreservation.org/projects/LISP/parallel#Connection_Machine_*Lisp_(StarLisp)_
18:34:32
dim
and rather than CLON I wrote my own simple stuff for parsing commands and subcommands ala git, but didn't separate it out from some of my stuff
18:35:13
dim
https://github.com/dimitri/pgcharts/blob/master/src/utils/cli-parser.lisp is used in https://github.com/dimitri/pgcharts/blob/master/src/pgcharts.lisp if you're curious
18:59:01
emaczen
How do we distinguish between C function names and lisp names with defcfun? For example, open and write?
18:59:39
Colleen
Macro defcfun https://common-lisp.net/project/cffi/manual/cffi-manual.html#defcfun-1
19:25:27
emaczen
how do you specify a union type in cffi:foreign-slot-value of cffi:with-foreign-slots?
19:31:18
jackdaniel
(usually I find libraries with no documentations, readmes or half-finished ones)
19:31:32
Bike
if you tell it "this thing is either an int or a char*" that doesn't really give cffi anything to work with
19:31:51
emaczen
Bike: Ok, so in the C code it object.union.field.field in lisp it would be (slot (slot object))
19:32:31
Bike
cffi is kind of apathetic about a lot of C stuff. it just takes memory and goes "that's a float? you got it, boss, float coming right up"
19:34:47
emaczen
Bike: CFFI is pretty good, I like that approach. I only wish it was a bit more steamlined to find out the constants I need for me -- I don't want to mess around with the groveller
19:35:50
emaczen
I wrote a macro that writes a c program that prints out the info I want in a plist, and then I compile it, run it and read it.
19:37:31
emaczen
Bike: Oh, well I spent more time a few months ago looking at the groveller than an hour getting this to work
20:10:44
jasom
if you're willing to wait a couple of GB should be enough for it to make forward progress
22:38:13
xsperry
hi. what would be the closest equivalent of list comprehensions in lisp? loop macro?
22:39:04
xsperry
particularly in cases when you iterate over two or more lists. do I need nested loops for that?
22:45:37
edgar-rft
a) what are "list comprehensions"? b) It's possible to iterate over several lists at once with the same pros and cons as in other languages. Nested loops are the simplest possibility.
22:46:45
Bike
list comprehensions are a syntactic construct in python and other languages that is indeed kind of like loop.
22:51:17
xsperry
ok, here's a simple example that is very easy to express with list comprehensions. given two lists, '(1 2 3) and '(4 5 6), make a list of conses consisting of each element from list A and list B. so '((1 . 4) (1 . 5) (1 . 6) (2 . 4) (2 . 5) (2 . 6) (3 . 4) (3 . 5) (3 . 6))
22:53:17
jasom
xsperry: I believe that's a nested loop in python as well (unless you use itertools which has that function builtin IIRC)
22:53:35
Bike
it would have to be a nested loop under the hood since you're iterating over both lists independently, anyway.
22:55:14
xsperry
jasom I think you don't, but I am not 100% sure. it has been years since I used python, but python's list comprehensions were inspired by haskell's, and in haskell you don't need to nest list comprehensions for this
22:55:47
xsperry
I am actually trying to replicate this really elegant example from haskell tutorial in CL
22:57:07
jasom
as in (loop for x in xs for y in ys collect (cons x y)) would return just 3 items with your inputs.
22:57:10
xsperry
jasom, you would zip lists first, and then then pattern match on resulting list. but at that point you probably wouldn't be using list comprehension
22:57:41
shachaf
Oh, LOOP iterates through lists together instead of nesting? That's what I get for saying something in here.
22:58:23
shachaf
In GHC Haskell you can write [(x,y) | x <- xs, y <- ys] for nesting and [(x,y) | x <- xs | y <- ys] for zipping. But zipping seems to me like a much more unusual behavior.
22:58:25
xsperry
this is the example I'm trying to rewrite in CL. it takes first 10 right triangle that has integers for all sides
22:58:40
xsperry
[(3,4,5),(6,8,10),(5,12,13),(9,12,15),(8,15,17),(12,16,20),(15,20,25),(7,24,25),(10,24,26),(20,21,29)]
22:59:22
xsperry
[1..] would probably be hard to emulate, but what about the rest? three nested loops? what are the alternatives?
23:02:00
jasom
xsperry: I'm not sure how the haskell example works; does it find all right triangles where the first side is of length "1" first?
23:03:10
xsperry
jasom, [1..] is an infinite list of integers. take 10 drivers computation, and since haskell is lazy it will only compute enough to take first 10 such triangles
23:06:27
jasom
it is indeed lazy which is <sarcasm>completely obvious from the source to anybody</sarcasm> https://github.com/jasom/itertools/blob/master/itertools.lisp#L406
23:07:13
aeth_
Well, that was an incredible mess. nickserv and chanserv were down but nearly every channel was +r and in every other one you couldn't speak. So if your Internet went down in a period of about 4-5 hours or you tried to connect, you were out of luck, apparently.
23:09:22
aeth_
And the best part is, when it forced my nick to Guest1234 or whatever when nickserv came back, it made my nick temporarily unavailable.
23:10:32
xsperry
jasom, ok, this is a lot more similar to the solution above than I imagined it to be. if I got it right, can I use loop to generate some lazy equivalent of a list (infinite list of right triangles), and then take first 10 such elements?
23:10:35
shachaf
As I'm trying to figure out some language ideas the language is becoming more and more like lisp. I guess this is an old story.
0:00:40
xsperry
_death, interesting, thanks. I wonder how close we can take it syntax wise with macros
0:11:05
_death
I guess something like this isn't too bad (take 10 (gen ((c (range 1)) (b (range 1 c)) (a (range 1 b))) (when (= (square c) (+ (square a) (square b))) (list a b c))))