freenode/lisp - IRC Chatlog
Search
23:23:44
pjb
fiddlerwoaroof: (split-sequence:split-sequence #\space "a b c d" :count 2) #| --> ("a" "b") ; 4 |#
23:25:06
pjb
fiddlerwoaroof: (let ((string "a b c d") (n 3)) (multiple-value-bind (splitted next) (split-sequence:split-sequence #\space string :count (- n 1)) (append splitted (list (subseq string next))))) #| --> ("a" "b" "c d") |#
23:26:32
fiddlerwoaroof
pjb: I'm not denying that it's easy to write your own, I'm just saying that all these little things introduce friction into the sorts of string processing I frequently do
23:27:12
pjb
fiddlerwoaroof: I agree. That's why you build up your own library. Or you may design a consistent string processing library.
23:27:15
fiddlerwoaroof
Lately, I've found a #{} reader macro that mirrors Clojure's #() macro for defining functions is useful
23:28:14
TruePika
but I'm most worried because the form being complained about is almost part of SBCL
23:29:03
fiddlerwoaroof
Tcl would make sense because macros there are essentially string transformations
1:58:45
pillton
You'll probably have to be more specific. I've solved graph problems by solving a linear system.
2:00:55
didi
pillton: I currently implement graphs using adjacency-lists and a hashtable. The hashtable hold the vertices as keys and the values are the adjacency-lists. I am wondering about different implementations and if anyone investigated this problem space in lisp before.
2:12:53
didi
I incidentally came across the passage that I mentioned: https://jaxenter.com/disadvantages-of-purely-functional-programming-126776.html "With a garbage collected imperative language, the relationships between the vertices and edges of a graph can be expressed using weak hash tables. The garbage collector will then collect unreachable subgraphs for you."
2:23:04
Petit_Dejeuner
didi: "It took 50 years for normal people to dilute the smug weenies to the point where you can get a useful answer about functional programming on social media."
2:31:07
fiddlerwoaroof
I like it how he tells us that the Lisp community had wrong arguments about Lisp's goodness, but doesn't bother to share them
3:02:04
didi
pillton: I am thinking about it. I want to retain the original vertices names, so I am thinking of using a map--possibly a hashtable--for names and indices and an array for the graph proper.
4:53:58
jack_rabbit
Is there a way to inspect the SBCL "heap"? I'm curious about the kinds of objects that are alive.
5:57:31
Petit_Dejeuner
I was going to say "Yeah, but I heard back then you could only get smug lisp weenie answers out of functional programmers.", but I wasn't sure if I should start hamming it up in #lisp.
6:20:28
axion
Does anyone know why the version of the quicklisp bootstrapper offered on its website (https://beta.quicklisp.org/quicklisp.lisp) is different than https://github.com/quicklisp/quicklisp-bootstrap/blob/master/quicklisp.lisp ...it seems like the git repo is behind?
8:06:18
dim
beach: fyi I failed to have clim talk to XQuartz because of protocol mismatch, and didn't have time to inquire after that
8:16:25
stilda
Hello. Sorry for a newby question but can not find anything in internet. Is it acceptable thing to use a construct like (defmacro mym (args-list) (destructuring-bind (a b c) (eval args-list) ...))? The question is in using eval there. I have a defparameter that holds a list which I want to pass to the macro. Is there a better ways to do it?
8:18:48
beach
stilda: And (again, if args-list is a list of arguments), you should call it ARGUMENTS instead. The convention is to use the plural for a list (or possibly a vector) of things.
8:19:25
beach
phoe_: Maybe. More likely, it sounds like the use of a macro where a function should be used instead.
8:22:49
dim
then tou can (loop for foo in foo-list ...) and it's easier to read (I think) than (for foo in foos ...)
8:25:43
stilda
ok. more detailed description is following: I want to generate a code of function. I have (defun define-loka-code (name params) (destructuring-bind (p1 p2 p3) params `(defun ,name () ...<use p1 p2 p3 here>))). Then I have (defmacro define-loka (name params) (define-loka-code name (eval params))). Then I have (defparameter *loka-parameters* (list value1 value2 value3)). And I use it like (define-loka myfuncname *loka-parameters*)
8:27:01
beach
dim: There are several things I don't like about accepted conventions. But I think it is more important to follow those conventions so as to facilitate communication, than to use my preferred style. And this goes for code as well as for prose.
8:27:08
stilda
value1 value2 value 3 is big enough so I want to keep it in a separate list and not inline in macro call.
8:30:42
phoe_
because if it is (list value1 value2 value3), this evaluates to (value1 value2 value3), and EVAL will treat this as a function call.
8:32:22
stilda
phoe_: no I define *loka-parameters* as (defparameter *loka-parameters* (list value1 value2 value3))
8:36:34
stilda
phoe_: in scope of define-loka params will have value '*loka-parameters* so there is no problems with evaluating (value1 value2 value3)
8:41:03
phoe_
then (define-loka myfuncname *loka-parameters*) will expand to (define-loka-code myfuncname (v1 v2 v3)).
8:42:08
stilda
sorry mybe quoute should not be there. I meant that params will be symbol *loka-parameters*.
8:43:22
stilda
no, without eval or symbol-value I will get expansion (define-loka-code myfuncname *loka-parameters*). And then it complains that can not destructure a symbol.
8:46:31
stilda
then why does it not substitute *loka-parameters* value there? Am I right that eval will be called on my macro body?
8:56:33
stilda
ok, I think I was wrong saying that (define-loka-code myfuncname *loka-parameters*) is the expansion of the (define-loka myfuncname *loka-parameters*) form.
9:05:13
phoe_
(defmacro define-loka (name params) (destructuring-bind (p1 p2 p3) (symbol-value params) `(defun ,name () ,p1 ,p2 ,p3)))
9:05:44
phoe_
now (macroexpand-1 '(define-loka myfuncname *loka-parameters*)) ;=> (DEFUN MYFUNCNAME () VALUE1 VALUE2 VALUE3)
9:16:06
stilda
ok, so I have to move it to separate file and ensure it is compiled before the call to macro
9:16:57
phoe_
(eval-when (:compile-toplevel :load-toplevel :execute) (defvar *loka-parameters* '(1 2 3)))
9:29:47
stilda
phoe_: Does it not get evaluated anyway without that (eval-when ...) when I compile/load a file? And also how does this ensure the order of evaluation? At the end the order is what bothering me.
9:32:15
phoe_
but basically, it allows the Lisp image to have some variables bound during compilation time.
9:43:04
edgar-rft
stilda: Common Lisp first reads the entire file, then it tries to optimize the code, and only then it compiles the code. If you're referring in your code to something that was defined in the *same* file, then you need to wrap it in (eval-when (:compile-toplevel :load-toplevel :execute) <cour-code>), then Common Lisp evaluates <your-code> when it *reads* the file.
9:45:23
Bike
it reads one form at a time (which is why in-readtable utilities and such work). then it compiles it, or if there's a top-level eval-when, possibly evaluates it as well (or doesn't compile). and optimization is usually part of compilation.
9:46:32
Bike
stuff like defmacro is needed by the compiler, so it's evaluated. But defun and defvar aren't. So if a macroexpander function refers to a function or variable defined in the same file, there will be a problem, unless you use eval-when.
10:00:47
stilda
ok, I have to read something, to many questions. Is there a nice material to read about whole evaluation/compilation/macroexpansion process?
10:12:11
edgar-rft
stilda: the Common Lisp Specification has a whole Chapter about it, but don't expect that it will be easy to understand: <http://www.lispworks.com/documentation/lw51/CLHS/Body/03_.htm>
10:12:38
stilda
phoe_: thank you, I have to work at the moment. I will read something myself first and then ask questions if any.
10:13:32
specbot
Evaluation and Compilation: http://www.lispworks.com/reference/HyperSpec/Body/03_.htm
10:14:22
phoe_
and the page http://phoe.tymoon.eu/clus/doku.php?id=cl:special_operators:eval-when is somewhat usable right now
10:17:16
stilda
I have tried to generate code for multiplication of hypercomplex numbers. My macro takes a list of multiplication rules for imaginary units and output a code for multiplication function. So far it looks like lisp is a very good fit for this.
10:24:43
phoe_
Because, well, you have the whole language at your disposal during read-time, macroexpansion-time, compilation-time, load-time, execution-time.
10:25:14
phoe_
In most languages, only the third of these is guaranteed. In some of the more interactive languages, the fifth is also added.
10:27:55
phoe_
For read-time, there's the #. reader macro; for macroexpansion-time, there's macros; for compile-time, load-time, execution-time, there are the respective eval-when options.
10:28:28
phoe_
(If I understand it correctly. There might be some bugs in the two statements above. If I'm wrong somewhere, please correct me.)
10:44:26
dim
in some cases it's possible to deliver “results” without being asked what tooling you used to deliver, those are good opportunities to use CL