freenode/#lisp - IRC Chatlog
Search
13:24:35
mercourisj
Yeah, I've been looking at run-program...I'd need to spend a little bit of time to understand it
13:41:01
pfdietz
(coerce <sequence> 'simple-string) will give you a simple-string, since the value returned by (coerce x y) is of type y.
13:44:50
KZiemian
Xach: I must left reading PCL for sickness of to much theory and to less programming
14:11:19
AeroNotix
PCL is imho the best book to learn CL imho. It doesn't put CL on a pedestal like a lot of books do. It treats the language just as a language. Rather than trying to put a halo of mythology around it.
14:12:53
dlowe
Honestly, it was the most amazing thing for a long time, but these days it's a solid middle-of-the-road language with a lot of history.
14:16:03
AeroNotix
Don't know about that. I use a lot of the new fangled languages and I still find myself thinking how much easier things would be in CL.
14:16:36
AeroNotix
literally the only thing I think CL doesnt have going for it is a good standardized concurrency model. there are good libraries which are portable but still.
14:43:34
AeroNotix
rumbler31: I just mean that in the CL standard it doesn't standardize any concurrency interface as far as I know (threads, actor model etc)
14:44:36
Shinmera
atomicity of operations and the memory model are good things to know for concurrency.
14:45:17
AeroNotix
Right and if CL specified a higher level interface for say, threads and related functionality (mutexes) a lot of the atomics are implied.
14:45:21
dlowe
Yeah, the newer languages all have their own scheduler and so far only CMUCL has done this (that I know of) and it wasn't amazing.
14:45:48
heisig
AeroNotix: sometimes I have the impression that concurrency is such a blurred topic, that maybe the best approach is to leave it outside of a language standard...
14:46:22
pjb
AeroNotix: on the contrary. For example some implementation (having threads), ensure atomicity of hash-table accessess while others don't.
14:46:33
AeroNotix
pjb: depends how you look at it. If it's parallel and you specify a mutex interface the implementation would require some level of atomicity
14:46:54
Shinmera
heisig: The problem with that is that it becomes very hard or impossible (under efficiency constraints) to write portable software.
14:47:03
pjb
AeroNotix: even setf of a variable is not always implemented atomicly (eg. on 64-bit machines with 32-bit data bus, you could end with botched data or references!).
14:47:34
pjb
AeroNotix: the alternative would be to have locks everywhere! It would be way to slow for most purposes.
14:47:38
AeroNotix
What I was meaning is that if there was a standardized concurrency interface a lot of those issues would've needed to be addressed.
14:48:40
pjb
On the other hand, the application developper usually know what his mutexes are, so he can add only the locks that are needed.
14:49:27
AeroNotix
Right, I agree with that approach. I wasn't meaning that (for example) setf would need to become atomic as part of the standard just that having a concurrency model in the standard that operations like setf would need to have their atomicity explained.
14:49:34
heisig
Shinmera: I know. On the other hand, standardizing on concurrency can also screw you at a later time if hardware capabilities change.
14:50:12
AeroNotix
pjb: I've had it said to me before that including a concurrency model in the standard would've been a bad idea. For example if green threads or the actor model was chosen and a new technology appeared and rendered it obsolete
14:50:26
rumbler31
well so... what, is the argument that languages that have concurrency friendly intrinsics may restrict implementation flexibilty?
14:51:03
pjb
AeroNotix: indeed. Imagine you're implementing CL on a GPU. You won't have the same problems at all as when implementing it on a CPU.
14:51:33
AeroNotix
Right. Perhaps if the API was described broadly enough #'EXECUTE-CONCURRENTLY or something. That doesn't imply any particular model.
14:51:48
pjb
At one time, processors didn't have cache memory and memory barriers. Now they all have it.
14:52:19
Shinmera
rumbler31: Yes, though that's only part of it. The other part is that the requirements by the spec may be too harsh or even wrong, affecting not just implementations but also users.
14:53:35
AeroNotix
yeah it'd be a poor experience if they added a model which only made sense at the time but was superseded by better technology today
14:57:32
dlowe
If it were abstracted with a nice interface, the implementation could use the better technology.
15:05:01
AeroNotix
sure, if you kept it generic enough the underlying implementation could be whatever you needed it to be. That said, some models would need primitives for model-specific operations
15:09:00
mgsk
How do I do something like this: https://gist.github.com/notmgsk/3204d1ce758dff6702b3389a33ecc5b0 I want START to begin at zero, and then increment it at the end of the loop
15:17:46
mgsk
Begin with start = 0, then at the end of the loop, set start to start = start + something
15:24:28
mgsk
dlowe: (loop for i in '(1 2 3) for start = 0 then (+ start i) do (format t "~D~%" start))
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?