freenode/#lisp - IRC Chatlog
Search
15:27:27
Shinmera
And what prevents you from just supplying a foo* that calls foo with the argument you need?
15:27:51
flip214
what I'm asking is can I do something like (defmacro foo (args) (values `(,foo state ,@ args) :STOP-TRANSLATING-THIS-FORM)))
15:28:21
flip214
Shinmera: it's still not possible to use the _visible_ symbol for tracing, seeing the documentation, etc.
15:29:21
Shinmera
Though arguably the docstring shouldn't be the same since it'll be supplying a hidden argument
15:30:19
Bicyclidine
What if the user was to write in the state argument? It would fail, if I follow correctly.
15:31:07
Bicyclidine
the macro and the function are essentially two different things. Giving them the same name is just confusing.
15:31:54
flip214
Bicyclidine: well, perhaps I should just put all that on a blog somewhere... having the big picture makes discussing about the feature easier
16:14:38
pjb
minion: memo for Josh_2: perhaps you want to count the ACTUAL number of operations needed to sort, and compare that for your different inputs. For sort algorithms, it's usually the number of swap that is counted. Or the number of accesses to the sequence. Or the number of comparison. Unless you have your own quicksort implementation, if you use cl:sort it will be easier to just count the number of comparisons.
16:17:00
pjb
paule32: at this point, it might be a good idea to read a book about NLP… Perhaps Gazdar & Mellish, Natural Language Processing in LISP - An Introduction to Computational Linguistics, Addison Wesley.
17:06:53
emaczen
SBCL does a tail call optimization but CCL instead overflows the stack. Any suggestions for getting CCL to do the same tail call optimization?
17:20:07
schweers
emaczen: SBCL does tco depending on the optimization settings, maybe CCL does so to, but has different criteria?
17:21:59
emaczen
schweers: I'm just finding out that my optimization settings are not what I thought they were.
17:22:39
emaczen
I expect (declaim (optimize ...)) to be evaluated at startup in init files for each implementations compiler.
17:25:14
schweers
emaczen: um, I’m not sure, but it might be that declaim only has an effect during the compilation of the file in which it occurs
17:28:07
Bicyclidine
unspecified for compile file. if the rc is loaded maybe it's defined to continue effecting. not sure.
17:28:13
emaczen
how can I check optimization settings in SBCL? #ccl informed me in CCL how to do it, which is how I found out.
17:40:46
phoe
schweers: it pays to read software manuals once in a while, including your language specification and implementation manual :)
17:41:05
phoe
take into account that these are global settings and can be modified by local declarations.
17:41:45
phoe
If you want to be EXTRA sure that your programs are compiled without tricks like (declare (optimize (speed 3) (debug 0) (safety 0))) you may want to sb-ext:restrict-compiler-policy
17:42:50
phoe
what is common in people's .sbclrc files is actually firmly setting the debug/safety policy to 3, so everything is compiled with debug 3 and safety 3.
17:43:56
phoe
_rumbler31: CL has no TCO so your stack may explode at the implementation's discretion
17:44:22
phoe
also, it is common for Lisp programmers in general to favor iterative programming style. Macros like LOOP are an example of that.
17:57:58
jasom
The only one that comes to mind are state-machines, where tail-calling the next state is IMO more readable than alternatives.
18:25:10
minion
Josh_2, memo from pjb: perhaps you want to count the ACTUAL number of operations needed to sort, and compare that for your different inputs. For sort algorithms, it's usually the number of swap that is counted. Or the number of accesses to the sequence. Or the number of comparison. Unless you have your own quicksort implementation, if you use cl:sort it will be easier to just count the number of comparisons.
18:26:12
Josh_2
pjb: Thanks for the memo but it's a bit late now :P I gave my presentation yesterday and the assessor said it was an excellent presentation and that I hit all the points
18:33:13
Josh_2
Would share my presentation but idk where to upload somewhere I don't have to sign up
18:54:50
beach
_rumbler31: Because Common Lisp does not guarantee tail-call optimization. There are cases where recursion is the best way, of course (like when you deal with a data structure that is naturally recursive). But for traversing linear data structures, iteration is preferable.
19:02:26
jmercouris
I can't think of a scenario in which recursion is more performant than iteration, are there any examples?
19:08:10
beach
jmercouris: What jackdaniel says. It has to do with what makes the code easy to understand and maintain.
19:08:37
beach
jmercouris: So if you traverse a tree, for example, recursion is often preferable to iteration.
19:09:14
shka
if your code needs to construct stack in order to iterate, you are better off with recursive function
19:11:19
jmercouris
I'm a software engineer too, don't confuse me being a noob with lisp that I am a noob in general, I understand the importance of developer time, I am just wondering if there is ever a scenario in which a recursive implementation is more performant than an iterative one
19:12:32
jmercouris
not necessarily time complexity, but on actual hardware, an example of a recursive solution being quicker
19:12:40
jackdaniel
if problem is better expressed iteratively, then you're better of using iteration. It's not always the case though
19:13:03
beach
I think that depends a lot on the implementation and on the architecture of the underlying computer.
19:13:06
jmercouris
state machines are a great use case for recursion, trees, as well, but will it every be quicker?
19:13:40
shka
jmercouris: if your stack is vector and it reallocates, you may hit sweet spot where performance degrades badly
19:14:31
jackdaniel
jmercouris: given perfect implementation, which maps nicely into thought, what is faster: (loop over states if match my-state (do-my-state)) or maybe rather (do-my-state) ?
19:17:21
jackdaniel
jmercouris: if you can do a tail call, you just call a function (and you are done), if you have a loop, you need to wait until function returns and decide what to do next (so the caller controls the execution)
19:18:56
scymtym
shka: known limitations, rather. it can be useful if you are aware of the limitations but it won't give you anything like scheme's call/cc or reset/shift
19:22:35
jackdaniel
scymtym: I can send you a pdf (it was removed from documentation when they were removed, but it builds fine when you go back in time in git)
19:24:32
scymtym
Shinmera: i think that one argues against call/cc specifically, not necessary against e.g. reset/shift (which closer to the style cl-cont supports)
20:27:35
jurov
Hi all, when I do (ql:quickload 'usocket) (usocket:socket-server #(127 0 0 1) 8910 nil nil) I get undefined function error.
20:28:31
jurov
NFI how to approach this? In dists/quicklisp/software/usocket-0.7.0.1/ the function does exist
20:30:39
jurov
(ql:where-is-system "usocket") has output ~/quicklisp/dists/quicklisp/software/usocket-0.7.0.1/ which is right, and which I've checked
20:35:01
Xach
jurov: i don't think usocket:socket-server is meant to be a function, is it? is it documented as such?
20:35:41
jurov
(do-external-symbols (s (find-package "USOCKET")) (print s)) does list USOCKET:SOCKET-SERVER
20:37:39
jurov
it is definitely something that can be called. and it worked fine on this machine few months ago.
20:38:03
_rumbler31
jurov: can you restart your lisp, ql usocket and then re-issue your test and paste full output?
20:40:42
Xach
jurov: i think it would be good to discuss on the list, because that seems like a strange oversight
20:46:36
jurov
paule32:but that has no influence on whether the function exists. and I remeber this working with the vector parameter
20:48:53
paule32
jurov: if you would like to set the vector value, try: (setf ip-address (vector 127 0 0 1))
20:55:43
Xach
jurov: (ql:quickload "usocket-server") will load the file that defines what you want to use.
20:56:22
jurov
Yep, I found it announced here: https://mailman.common-lisp.net/pipermail/usocket-devel/2016-October/000618.html
21:09:52
pjb
Zakkor: (defmacro defun (name lambda-list &body body) `(setf (symbol-function ',name) (lambda ,lambda-list ,@body))) ; basically.
21:10:07
Bicyclidine
(defmacro myquote (form) (list 'quote form)). now (myquote (7)) => (7), whereas (print (7)) would be an error
21:10:17
pjb
lambda is a macro that expands to (function (lambda …)) and function is a special operator, so special rules.