freenode/#lisp - IRC Chatlog
Search
13:46:00
fluxit
Hello - another noob looking for help as well: I'm having some trouble (style issues) when passing around &rest arguments. Here's an example of some problem code: http://hastebin.com/ebokayihoz.lisp
13:48:01
loke`
fluxit: I'm sorry for not being able to look at your code. I can't look at dark backgrounds for more than a few seconds before my eyes cross.
13:48:27
fluxit
line 31 of the haste- I don't know how to expand a list of list from an &rest param ... or even if that is something I should do- sorry for not being specific
13:48:56
loke`
fluxit: What do you mean "expand"? The arguments are passed as a sligne argument using &rest
13:50:43
fluxit
I guess I'm looking for a way to convert lists-of-lists into seperated lists (so that functions like intersect will work on them) however...
13:51:13
fluxit
I think I'm doing something wrong, stylistically, to run into this problem in the first place... It just seems... wrong.
13:53:49
fluxit
(Also, is there some way to hide whatever fix [mapcar, reduce/fold, etc] inside of my functions? I really want to write something like the second to last function.)
13:54:56
loke`
fluxit: in the second-to-last example? WOuldn't use use (apply #'intersection ...) there?
13:56:15
ggole
When you want to apply a two-argument function like intersection across the elements of a list, you probably want reduce
13:56:21
loke`
Well INTERSECTION takes a number of lists as (&rest) arguments. So if you have a variable holdoing a list of lists, you'd have to call it using (apply #'intersction list-of-lists)
14:13:49
fluxit
Well, reduce was what I wanted- thanks everyone- but... It's still ugly. I'm specifically looking at my prime-factors function
14:15:27
fluxit
There has to be a better way to handle passing around &rest arguments, right? What if I had N functions that passed their &rests in the way that I do in the gcd functions- You'd have to strip off N sets of extra parens, no?
14:16:49
fluxit
(Rephrased: My prime-factor function has got to be the wrong way of handling that situation.. so what's the right way?)
14:21:35
phoe_krk
But like kenanb said: apply and reduce are fairly necessary there. They tell people what you're doing with your lists.
14:22:24
phoe_krk
You get a list, then APPLY a function to it. Then you REDUCE the resulting lists with INTERSECTION. Then you apply MAX to the results to find the maximum.
14:22:49
phoe_krk
(max (...)) basically equals to (...) because MAX is waiting for more than one argument.
14:23:17
fluxit
Another example- what if you have something like this http://hastebin.com/apolosoxet.lisp colorless: http://hastebin.com/raw/apolosoxet
14:27:50
phoe_krk
"Three sets of nested lists" can look completely different based on who's reading the words.
14:27:54
kenanb
fluxit: that is the right way to do it, you are doing list management because it is necessary, it might seem not like so for functions that expects a number of arguments that has similar characteristics, like the lambda list of #'+ etc, but usually a lambda list will be like (a b &rest args &key c (d nil d-supplied-p))
14:28:05
phoe_krk
Give me a proper example of the lists you need to work on, and I'll try to show you a way of working with them.
14:28:52
phoe_krk
Can be really simple, like '((a 1) (b 2) (c 3)) '((d 4) (e 5) (f 6)) '((g 7) (h 8) (i 9)) - there, three sets of nested lists.
14:29:00
kenanb
fluxit: and when your own functions will constantly deal with a list of arguments, why not using a parameter that expects a list?
14:31:40
kenanb
fluxit: (defun test (my-list) (another my-list)) (defun another (my-list) (last my-list)) (defun last (my-list) (print my-list))
14:32:08
fluxit
But wont I always have to write boilerplate (like my prime-factors code http://hastebin.com/ebokayihoz.lisp http://pastebin.com/raw/4XkaVBxy) to handle single elements vs a list?
14:38:17
aeth
fluxit: You probably want to iterate explicitly with do in your example code. Lisp is not Scheme.
14:39:27
fluxit
Lol.. I'm not explaing myself well. Do you guys know python? I'm looking for tuple expansion in lisp (for the &rest args)
14:39:57
kenanb
fluxit: I believe you are trying to solve a problem that only exists in your mind. those two are totally different interfaces to pick for a function, you need to chose one, which brings us to question "what your function is for?", is it an internal function that will always deal with lists? or is it an external function that will expect an arbitrary set or arguments, it can't do both, at least not without being explicit in your call to
14:40:30
phoe_krk
(defun myplus (x &rest args) (if (null args) x (apply #'myplus (+ x (car args)) (cdr args))))
14:41:11
kenanb
fluxit: you can't, not because the language doesn't let you do it, but because it is a completely wrong thing to request
14:41:36
fluxit
phoe_krk: I'm not having an issue handling arbitrary amounts of arguments, I got that. I'm having an issue hiding away my function interface
14:42:07
phoe_krk
fluxit: hiding away your function interface? why and what would you want to achieve through it?
14:43:29
kenanb
fluxit: you are not trying to "hide away" your interface, you are trying to change it, therefore you need a wrapper, and a wrapper that changes the interface is not boilerplate, it is part of your algorithm.
14:43:36
phoe_krk
kenanb: I don't agree with "lisp not allowing him to do that". He can do it if he's patient enough.
14:45:03
phoe_krk
You can do it Java style and write every single piece of code in a whole new class and make a interjection-boilerplate-string-factory-factory-generator.
14:45:32
kenanb
phoe_krk: yes, of course, you could do it with macrology, but it would be a hack, it is not a good problem to solve.
14:45:44
aeth
fluxit: I think the point is that you have to code idiomatic code in the language you are using.
14:47:00
fluxit
or IF i have to handle cases like that, then to only have to handle them outside or inside the functions, not both
14:47:22
phoe_krk
fluxit: you avoid having to write things like your prime-factors example at the expense of having to write a real, *real* lot of code necessary to hide function application and reduction like you want to.
14:48:04
phoe_krk
Because I totally don't get what you said about "handling cases". I don't get it just yet.
14:49:51
phoe_krk
fluxit: you basically can write your own vision of Common Lisp by creating a new package and importing completely nothing; in there, you can write your own intersection function, your own max function, your own prime-factors that hide everything away the way you did.
14:51:01
phoe_krk
But to bend the rules, you first need to get to know them, and you need to get to know them well. :P
15:00:01
fluxit
I *think* that its valid python.. but I didn't/couldn't actually check it (no primes())... but the idea is there either way: http://pastebin.com/raw/xhFC2JSN
15:03:33
phoe_krk
Each function in Lisp has a so-called lambda list. Basically, a list of arguments it expects.
15:06:10
fluxit
But it's not (it is- I get that) but a LOL doesn't behave the same a list does in a function
15:07:07
fluxit
so if you wanted to create general purpose functions you'd need to check for LOL- If I wanted to write a intersect function that could handle both cases:
15:07:10
aeth
fluxit: if you do (map 'list #'foo sequence) it's more generic than (mapcar #'foo list) so you'd be able to handle vectors as input
15:07:50
kenanb
fluxit: you shouldn't even handle data with completely different semantics from a single interface manually in a single function most of the times, let alone doing it automagically
15:08:31
aeth
fluxit: Why not just have a (prime-factor int) and a (prime-factors sequence) instead of trying to be too generic?
15:08:33
axion
fluxit: why not write implementations for both variants with a common api (Generic function)
15:09:24
fluxit
Guys, I get that it CAN be done other ways- I'm just trying to understand WHY I shouldn't/can't do it
15:10:27
phoe_krk
From my point of view, it's much easier to have a function that has a well-defined input and produces a well-defined output.
15:11:48
phoe_krk
And, depending on what kind of data you have, utilize APPLY/FUNCALL/MAP/MAPCAR/REDUCE to bend your data to the function's inputs.
15:12:23
phoe_krk
And your lambda list doesn't then look like (my-fun &rest args), giving you no help on what you're doing.
15:12:43
kenanb
fluxit: because if the language would try to do it, it would be trying to infer the application method from the structure of the parameter value. what if your function actually works with lists as parameters? like append, what would you expect APPEND to do in such ambiguity?
15:15:02
phoe_krk
What would (append (list (list 1 2) (list 3 4) (list 5 6)) (list 7 8)) evaluate to?
15:18:04
phoe_krk
APPEND merges the lists it takes as its arguments. It doesn't do anything to the contents of the lists.
15:18:27
kenanb
fluxit: but append takes an arbitrary number of arguments itself. so provided it is feed only a single argument, append should be returning its single argument unchanged, since there is nothing else to append. so the programmer would expect (append '(1)) => (1), and therefore (append '((1 2) (3 4))) => '((1 2) (3 4))
15:18:30
phoe_krk
If you have a list of lists you want to have merged, you need to APPLY the function APPEND to the list.
15:19:26
fluxit
Okay- I think I get it for append- You need it to be the identity function for just 1 element that way you can recurse properly, right?
15:19:27
kenanb
fluxit: but your append returns (1 2 3 4), so the question is how would you guarantee what is "the right thing"?
15:21:14
kenanb
fluxit: yes but not only for recursion, what if your function appends a list it gets as argument at some point and it doesn't know how many arguments it will get, but it surely wouldn't expect to append the nested lists to each other just because it got a single list instead of multiple lists
15:21:28
phoe_krk
Therefore applying APPEND to a list of lists. If it's an empty list, it'll return an empty list. One list, one list. Multiple lists, appended list.
15:24:37
kenanb
fluxit: so you expect function application to work in a certain way for some functions and another way for others?
15:25:05
malice
fluxit: hint: you can always use (documentation 'your-function-name 'function) to see what your compiler wrote about the function. e.g. (documentation 'max 'function)
15:28:44
phoe_krk
fluxit: because your code becomes messy the moment you can accept anything anywhere.
15:28:52
malice
fluxit: You have many philosophies. One of them is that you write a function that does one thing, and does it well.
15:30:08
malice
fluxit: Yeah, but max value of what? What is "the max value of the list"? Or a vector? Or of a class instance? It's not about how you word it, but see that in your words "max value" is vague,
15:30:34
phoe_krk
I'd rather have it tell me something went wrong, than have it work with value that might have been a mistake.
15:30:38
kenanb
fluxit: we have giving you like a lot of reasons actually, and I really like your example because it exaggerates it to the point of absurdity, which makes it obvious how such approach would make the "list" structure totally pointless, because its characteristics cannot even efect the algorithm at that point, it is as if you want the whole nesting to always be "flattened" automatically.
15:31:36
phoe_krk
Also a thing where, in Javascript, 1234567890123456789012345678901 - 1234567890123456789012345678900 might give you 0.
15:34:00
kenanb
fluxit: you cannot take it out of absurdity, that is the good thing about your example, if you want function application work in that way, it should also be working for the absurd case.
15:36:20
haom
when I get thrown in to sbcl's low-level debugger, with an error like: "glibc detected *** sbcl: free(): invalid next size (fast):" is this an error the sbcl devs should possibly want to know about?
15:38:08
kenanb
fluxit: list actually does support returning multiple values, but it will not help you. in fact it will make your situation even worse, because now you have to bind multiple values to a &rest args manually, then do the same thing :D
15:38:55
p_l
fluxit: no, it returns separate values on the call stack, doesn't allocate any kind of list or other structure
15:39:17
p_l
fluxit: and you have multiple-value-bind which allows you to bind those values directly into symbols
15:40:03
fluxit
So couldn't I use values in my prime-factors function to return seperate lists? Which would then work with intersection?
15:41:38
fluxit
( phoe_krk: been doing the little schemer :P- A made up intersection function which isn't binary)
15:42:21
kenanb
I think it really doesn't matter because fluxit will need all the values #'prime-factors returns ALL THE TIME, therefore prime-factors should be returning a sequence after all
15:44:38
phoe_krk
You have a function that takes two arguments, bam, it takes any amount of arguments with reduce.
15:44:52
phoe_krk
FUNCALL and APPLY also are there for calling functions with unknown/known amounts of arguments.
15:46:08
phoe_krk
REDUCE takes two arguments of a list, calls a function on them, then puts the result back on top of the list, and repeats until there's just one thing on the list. Which gets returned.
15:46:42
phoe_krk
You can write simpler functions with well-defined arguments and just bend your data so it all fits.
15:47:12
phoe_krk
FIND, REMOVE, REMOVE-IF, and so on. They all take test and/or key functions as arguments, too.
15:49:23
fluxit
I've got to go- I've managed to avoid my OS homework for far too long now :) Thanks everyone for all the help, I'll play around with values (and see if I can't come up with a good 'better-max' example- I'm still not completely sold that it's a bad idea) and see if I can't get the behavior I'm looking for.
15:49:24
fluxit
Fair enough- I can see how it can lead to a lot of bugs. I definitely wont be doing it outside of personal things.
15:52:21
pjb`
It's increadibly you have such misconceptions after so long. What have you been doing?
15:53:11
phoe_krk
I seemingly need to get the very theoretical basics repeated a few more (tens of) times.
15:53:16
pjb`
jasom: calling atoms atoms is silly too (apart from ¹H), given they're made of protons and neutrons.
15:53:52
phoe_krk
pjb: I'm close to remembering that there are actually no unbound lexical variables. I'll get the things you mention remembered, too.
15:55:27
fourier
in compilation output I see ;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 1
15:55:35
pjb`
Yes, it seems that LW doesn't want to debug the main thread, in which it implements the debugger GUI.
15:56:08
pjb`
So try to run that code in a different thread. If that's GUI code, then perhaps you could debug it with slime?
15:56:53
fourier
it is what I guess what I 1) load my app with quicklisp 2) set a breakpoint 3) try to compile a file with LW
15:58:20
fourier
I guess it is _probably_ something with where to place .xfasl files. While loading with QL it places them into ~/.cache/common-lisp.... and when I compile with IDE the same file the .xfasl appears in the same directory as a source file.
15:59:06
pjb`
The problem is that you're trying to debug the main thread: Debug-Break in process "Cocoa Event Loop" {undebuggable process}
15:59:42
pjb`
So instead, try to debug it with slime (sldb expressions are evaluated by swank in different threads).
16:00:22
pjb`
I don't guarantee that you will be able to debug the Cocoa Event Loop with slime/sldb/swank, but this is what I do with ccl which has the same problem.
16:04:29
fourier
One can't call capi from other threads - there are special functions to execute something in UI thread.
16:04:29
pjb`
I would try: (ql:quickload :bordeaux-threads) (bt:make-thread (lambda () (your-application)))
16:20:21
pjb`
phoe_krk: "join" has some kind of connotation that is not valid for CL:APPEND. what CL:APPEND does is to build a new list that contains all the elements of all the list but the last, and NCONC that last list, so the result share structure with that last list. In a way, it joins only the new prefix with that last list. I would say that it's NCONC that j oins the lists together, not APPEND. mind CONCATENATE, which will return an
16:21:14
pjb`
Also, by the definition of append, (append '(1) 2) #| --> (1 . 2) |# the last argument doesn't need to be a list!
16:23:24
pjb`
fluxit: what about (max '(3 #(4) #S(point :x 5 :attributes (6 #(7))))) ? Should it return 7? How would it know how to walk rand lisp objects?
16:44:42
fourier
pjb`: yes it looks like it is something what you've described. In other examples I never verified UI callbacks, rather code executed in constructors. so need to find another way to debug. (the solution with running UI explicetly in another thread doesn't work with debugging either)
16:45:09
pjb`
fluxit: (multiple-value-call (function intersection) (function-returning-sets-in-multiple-values))
16:45:35
pjb`
Well, function-returning-2-sets-in-multiple-values since intersection takes only two of them.
16:45:58
pjb`
but function-returning-2-sets-in-multiple-values could return more values, for the optional parameters of intersection.
16:47:57
pjb`
fourier: what are you debugging? The code that needs to be debugged often can be run outside of the main thread context. You could stub the CAPI functions if it calls them directly. Think "unit tests". That's where most of the debugging is/should be done.
16:59:46
fourier
yes I understand it all. of course I can just add logging as I usually do; but the problem is what I cannot debug the ui code with a graphical debugger seems strange to me; I was able to debug Cocoa C/ObjC code in xcode without problems and this situation just feels strange for the expensive IDE, one of advantages of which is a UI framework.
17:11:30
kenanb
can you confirm these assumptions from standard compliance perspective: 1) structures are clos classes that inherit from structure-object instead of standard-object 2) therefore methods can specialize on structures because they are clos class instances 3) make-instance will work on structure classes 4) unlike clos class instances, the behaviour is undefined when trying to access a slot that is not manually set or had no initform, so
17:14:12
kenanb
fiddlerwoaroof: thank you but I am well aware of the page :) I was trying to clarify my understanding of structures according to that page and several other references to structures
17:23:08
kenanb
fiddlerwoaroof: hmm, yes, so my point with 3 was indeed wrong, sbcl make-instance works on structures but only to allocate them, not to initialize their slots
17:31:29
emaczen
I want to replace a subsequence with ONE element (so delete the subsequence and insert the element)
17:32:17
Bike
that's more complicated, you'll have to copy the subsequent element backwards and then resize the sequence.
17:32:30
emaczen
(delete-if #identity sequence :start i :end j) keywords seems to delete the rest of the list
17:34:08
Baggers
Is there a way to make a package export all the exported symbols of a package it is :use'ing? (without listing them all under :export)
17:36:28
Jonsky
I found that there're GUI automation libraries in other languages. Is there any in lisp? I mean a library to control the mouse and keyboard
17:37:30
kenanb
Jonsky: can you provide an example library name from another language, I am confused
17:37:35
Bike
i remember using something like that to cheat in runescape. i don't know that it's common, though.
17:37:46
p_l
Jonsky: depends. You can use Windows' GUI automation protocols from any Lisp that can use COM objects, on OSX you can link through Obj-C bridge (so CCL will have it easiest, I guess). On Linux you'd have to implement your own ATK bus client or call to C libs
17:38:01
Bike
kenanb: a library to send software mouse and keyboard movements to the system, so that you can automate tasks that only have a graphic interface, and such.
17:38:06
p_l
Jonsky: we are missing a proper library for Selenium, though it should be easy to implement
17:39:38
p_l
Jonsky: Selenium currently doesn't have a client library, but it should be doable in not-too-big timeframe as all the necessary parts are available
17:40:06
Jonsky
p_l: and I have no idea what you were talking about in the rest of the reply :(. I should learn more then.
17:40:43
p_l
Jonsky: I used UI automation for end-user tests of GUI applications (i.e. we mimicked real user, just like Selenium does for WWW)
17:42:30
p_l
kenanb: UI Automation interfaces are used pretty much by two kinds of applications - Screen readers (and other accessibility tools) and testers
17:43:50
pjb`
fourier: in the case of Xcode, the debugger is in Xcode, a different process than the application you are debugging. The equivalent situation is to use slime!
17:44:36
fourier
pjb`: yes exactly. I thought it is implemented in similar way in LW. Sad what it isn't :)
17:46:56
pjb`
kenanb: in LW, the debugger and your code both work inside the same LW application. It's more like when trying to debug emacs code inside emacs. Well, emacs still has two parts: one written in C and one written in emacs lisp, you wouldn't debug inside emacs the part written in C actually. The event loop processing in emacs is written in C, so while you can still botch the emacs image to the point of rendering it useless, some sanity
17:48:18
pjb`
kenanb: you have to remember that structure-class is not (necessarily) a standard-class. That's why defmethod work on structure-class and its subclasses, but not make-instance of slot-value.
17:48:53
pjb`
kenanb: also, integer is a built-in class which is also in a way, integrated into clos, given that defmethod works on built-in classes too. (class-name (class-of 42.0)) #| --> single-float |# etc.
17:49:35
Indecipherable
I think starcraft had an api for this sort of thing actually, not sure. "AI" bot fights being a thing and all
17:49:38
kenanb
pjb`: hmm, yes. so my other assumptions are right, except the make-instance one, right?
17:50:06
pjb`
emaczen: you can use com.informatimago.common-lisp.cesarum.sequence:replace-subseq, of course.
17:51:55
kenanb
pjb`: I believe there is an exception to assumption number 4 tho, if the type of the structure is a list or vector (in which case it is not even a real structure anymore but still) the slots that are neither manually initialized nor provided an initform should still default to a value. since a vector or list will be built out of them
17:52:03
pjb`
emaczen: (let ((seq (list 1 2 3 4 5 6 7 8))) (replace-subseq '(0) seq 2 6) seq) #| --> (1 2 0 7 8) |#
17:52:35
fourier
pjb`: Yes I got it. I just thought they could implement it as a separate process, but they haven't. Speaking of it, what is the most popular (and supported) logging library for CL, which could dump structs and class instances ? :)
17:54:25
kenanb
pjb`: or maybe it is permitted that an error can be raised on creation in case of absence for such slots as an alternative to initializing to something?
17:56:49
pjb`
Baggers: notice that it's in your best interest not to use defpackage in your macro expansion, but to call directly the functions make-package, export, import, use-package etc… The problem with defpackage is that its semantic upon repeated calls are implementation specific.
17:57:22
kenanb
pjb`: you mean for all types of structures or list/vectors? because the standard says what happens in an attempt to read them when they are not provided and not initformed is undefined
17:57:25
pjb`
or, you can use a version of com.informatimago.common-lisp.lisp-reader.package:defpackage
17:58:44
pjb`
kenanb: oh, you're right. I thought it was nil by default. Indeed, that means that even for a vector or a list, it might be something else than nil…
18:00:21
Baggers
pjb`: That's very interesting, why would there be multiple invocation in a case where the macro expands to a defpackage.
18:02:37
pjb`
Baggers: in the benign cases, the defpackage form has not changed, so hopefully it'll be idempotent. But you may have added or removed some external symbol, and added or removeed some packages from the use list, etc. Implementations are basically free to do whatever then want with the new definition. Most try to do something sane, but there may be conflicts. Most try to provide useful restarts, but they're not standardized, and the
18:02:40
Baggers
pjb`: true, but I dont see how this would differ from when using defpackage normally. Or is that your point, that defpackage in general has this issue (whether using macros or now)
18:03:32
pjb`
But since defpackage is problematic, when you define your own macro it's better to give it a definite semantics, by using the functions instead of the defpackage macro.
18:03:33
Baggers
pjb`: cool! so I'm at just as much risk now. It is really good to know though, thanks
18:04:00
kenanb
pjb`: but in case of a real structure object, it can be left uninitialized, in case of list/vector structures I see two possible exits: either it will be initialized to nil (or the specified vector element-type in case of vector structure type), or it may as well error on initialization because a structure of type vector/list is being created with slots that cannot be initialized, now I wonder if both of them are permitted, or if it
18:04:49
pjb`
Well, make-array doesn't specify a default default element either, and while make-list has nil, defstruct could call it with a different initial-value.
18:11:39
Baggers
Shinmera: no worries at all, I'm happy that it doesnt by default, good to know I can do this if needed though
18:12:55
Shinmera
Baggers: All the actual behaviour and look of the generated template is in https://github.com/Shinmera/staple/blob/master/default.ctml
18:26:05
kenanb
pjb`: yeah, what leaves me confused is that spec states the behaviour as undefined for reading such slot of an instance, which is ok for a structure class, but when it is a list or a vector, it implicitly means that "all slots should be initialized somehow FOR the object to be created", but should an object necessarily be created? an implementation may as well decide to default-default initialization for such slots to (error "No value
18:26:06
kenanb
provided, no initform exists, a vector cannot be initialized.") as long as the spec doesn't state that "objects will always be created regardless of initialization of their slots and the behaviour is undefined ONLY when an attempt to read the slot is made."
18:27:55
kenanb
pjb`: on the other hand it says that about default constructors: "It is as if the slot-initforms were used as initialization forms for the keyword parameters of the constructor function." which IMHO implies when no initform is explicitly specified, and when the keyword is not provided in initialization, it will default-default to nil, just as we expect with a normal function.
18:34:58
pjb`
kenanb: well, if an implementation leaves places uninitialized (eg. with safety 0), reading the car of a cons cell used to not store such an uninitialized slot value could indeed get you an random bit pattern and this could be interpreted by lisp as anything or nothing. It could crash your system, it could give you access to the "kernel", it could be any lisp object or something foreign, it could indeed be the address of the device tha
18:36:52
pjb`
kenanb: it's not what it says. It says that the constructor may use (&key (slot nil slotp)) (when slotp (setf (struct-slot struct) slot)) and when not slotp, nothing is stored. So assuming struct was allocated with a low-level, efficient, non-initializing allocator, you're framed.
18:38:51
pjb`
Well, actually the spec says: (cond (slotp (setf (struct-slot struct) slot)) (slot-initform-p (setf (struct-slot struct) (funcall slot-initform-closure)))) so you can indeed use (defstruct s (x (error ":x is mandatory")))
18:46:50
kenanb
of course I can do that, what I wonder is if the implementation is free to do that as a default-default, or should an implementation either not default to anything, or default to a value (and not a condition)
18:49:04
kenanb
anyway, I guess in practice an implementation will always default to something that fits (and vector-element-type slot-type) or slot-type or nil.
18:51:08
kenanb
pjb`: I understand and agree with your points, thanks god I was not considering not providing initforms as a practice, I was more curious of what happens on the edge cases.
18:52:47
kenanb
spec usually not only states what happens but also what the implications of the specified and unspecified behaviour are. for structures IMHO it does the second slightly less so, yet still pretty comprehensive in general.
19:00:52
pjb`
kenanb: some implementations, like sbcl or ccl specifically do not initialize arrays to nil when you don't give an initial-element.
19:05:48
pjb`
It should be noted that the unix kernels allocates pages by making them point to a 0-filled page with COW. So when you allocate big memory blocks, you get it filled of 0s. But once you've garbage collected things right and left, you could very well allocate new blocks on old data including references that have already been garbage collected, or not.
19:06:36
pjb`
Reviving old data would be bad for the garbage collector, so there's insentive for the implementations to reset it. But it could merely have a flag in the array to indicate that it doesn't contain any reference.
19:08:25
pjb`
So you could try to make an argument from the garbage collector point of view (which may read your arrays for GC purposes), but since the GC is not specified, it's not even sure you've got one, so the argument doesn't stand.
19:38:50
phoe_krk
pjb`: is it intended for your reader not to include UNQUOTE and BACKQUOTE functions?
19:50:44
pjb`
I could provide a default implementation, but most of the time you would want a different implementation.
19:52:54
pjb`
If you post an issue on one of git.framasoft.org, gitlab, or github, I might implement it, but I won't have time to start working on it before Q4.
19:55:31
circ-user-2glXF
how does one create a secure, temporary directory in a common lisp program?
20:00:57
circ-user-2glXF
the temporary directory functions in UIOP seem to just return "/tmp", which already exists
20:26:56
pjb`
circ-user-2glXF: one does not. You can create one that is probabilistically safe enough to use, or you can rely on the underlying OS to provide one.
20:37:12
Jonsky
hello, is there any way I can set the repl to go back to the top level automatically after displaying the error message?
21:28:24
pjb`
Jonsky: or you can implement your own repl: (defun repl () (loop (handler-case (print (eval (read))) (error (err) (terpri)(princ err)(terpri)))))
21:33:15
kenanb
pjb`: ok, I found the source of the problem looking at the latex sources of spec draft because it has inline comments from Barmar and KMP :D
21:38:15
kenanb
pjb`: from what I can see, it goes like this, Barry Margolin comments that they need to specify the case of no value no initform, they look at CLtL, CLtL used different language describing the case of non initialized values for arrays and structures, in an attempt to clear the confusion around two different descriptions of similar unspecified behaviour, they came up with one sentence that describes what really happens when you try to
21:39:26
kenanb
probably overlooking the fact that the representation of a structure can even be a list
21:41:29
kenanb
CLtL specified that "initial contents" are unspecified for defstruct slot, and they replaced that with a uniform version.
21:47:21
pjb`
Thulsadum: that is, if you don't use the variables, you can perhaps avoid them entirely?
21:48:39
Thulsadum
perhaps the function does exists, but, this was quick: (maphas (lambda (k v) k) some-hash) to extract the keys.
21:57:34
pjb`
Hey :-) cesarum version is more efficient than alexandria, which goes thru a maphash-keys function :-)
21:57:36
phoe_krk
http://paste.lisp.org/display/310982 <- someone just told me I broke the comments-to-code ratio so far.
21:58:16
pjb`
phoe_krk: for documentation and tutorial text, you could use #| |# so it wouldn't look like comments.
21:58:51
pjb`
Start the file with #| instead of #! and write text. Then you can have code sections with |# code #|; finish the file with |#.
21:59:55
pjb`
You should be able to configure mmm-mode or mumamo-mode to font-lock your text and your code adequately (ie, not setting #| … |# text in comment red.
22:05:37
kenanb
phoe_krk: if you are, and if you have many of those files, with much textual information and fewer amount of code, you may love using org-mode with CL code blocks for those.
22:06:39
phoe_krk
kenanb: it's the first file with such an amount of comments. :P I'll pass on org-mode for now, though later on I plan on learning it.
22:07:25
aeth
Imo you should learn org-mode like you learn anything else that's hugely complex. Just learn a few features and only use those.
22:08:25
phoe_krk
aeth: "like you learn anything else that's hugely complex. Just learn a few features and only use those."
22:09:10
aeth
Cthulhux`: I'm undecided on whether I prefer real todo lists or my old way of doing todo, which is to just delete completed items.
22:09:34
aeth
Sure it's nice to see everything that's complete, but if I just delete completed items then I can constantly change how I structure a todo list without having to worry about (currently) irrelevant stuff
22:12:11
Cthulhux`
something tells me that just setting deleted items to DONE is better in a couple of ways.
22:32:13
Petit_Dejeuner
"Imo you should learn org-mode like you learn anything else that's hugely complex. Just learn a few features
22:34:08
aeth
Someone's CL project just got to the top of HN: https://news.ycombinator.com/item?id=11324746
22:35:02
prion_
Hie! There is something I don't understand in PCL: The author describe a leak in the macro definition; it's in a do loop, which evaluate argument in not the same order the argument are passed in the parameter list! For example, the parameter list: (a b c); and the do evaluation: ((var1 c)(var2 b)(var3 a)). Why should I respect the order of the parameter list in my call? I don't understand
22:37:16
prion_
The different evaluations of the argument in DO is passed in the opposite order they appear in the macro call. Why is that a bad thing?
22:39:37
Petit_Dejeuner
yeah, it is http://www.lispworks.com/documentation/HyperSpec/Body/03_ababc.htm
22:39:38
prion_
I never took care of the order of my let definition comparing to the argument order...
22:45:16
phoe_krk
As in, (deftype asd-list-set-node () '(cons symbol (cons asd-list-set (or asd-list-set-node nil)))) - this actually blows my stack when used in typep, so I guess there has to exist another way if there is any.
22:50:28
prion_
In the standard: "it is not specified whether the definition of the operator in a function form is looked up before the evaluation of the argument subforms, after the evaluation of the argument subforms, or between the evaluation of any two argument subforms"
22:50:50
prion_
So why should I even care about any order if I don't know in what order the argument'll be evaluated?
22:52:08
Bike
when the function form is evaluated doesn't matter unless you do something crazy like (foo (setf (fdefinition 'foo) (fdefinition 'bar))), and doesn't matter for a macro.
22:52:17
prion_
If I understand well, If I pass a function with side-effect in the parameter of a function, I don't know when any of the argument'll be evaluated?
22:52:27
Petit_Dejeuner
You do know what order the arguments will be evaluated, you just don't know when the function to be called will be dtermined.
22:53:00
Bike
What that clause is saying is that in a call, like (fun form1 form2 form3), when "fun" is looked up is not defined.
22:53:04
Petit_Dejeuner
(could-be-evaluated-at-any-time the-first-argument-to-be-evaluated the-second-argument-to-be-evaluated)
22:53:11
Bike
it is, however, defined that form1 is evaluated between form2, and form2 is evaluated before form3.
22:54:57
Bike
all you really need to understand is that if a macro uses a list of forms like that, you should have them evaluate left to right to match the behavior of built in evaluation and all the standard macros.
22:57:29
prion_
That means that the way I define the parameter list is very relevant if I plan to use an argument which have side-effect
23:23:29
pjb`
In the case of Common Lisp left-to-right order of evaluation is even more important than in less languages, since we have symbol macros. Even what may look like a simple variable reference can actually have side effects!
1:28:50
MereMortal
I want the power to program my computer to serve a nice interactive website www.norecruiters.org jobs site and then clone getbig.com
1:32:46
Zhivago
Then you can decompose it into a database interface and a web interface, of which there are a number available for CL.
1:41:58
Heranort
hmm...anybody know about python? i want to know is there a function that similar to the ",@" in lisp for parameter destruction?
1:42:29
Heranort
I know it'd not proper to ask such a question but I failed to get into the #python channel :(