freenode/#lisp - IRC Chatlog
Search
15:30:15
mgsk
dlowe: (loop for i in '(1 2 3) with start = 0 do (format t "~D~%" start) (incf start i))
15:36:24
mercourisj
Alright, so I have within my program something like (defvar some-system-path (calculate-default-path)), when I compile my lisp image, the path calculated on my machine is persisted into the image
15:37:03
mercourisj
I want this software to work on other users computers as well, so somehow I should defer (calculate-default-path) to when they launch the program
15:37:21
mercourisj
because my defvar is a top level form, I was thinking of writing a macro that does this, does this seem like a good idea or no?
15:38:09
mercourisj
a macro that will take something like (def-deferred-var var-name var-initialization-function), and var-initialization-function will be invoked on startup to setf some defvar
15:39:58
mercourisj
AeroNotix: Yeah, I was going to put them in a list of vars that will be iterated calling their initalization function
15:40:08
mercourisj
AeroNotix: Something akin to the approach for the defcommand macro which also maintains a list of commands
15:41:02
AeroNotix
mercourisj: is there no way your program could be refactored to not need the global defvar?
15:41:28
mercourisj
well, consider *global-map* for the global key map, I guess yes, technically it is possible, but it doesn't make sense
15:41:40
dlowe
yeah, but so is threading a super-common piece of data through each and every function
15:41:59
AeroNotix
mercourisj: not wanting to start a war but emulating emacs style is a bad practice. Elisp is a terrible lisp and perpetuates bad style
16:20:48
pjb
mgsk: with clauses are evaluated before for clauses, it would be preferable to write them first.
16:22:35
Timzi
does anybody here run slime on a remote machine? I'm trying to connect to the remote repl, but my /tmp/slime.* file is created on the remote machine and tramp (or swank?) isn't recognizing it's not on my local
16:23:31
pjb
Timzi: never had a problem M-x slime-connect to connect to a remote, as long as swank-server was launched.
16:38:45
pjb
paule32: you didn't understand at all what I meant. I said to compile CLISP itself, not some library.
16:39:18
pjb
paule32: in the build instruction of clisp, it's explained how to configure it to link with readline, so that clisp can provide history navigation in its REPL on the terminal.
16:41:25
pjb
paule32: but basically, if libreadline is available it will be automatic. You can disable it with ./configure --without-readline
16:42:08
pjb
paule32: on the other hand, if libreadline is not in a standard place, you can indicate it with ./configure --with-libtermcap-prefix=DIR --with-libreadline-prefix[=DIR] search for libreadline in DIR/include and DIR/lib
17:01:21
pjb
ebrasca: CL is a programming language. Racket is a program, including implementations of programming languages. They don't provide anything in common.
17:02:02
ebzzry
Is there anything close to using CL as the language for displaying these slideshows? Or, really no?
17:02:42
antoszka
ebzzry: I'm sure you could hack up something quick using the new GL or Qt libraries, but there's nothing ready-made for slideshows that comes to mind
17:25:17
whoman
sigh. people will always want alternatives. what a world. but variety is the spice of life perhaps
17:26:11
whoman
i could only imagine how productive someone could be with eating/spewing lisp code with slime and paredit and emacs ; probably faster than thought. there is also a paredit alt called something like that too.
17:36:50
jjjjjj
new to lisp (from python), how to update this function? https://pastebin.com/cJVzSACd
17:38:15
jjjjjj
beach: I want "qaqqq" to match the "a" in "apple" but it doesn't, not very good with lisp so not sure how to update the function...
17:39:42
beach
It seems you don't have a very good specification of what you want. Where did you find this problem?
17:40:20
jjjjjj
beach: I made it up, I'm trying to learn lisp through small practice programs, hangman is a good starting point
17:43:15
pjb
jjjjjj: you have something in your cranial box. It's called a brain. You must start it up. Don't be afraid, it won't break, it won't wear. It'll be a little magical. Once you brains start working, you'll be able to think, and even to program!
17:43:57
beach
jjjjjj: If you don't care about characters that don't match, then just iterate through every character in WORD.
17:45:13
beach
jjjjjj: Maybe if you describe what role you want the variables WORD and GUESS to have, then it might be easier to help.
17:49:56
pjb
jjjjjj: You see, you asked about that the other day, from your specifications I gave you this function in your paste. But you didn't understand it at all, since you are not able anymore than days ago, to modify to match your refined specifixations.
17:50:59
pjb
jjjjjj: given a specification, we can imagine algorithms, and with the rich CL libraries, we can implement those algorithms in a concise and efficient way, but in a way, it's an opaque way. If you don't know the same libraries, you cannot understand it.
17:51:39
pjb
jjjjjj: so my suggestion now would be to start learning Common Lisp, by reading a tutorial, learning about the data types provided by Common Lisp, and the library functions provided to manipulate those data types.
17:52:05
pjb
jjjjjj: then, when you will have that basis, we will be able to talk about algorithms and how to best implement them using those opreators.
17:52:39
pjb
paule32: compile, load and quickload have a :verbose (and sometimes a :print) key parameters.
17:52:46
Xach
That is a good introductory book, but you need not read the whole thing before you come back with more questions.
17:54:52
pjb
jjjjjj: this is how I learned programming originally: I took the language reference manual, and for each new operator I learned, I wrote a little program to exercise it, to see how it worked. Only after that, I started trying to implement my own programs (and games).
17:56:07
jjjjjj
i don't know how much i can map my existing python knowledge to lisp, that could save time
18:00:29
pjb
jjjjjj: python is quite alien to lisp. For example, it is strongly based on statements, while in lisp there are only expressions.
18:01:00
pjb
jjjjjj: python is a OO programming language, but OO is only one abstration tool in lisp, amongst many others.
18:03:07
warweasle
pjb: I had to use python recently. It does some things well...but I can't get over the whitesapce as a delimiter.
18:03:08
jjjjjj
pjb: ok. but out of interest, how would you solve this problem in lisp: iterate each char in one string over another, returning matching chars or "-" as appropriate. I don't think I can solve it with my limited knowledge of lisp, but if I saw the solution I could learn from it..
18:04:23
jjjjjj
I mean, iterating each char over the whole of the other string. the last solution you gave me didn't do that.
18:05:19
pjb
(let ((word "apple") (guesses "qa")) (loop for letter across word if (find letter guesses) collect letter else collect #\-)) #| --> (#\a #\- #\- #\- #\-) |#
18:05:20
jjjjjj
"aaa" and "aaa" -> "aaa", "apple" and "aqqq" -> "a----", "apple" and "qaqqq" -> "a----"
18:56:13
jmercouris
I'm trying to determine if a symbol points to a function, I tried typep, but a functions symbol is of course just a symbol
18:59:30
White_Flame
there's fdefinition, fboundp, and a few others, but I think they all "signal" a condition if it's not a function
19:00:42
sjl
I don't think there's a function-designator-p defined by the standard, you'll probably have to implement it yourself
19:03:23
phoe
a function designator is one of the following: a function object, a symbol, or a list (SETF FOO) where FOO is a symbol.
19:04:16
jmercouris
so, I don't have to worry about hitting any edge cases as it will only be my own code
19:04:32
White_Flame
from the spec: fboundp is sometimes used to ``guard'' an access to the function cell, as in: (if (fboundp x) (symbol-function x))
19:06:14
sjl
phoe: not sure that last one is correct. (funcall '(setf car) :foo (list 1 2 3)) fails in SBCL with:
19:11:40
sjl
I wouldn't say it's "not following the standard" because it's not claiming to be function-designator-p
19:12:03
sjl
it's doing its own thing, and that happens to be something like jmercouris probably wants
19:12:27
phoe
I mean - it accepts an argument named FUNCTION-DESIGNATOR that does not have to be a function designator despite its name.
19:13:26
phoe
It makes a logical distinction, it's either a function or a function *name*, not designator.
19:13:53
phoe
But I can perfectly see why it is like that, and I don't want to change that behaviour.
19:50:55
jackdaniel
hey, anyone having ACL around? I'd appreciate trying to compile CLX (from develop branch) on it
19:56:42
phoe
the standard says nothing if it's permitted and/or intended for programmers to explicitly call initialize-instance in client code.
19:57:18
specbot
Object Creation and Initialization: http://www.lispworks.com/reference/HyperSpec/Body/07_a.htm
19:57:39
phoe
"The generic function shared-initialize implements the parts of initialization shared by these four situations: (...) when re-initializing an instance, (...)"
20:08:43
Bike
reinitialize-instance might not "reset" an instance depending on what you mean by that, though. particularly it doesn't reinstall any initforms.
20:08:58
didi
Idle thought: Isn't it interesting that #'format uses a control /string/ instead of a control /list/?
20:10:58
Bike
~{~a ~} being (start-loop aesthetic " " end-loop) would be kind of weird. ((aesthetic " ")) or something, indicating the loop as part of the structure would make more sense
20:16:55
jmercouris
Alright, so I'm working on a way to be able to pass something like '(print "lol") to (funcall)
20:17:22
jmercouris
I have a simple approach that is basically (funcall (first list-of-things) (rest list-of-things))
20:17:58
phoe
"~:[{~;[~]~:{~S~:[->~S~;~*~]~:^ ~}~:[~; ~]~{~S->~^ ~}~:[~; ~]~[~*~;->~S~;->~*~]~:[}~;]~]"
20:20:06
jmercouris
didi: just to be completely clear about my objective- I want the user to be able to pass a function as they normally would with args like this: '(function any-number of arguments :including-keyword args) and then execute that call at a later time
20:20:47
jmercouris
didi: does that make sense? or is my explanation not so good? I am pretty tired at the time
20:21:25
phoe
I'd rather pass the function object that I control rather than an arbitrary number of forms that you need to eval at runtime.
20:22:02
phoe
and no, it's not a burden. eval-at-runtime is pretty evil in Lisp anyway, and should be avoided wherever possible.
20:23:33
phoe
either a lambda without arguments *OR* a lambda with specified arguments that you will pass to it.
20:24:07
Bike
why can you not just do (push (lambda () (setf ,variable ,value)) *deferred-variables*)
20:24:10
phoe
like, if you want to execute user code that will do some things with object FOO, then you will want to accept functions like (lambda (foo) (user-code foo))
20:24:22
Bike
(incidentally, that's a thunk right there. you already understand this concept, hooray)
20:24:42
phoe
or you can go the around route and define *foo* as a dynavar, and expect your users to grab its value that way.
20:25:11
phoe
this way, you can "work around" the issue with function arguments. you just hide them in dynamic variables, which is ugly in its own way.
20:25:14
Bike
say you have (deferredvar fishes-count (count-fishes :type "salmon")), which i believe was what you wanted your example to be
20:25:36
Bike
this will macroexpand into (push (lambda () (setf fishes-count (count-fishes :type "salmon"))) *deferred-variables*)
20:25:40
jmercouris
Yeah, it was, but I changed it for simplicity half way, missed a few spots I guess :D
20:26:35
jmercouris
I wasn't thinking straight, I was thinking of it as multiple values, but it is just a single list
20:27:23
_death
I use :default-initargs to.. pass defaults for initargs :).. if a slot has no initarg, then I use :initform
20:35:52
Bike
i found a probably longstanding if nontrivial to trigger bug in ecl about them the other day, but just due to reading source
20:48:51
didi
I shall put this `out' macro with the series package for when I am courageous enough to incorporate them into my programs.
21:06:13
jmercouris
Ah, nvm, I do see how it is possible, sorry for the interruption, I should probably just go to sleep
21:36:40
_death
jasom: if you mean the one in ytools, it doesn't.. for my own, I use an old trick to pass context around
22:21:34
Xof
in one of those Small World kind of things. "What do you do?" "Oh, really, what lisp do you use?" "Oh, really, do you want to know something funny?"
22:22:39
Xach
Lisp music software seems to exist in its own world (much like every other piece of the lisp world)
22:58:13
stylewarning
One exercise in Scheme is learning how to do macros that capture name. One such exercise is writing a macro with-degrees (&body) which lexically captures sin/cos/tan and defines them as functions of degrees. In Common Lisp, you can't lexically shadow symbols in the CL package.
22:58:43
stylewarning
Nonetheless, I'm curious how someone might actually solve this. Code walk and replace? Does anyone have a simple example of how to do it with current libraries?
23:06:21
p_l
I'd love a "trivial-codewalker" that would just hook into compiler innards of the implementation in layerable way :<
23:09:30
scymtym
p_l: https://github.com/scymtym/sbcl/blob/wip-walk-forms-new-marco-stuff/examples/code-walking-example-without-clos.lisp
23:26:57
jasom
stylewarning: just shadow the symbols in your current package, and set their fdefinition to be the CL: equivalent
23:27:46
stylewarning
jasom: of course you can do that; the idea of the exercise was to just provide a small convenience without extra packages and the like
23:28:03
stylewarning
and of course it's not possible, with a macro, to change the package over the lexical scope of the macro
23:28:54
jasom
stylewarning: short of walking the entire tree and replacing the symbols, I can't think of a way. If it were easy that would violate a core part of lisp's macro hygiene
23:29:22
stylewarning
jasom: Sometimes I do wish it were possible to selectively turn that stuff off.
23:29:42
jasom
stylewarning: sbcl lets you disable package locks, so you can on at least one specific implementation
23:34:17
stylewarning
jasom: I need to learn more about these neat features of SBCL. I usually scan the manual every so often, but I guess I missed/forgot this.
23:36:39
scymtym
stylewarning: speaking of which: we just made the manual look a little nicer and documented the different kinds of timeouts in SBCL
23:49:36
scymtym
didi: we just applied a different stylesheet to the HTML version. does that alleviate your concerns?
3:26:06
borei
i have question about lisp code optimization - matrix multiplication in my case. i undestand that topic is rather big, but still, some recommendations would be nice. I was trying to find best solution in C/C++ but didn't get explicit answer for it