freenode/#lisp - IRC Chatlog
Search
8:53:14
givre
beach: I believed that placing the ,@ before a form instead of the parameter would splice differently, which is far fetched yeah
8:53:27
beach
givre: Like I said, ,@ will evaluate the form that follows, in my case (list 1 2 3 x) and then splice the elements of the resulting list into the COND.
8:59:25
givre
givre: the find-element function is awaiting a function parameter, i passed it this way and then applied it in the body when i was not using the list
8:59:41
beach
givre: I suggest you write a function that returns the list ((find-element 1 '(1 2 3) (lambda ...)) (find-element 1 '(1 2 3) (lambda ...))). Once you have that, you can stick a call to it after the ,@ in your macro body.
9:00:47
givre
beach: I guess for the #' I don't need to use it because my lambda will be #'ed in their list anyway right ?
9:02:00
beach
There are "functions" and "lambda expressions" (which are not functions, but code), so again, it depends.
9:06:37
beach
givre: Here is a better example: Consider the macro (defmacro baz (x y) `(list ,x ,y))
9:07:48
beach
In the first case, you are passing lambda expression to the macro function, because macros do not evaluate its arguments.
9:08:13
beach
In the second case, the reader will create functions for you and those will be passed to the macro function.
9:11:11
TMA
givre: to macroexpand is to call MACROEXPAND on the (quoted) form, not to _run_ it (possibly call MACROEXPAND-1 to look at one level of macroexpansion at time)
9:12:32
aeth
You usually want macroexpand-1 because macroexpand will leak implementation details as it keeps expanding well past the standard forms
9:13:29
beach
It is just amazing that you are trying to write a macro this early in your Common Lisp training.
9:14:51
beach
givre: So with all this information, you should be able to write a better version. But I this is too basic for #lisp, so next time you need help, I suggest you visit #clschool instead of #lisp.
9:15:43
givre
beach: i've been doing a bit of common-lisp for times to times over the past few years, but right now i've got the opportunity to write some POC at work and real code so here am I
9:16:09
shka_
givre: there are multiple ways to implement such functionality, and macros have major drawbacks
9:17:53
aeth
I recommend people stick to established patterns when learning how to write macros. DO-FOO, DEFINE-FOO, and WITH-FOO are all simple and are the vast majority of macros you'll probably see/write
9:19:02
givre
shka_: ok, i was about to ask for betters leads. higher order functions are something I can relate to a bit more indeed !
9:22:02
shka_
anyway, contrary to what many would say, you can spend whole day in CL without defining your own macro
9:28:29
givre
shka_a: Sure ! I'll write this macro anyway since I invested time in it, then I'll stick to actually writing code.
9:31:48
Demosthenex
so i have a simple http api to postgres project i'm doing, i'm considering threads to run requests in parallel. i have no global or shared variables, other than potentially postmodern's db connection and dexador's. i'm reading on bordeaux threads, any other suggested reading?
9:37:44
shka_
Demosthenex: lparallel is thread pool, futures, some paralleized higher order functions, sync queues and some other stuff
9:39:53
Demosthenex
i think this is a simple job and a good fit for parallelism... so i'll give it a go
9:46:39
makomo
i was scrolling through SBCL's sb-walker codewalker and stumbled upon this comment https://github.com/sbcl/sbcl/blob/master/src/pcl/walk.lisp#L393
9:47:48
makomo
implementing special forms as macros should be conforming afaik, but does the same hold for the reverse?
9:51:45
beach
"An implementation is free to implement a Common Lisp special operator as a macro. An implementation is free to implement any macro operator as a special operator, but only if an equivalent definition of the macro is also provided."
9:54:13
Demosthenex
shka_: give i know how many pages of data i'm downloading, i'm thinking of just using pmap
9:55:39
makomo
beach: so for the purposes of a code walker, one can just ignore the fact that a macro is implemented as a special operator when there will surely be an equivalent definition of the macro
9:57:22
makomo
beach: mhm. the "codewalker problem" is quite an interesting one, and i always wonder how useful would a codewalker within the standard be
9:58:35
pjb
makomo: or in a library, no need for a standard. The only thing, would be that implementation don't have macros that expand to non-standard special operators that don't have a macro expanding only to standard operators.
9:59:19
makomo
i've watched michael raskin's talk on a portable codewalker, and from what i've seen, doing it portably isn't really possible
9:59:37
pjb
beach: the implicit in "but only if an equivalent definition of the macro is also provided." is that this macro expands to standard special operators…
10:00:22
beach
makomo: So for those parts, come up with a CLOS protocol so that implementations can configure it.
10:00:43
makomo
beach: mhm, i get your idea, but it would still be nice if it could be done 100% portably
10:01:54
makomo
i think i have a vague idea (i forgot much of the talk) -- it might have something to do with environments
10:02:36
makomo
but, reasons for it not being possible aside, i would still wish that it could be done portably
10:03:51
beach
The problem is that the implementation may call MACROEXPAND on a lexical environment.
10:08:36
makomo
beach: reading your code walker specification that i just found -- good stuff! a minor typo: "and interpreter" https://github.com/robert-strandh/SICL/blob/master/Code/Cleavir/Code-walker/Specification/code-walker.text#L70
10:10:53
makomo
beach: i think christophe's post was about "let over lambda", not "land of lksp" (assuming we're thinking of the same article) https://github.com/robert-strandh/SICL/blob/master/Code/Cleavir/Code-walker/Specification/code-walker.text#L15
10:11:09
pjb
beach: I don't think a code walker should expand the standard special operator as macro ever.
10:11:14
makomo
here's the post about code walking: http://christophe.rhodes.io/notes/blog/posts/2014/naive_vs_proper_code-walking/
10:16:53
makomo
j`ey: a program that knows how to "interpret" common lisp code and that can tell you various stuff about it
10:16:56
jackdaniel
since body contains code, such macro has to understand meaning of special forms, macros, functions, variables etc
10:17:10
makomo
"interpret" not in the sense of executing it, but in the sense of "walking" it and "figuring out what the code does"
10:18:51
jackdaniel
since code walking is non-trivial in common lisp it is hard to get right (hence it is rarely used in "normal" applications)
10:23:33
pjb
beach: Yes, https://github.com/robert-strandh/SICL/blob/master/Code/Cleavir/Code-walker/Specification/code-walker.text#L98
10:24:12
pjb
The code walker should not always try the macro first. If it's a special operator, it should call the user function with it, and let it interpret the special form.
10:25:20
makomo
beach: ah :-). i suppose this text will eventually become part of the main SICL spec (the collection of tex/pdfs you maintain)?
10:25:21
pjb
beach: now, there may be an option to do what you specified, but in general, I wouldn't use it.
10:25:48
makomo
beach: "during during" https://github.com/robert-strandh/SICL/blob/master/Code/Cleavir/Code-walker/Specification/code-walker.text#L63
10:26:09
beach
makomo: Possibly. Since I couldn't remember having written it, it might have been forgotten.
10:26:30
makomo
beach: "body code" ("body of code" perhaps?) https://github.com/robert-strandh/SICL/blob/master/Code/Cleavir/Code-walker/Specification/code-walker.text#L79
10:26:48
pjb
The thing is that such special operator macro will most certainly do implementation specific things, such as ignoring ignorable special operatorns (eg. THE). A code walker will usually want to be conforming and extract the semantics of the program in an implementation independent way.
10:27:49
makomo
the thing about not trying macros first is also mentioned in the comments of sbcl's walker https://github.com/sbcl/sbcl/blob/master/src/pcl/walk.lisp#L389
10:39:27
makomo
beach: "a code walker (...) that collect (...)" https://github.com/robert-strandh/SICL/blob/master/Code/Cleavir/Code-walker/Specification/code-walker.text#L112
10:41:52
dim
as with many things in CL I though it was somewhat overkill until I had a use for it ;-)
11:23:07
jackdaniel
Xach: CG memos you've shared the other day by Alvy Ray Smith are true gems, thank you again for sharing the link
11:32:05
Xach
jackdaniel: many years ago i ran a GIMP web forum and he joined and asked if gimp was making the mistake of being rectangle- and square-centric with regard to images and layers, and a few deveopers chimed in that those were the most natural and anyway image formats are all square, and who are you, anyway, old man
11:32:20
Xach
jackdaniel: it was pretty embarrassing when i saw him in a pixar documentary and he was a founder
11:33:59
jackdaniel
truth to be told, orbitrary shapes/ transformations for various objects make my life certainly worse than it should be (mcclim-wise)
11:34:53
Xach
right - his notion is to break free of tradition and ease - kind of like how gc frees you, even though making gc work is difficult
11:34:56
jackdaniel
and it is just in time I've read it, because next biggish thing I want to add to mcclim are animations
12:48:32
oni-on-ion
aeth: are you still awake or up yet? what did you mean earlier when you said that funcall happens differently on 'foo than #'foo ? i think that might be part of a problem i ran into last nacth
13:13:08
EvilTofu
Moo. I've just downloaded CCL 1.11.1 from the Apple Mac App Store. HyperSpec look ups just give me a Map_Sym.txt file not found dialog. Is there a fix for this?
13:14:30
oni-on-ion
never heard of that before. i myself use slime in emacs with HyperSpec downloaded from lispworks.com and the help lookups (C-c C-d h) are great
13:21:27
oni-on-ion
aeth: ah it did solve my problem! i've got to learn the difference between #'foo and 'foo now.
13:33:41
pfdietz
"Because static typing is primarily about optimization, not correctness, and optimization is only important in certain places."
13:38:47
oni-on-ion
for me, types help to design data structures, which helps to plot and plan - where most i guess use paper or their own heads
14:26:51
oni-on-ion
slime-highlights is really great. make changes anywhere, they are highlighted, C-c C-c to compile those
14:34:57
oni-on-ion
could we use setf places in let forms? ie. (let (((slot-value h 'conn) (make-connection..))) ...)
14:38:47
trittweiler
oni-on-ion, search for LETF. It used to be provided on the Lisp machine. And implementation based on setf + unwind-protect is easy, but it doesn't really work well in multi-threading environment (contrarily to LET, both for lexical bindings (trivial) and dynamic bindings)
14:39:25
oni-on-ion
trittweiler: ohh,i thought that letf was for functions on just the right hand side only =)
14:40:06
trittweiler
there's also an implementation of lets in Emacs' cl implementation. Probably can just take that. Or search comp.lang.lisp
14:56:27
schweers
I have a hopefully quick question. I don’t indend on doing this, partly because I don’t know how. I just want to know a) if it could be done, and b) whether that would be considered sane. Suppose I want to place very simple datastructures (for the sake of argument, lets say something like a defstruct) in a specific place in memory, like a memory mapped file or shared memory, or something similar. Can the MOP be us
14:57:27
Xach
oni-on-ion: if it's (defmethod frob ...) you would inspect the #'frob generic function, and slime shows a list of methods with options to remove
14:57:49
oni-on-ion
https://github.com/robert-strandh/CLIMatis/tree/master/Applications/Clouseau <-- ah there is !
15:05:16
oni-on-ion
hey so. how come (slot-value h :conn) does not work, but (slot-value h 'conn) does -- when defclass slot was set to :initarg :conn ??
15:05:40
Xach
oni-on-ion: the :initarg is the symbol used in make-instance, not the name of the slot.
15:09:25
Xach
jasom: I am trying to build a cuda library and i don't care if it really works, i would just like a (possibly non-working) .so to see if I can make progress.
15:23:10
pjb
mkdir -p ~/quicklisp/local-projects/com ; cd ~/quicklisp/local-projects/com ; git clone https://github.com/informatimago/lisp.git informatimago
15:24:02
pjb
But it counts only from the time loaded, so you have to insert this (ql:quickload "com.informatimago.common-lisp") in your rc file.
15:59:34
makomo
if i want to communicate that a slot should be initialized to the empty slot, should i use :initform () or :initform '()
16:04:44
shka_
I think that in the case of slots, it is beneficial to supply :type option in order to be more explicit about your intents
16:06:06
pjb
(mapcar (lambda (other-nil) (eq nil other-nil)) (list nil () 'nil '())) #| --> (t t t t) |#
16:06:40
makomo
mhm. misunderstood what you said there (thought you weren't talking from a style standpoint)
16:07:36
beach
(let (a b c) means a b c are "uninitialized" so the person reading your code expects them to be assigned to before being used.
16:09:09
pjb
There's notably the case of (let (a) (declare (integer a)) (setf a 42)) ; technically before the setf, reading A would be a bug, since we would read NIL as an integer!
16:10:05
pjb
But it does, because lexical variables cannot be unbound. and local dynamic bindings must shadow the outer dynamic binding.
16:15:15
makomo
beach: we've discussed this before and you also mentioned it yesterday again -- using accessors internally instead of directly using slots. then, if one wants the client to actually use some of those accessors, one should export the respective symbols, right?
16:15:40
makomo
beach: but what about when you want to export e.g. only the reader, and not the writer? this isn't really possible, is it?
16:16:21
Bike
i've a few times had ":accessor %foo :reader foo", defined a special (setf foo), and then exported foo and not %foo
16:16:28
makomo
oh, good point, didn't think of that. what would be the canonical names then? %something?
16:18:46
Xach
beach: sorry. i misread as :writer %foo, which can be confusing, because plain functions don't often use setf argument style.
16:19:13
Xach
when i first tried separate :reader and :writer, i thought :writer foo would create (setf foo)
16:19:21
Xof
if you do that because you don't want users to mess with slots, you might also want to make sure that your initarg(s) isn't/aren't exported
16:19:41
Xof
otherwise users will defeat your protections by using (reinitialize-instance object :%bla 3)
16:19:57
pjb
pfdietz: stylistically, it would be bad. But notice about arrays, that if no :initial-element or :initial-contents is given, the memory is not initialized so you could get mis-interpretation of the bits, and the standard only says: "don't do that".
16:21:35
pfdietz
The standard pretty explicitly says the declaration has to be in effect right after the binding occurs, even without an explicit reference by the user. Look up bound declaration and declaration scope. Undefined behavior if not the right type.
16:23:38
beach
Xof: I had an interesting phone meeting with Didier Verna today about my solution (in SICL) to method combinations. He seems to think it is sound, so there might be a joint ELS paper submission at some point.
16:24:41
Bike
pfdietz, pjb: clhs type says initial values of the variables have to be of the type. seems straightforward.
16:24:57
spm_
I'm having a little trouble understanding how quoted lists get applied as default &key arguments. I thought the list would be passed fresh to each call of a function, but the list seems to persist across calls. Clearly wrong-thinking on my part, but I'm not entirely clear why.
16:26:32
pfdietz
The user has not given an explicit value, but the standard says what the value is. It's NIL.
16:27:28
pfdietz
"3. At the moment the scope of the declaration is entered, the consequences are undefined if the value of the declared variable is not of the declared type. "
16:27:34
spm_
Xach: Thanks. Yes, I figured out how to not have the problem, but am not clear regarding in-what scope the quoted list becomes defined, and what happens on subsequent calls to the function.
16:27:46
pjb
spm_: the init-form is evaluated at call-time, only if no matching keyword argument pair is given.
16:28:06
Bike
spm_: nothing to do with &key. you are editing quoted data, which is always undefined behavior.
16:28:36
pfdietz
"The scope of a bound declaration is the same as the lexical scope of the binding to which it applies; [...]"
16:29:07
pjb
spm_: so the question is whether you want the same list or a new list each time: https://pastebin.com/sz43meDi
16:29:47
Xach
sbcl can be quite helpful with warnings about modifying quoted/literal data, but it doesn't catch everything
16:32:49
spm_
pjb: Yes. new value each time was what I was after, and not what I was seeing. My thinking was that a new quoted list would be created each time the function was entered if it wasn't provided.
16:35:07
Xach
spm_: possibly because someone could pass a keyword and the warning wouldn't apply...not sure.
16:35:57
pjb
(defun f (&key (x (error "You need to pass a :x argument!")) y) (list x y)) (f :y 42) #| ERROR: You need to pass a :x argument! |# (f :x 42) #| --> (42 nil) |#
16:36:31
spm_
Thanks for the assist. I need to do more reading on compile/init of functions as the "why" still isn't fully clear to me, but if the behavior of modified quoted literals is undefined, then I certainly ought not do that. :-)
18:19:32
AeroNotix
each logger within a system/package/function highlights which logger it came from within the slime repl, which then exposes that logger as something you can interact with (forget what slime calls it, the C-c C-v TAB things) that you can then configure right within your REPL.
18:42:25
jackdaniel
having mcclim work on windows requires Xserver run on windows and this is a tedious thing to make it work
18:42:33
epmor
Already tried, it was after libssl32.dll and some other DLLs tht were difficult to get working on windows
18:42:54
dim
jackdaniel: did you try with the Xserver embedded in https://mobaxterm.mobatek.net already?
18:44:36
oni-on-ion
he is more so askin about xplat gui than how to get clim working on windows, imo
18:45:21
jackdaniel
when I'm doing something on windows (usually testing in a VM) I grab cygwin, install emacs and operate from eshell
18:45:37
jackdaniel
I suppose it is lame by windows standards, but I easily get confused how to get thigns working there
18:48:56
dim
jackdaniel: it embeds a full Xwindow server so I think it might be useful for your tests, and also it comes with unix developer tools and an apt-get command, so, it might help…
18:49:07
makomo
i need advice regarding a DSL. i've written it up here as a comment, with an example of the DSL below: http://plaster.tymoon.eu/view/917#917
18:49:27
dim
I'm not sure how much you would improve towards a typical windows user, but if you manage to reduce your environement dependencies to a single app that'd not be too bad
18:53:44
makomo
even if i did use methods for that (instead for example, FUNCALL-ing and creating the functions myself), i still need to use the process' body to create this function
18:54:28
makomo
and the process' body isn't valid Lisp code right away. it requires some analysis to inject proper LETs and such
18:54:52
makomo
shka_: right now it's a normal function. <- being a macro is just one proposed solution
18:55:48
makomo
well, i do too :-), but i need a way to walk the :process bodies and find all of the signals (<- **HERE** <expr>)
18:56:59
makomo
:signals are internal signals of the component. the thing i'm looking for is finding "drivers"
18:57:19
makomo
if a process ever assigns to an internal signal, it counts as a driver for that signal
18:58:25
makomo
yeah. the fact that these are implemented as Lisp functions internally doesn't mean anything
18:59:20
makomo
well actually, i'm not so sure i can go about it that opaquely. the :process' body is arbitrary Lisp code
19:00:11
makomo
because this process attempts to assign to A (even if it never does so within an actual simulation), it counts as a driver for A
19:02:19
makomo
i'm not sure how to do that. either a code walker or making <- a macro and doing it at macroexpansion time (and also arranging for <- to be macroexpanded in the first place)
19:02:57
makomo
shka_: they are, since there isn't really a way for me to restrict that. the DSL assumes that a :process' body will be "well behaved"
19:04:17
makomo
but this is something i don't care about, because the alternative is writing my own language from scratch
19:04:47
makomo
no, it is evaluated and who knows what happens. the condition bubbles up the simulator and aborts it
19:05:16
makomo
i could also modify the simulator's internals within a process for example, which is also insane
19:05:20
_death
using a code walker can make sense.. but even a dumb tree walker approximation may work for a POC
19:05:47
makomo
_death: eventually i want to introduce helper macros and such for patterns that arise in VHDL itself
19:07:41
makomo
so it's as complex as Common Lisp itself. that's why i need a code walker to do it properly
19:08:25
_death
right.. I learned about agnostic-lizard during ELS, and the code looked nice, may want to check it out
19:11:05
shka_
basicly build lambda form with whole body + macrolet for <- that basicly signals symbol passed as first argument, then call compile on it
19:11:36
makomo
yeah, that's almost the same as the macroexpansion solution, except you avoid the manual call to COMPILE
19:12:54
makomo
shka_: i'll already have to do something like that for these internal signals though
19:13:14
makomo
see how there are no LETs within the process? it's implicit that the process can access the local :signals of the component
19:17:14
makomo
shka_: another reason why i want the process' bodies to be arbitrary lisp code is for various reporting functionality and interaction with the simulator itself
19:17:43
makomo
for example, you could imagine a "debugging protocol" that a component could support and implement, that would allow one to debug the defined component
19:20:07
makomo
hm, but the code walker will probably yell at me if i try to walk the incomplete body (as its specified by the user), right?
19:21:25
makomo
so i would have to generate the whole body before i can walk it (which isn't an issue, i think; just mentioning it)
19:24:14
makomo
ideally i would use something portable (although that's hard to achieve for a code walker), but as an initial iplementation, an internal code walker would do as well (sb-walker is the easiest to get)
19:24:40
pfdietz
shka_: thank you for that. There's an issue in Waters' COVER package that might solve (how to get from macroexpanded code back a representation of the source code it came from, to produce useful output). COVER's solution is a bit of a hack that isn't compatible with some macros, like ITERATE.
19:26:49
pjb
Bike: See https://github.com/informatimago/lisp/blob/master/common-lisp/lisp/relative-package.lisp#L106
19:28:16
shka_
it is ironic that it is easier nowadays to read lisp code from stream or string, use eclector.concrete-syntax-tree and walk that then actually deal with lists
19:33:40
Xof
makomo: not really tested, but: https://gist.github.com/csrhodes/8d74a1749a042a780d4c4ef1a42a6752
19:38:31
scymtym
Bike: it's a spec but there is also http://www.sbcl.org/manual/index.html#Package_002dLocal-Nicknames
19:49:37
pfdietz
Just sexprs. It also produces small structures that get stored in the compiled code (more properly, regenerated at load time using CL's mechanics for that so you aren't clobbering constants values) to record when parts are visited.
19:51:04
pfdietz
Richard Waters' portable CL coverage package. It records what part of your code you've executed.
19:52:27
pfdietz
It should be, but I think there may be portability issues? Was thinking of uploading it to github anyway (I think it's off on an ancient CMU lisp archive site.)
19:53:39
pfdietz
At one point I modified COVER for my own use to allow some extensions, like recording of coverage information in a file (so it could be combined from separate test runs) and checkpoint/rollback of coverage (useful for minimizing test cases under the constraint they still increase coverage.)
20:00:01
scymtym
eclector and concrete-syntax-tree would probably allow producing sb-cover-style annotated sources as output
20:25:23
AeroNotix
It requires that you compile your files with certain declaims active and then deactivate those declaims when you want to compile other files.
20:26:14
aeth
oni-on-ion: #'foo is the function object foo, 'foo looks up foo so if foo is redefined the 'stale' object isn't used.
20:31:39
aeth
oni-on-ion: (defun foo () (print "Hello")) (defun bar (f) (funcall f)) (let ((a (vector #'foo 'foo))) (bar (aref a 0)) (defun foo () (print "Goodbye")) (bar (aref a 0)) (bar (aref a 1)))
20:45:05
aeth
oni-on-ion: I don't want to say something incorrect, and there are test cases I wrote where even #'foo uses the redefined function (at least in SBCL), such as directly binding #'foo in the let instead of placing it in a vector
20:45:14
aeth
i.e. (defun foo () (print "Hello")) (defun bar (f) (funcall f)) (let ((f1 #'foo) (f2 'foo)) (bar f1) (defun foo () (print "Goodbye")) (bar f1) (bar f2))
20:50:01
aeth
Is there a way to check that object foo implements a method for the generic function quux? More concretely, I have an unwind-protect that is supposed to clean up all of the foreign OpenGL data at the end of the program. This actually would be a good candidate for a generic (and performance is not absolutely an issue since it's run once, at the end).
20:50:28
Bike
You can look up whether a generic function has an applicable method for a given class.
20:51:27
aeth
Bike: I think the user would probably be in for quite a surprise if (cleanup foo) failed because cleanup isn't defined for foo, and it probably would be a good thing to check for before starting instead of letting the user potentially leak memory upon closing the program. (A leak because the REPL will probably keep running.)
20:52:14
Bike
i'd usually like to avoid relying on that kind of introspection in the middle of a program, but that doesn't seem unreasonable.