libera/#commonlisp - IRC Chatlog
Search
4:49:47
pjb
rdrg109: alteratively you can use copy-list. Notaby in functions that want to modify their parameter, but that can accept literal (immutable) values: (let ((items '(1 2 3))) (let ((items (copy-list items))) (push 4 (cdr (last items))) items)) #| --> (1 2 3 4) |#
4:51:09
pjb
rdrg109: or more wisely, write your functions so they don't try to mutate their parameters at all.
4:51:58
pjb
(let ((items '(1 2 3))) (nconc (butlast items) (cons 4 (last items)))) #| --> (1 2 4 3) |#
4:52:30
pjb
rdrg109: ^ note the use of nconc, which mutates the fresh list returned by butlast, so we don't copy it again.
4:53:25
pjb
So you can use mutation inside your functions as long as you are only mutating objects created by (or for) your function, and not the arguments.
7:51:34
rdrg109
pjb: Thanks for helping! I will need to devote some time to understand what you all mentioned.
7:52:25
rdrg109
Fortunately, Org Babel supports Slime code blocks, so having that + irc logs is helpful for taking notes
7:52:58
susam
Quick survey: What do you prefer for outputting HTML? Writing HTML using CL macros or writing HTML as plain HTML and combining them with Lisp? And why?
7:53:44
moon-child
susam: I generally write plain html. Was at one point working on a macro language that would let you write html but without quotation marks around plain text. Never finished that, though
7:55:37
susam
I have been torn between the two approaches. While writing HTML using CL macros can be convenient as a developer, I worry it would prevent someone else who does not know CL from editing the HTML independently. So far I have been leaning towards writing plain HTML.
8:10:28
lisp123
susam: I like CL-WHO for outputting HTML, but I'm not trying out BKNR.IMPEX - it outputs to XML well (automatically, once you create a DTD). I don't think it will do tables well, but for that I wrote a custom function very quickly
8:11:44
lisp123
In general, I'm trying to store objects now in classes, and then have a defgeneric / defmethod to define a "print-html" method for each object - thus creating HTML files is just printing the objects
8:14:38
lisp123
also check out HTML-TEMPLATE - it's a great solution to allow designers to work on HTML and then have lisp populate it.
8:42:26
splittist
I use djula as a templating solution. Not that anyone should take web lessons from me.
10:46:23
coat
I am trying to load a file from current directory but I get error that the file does not exist. issue only in slime. works fine in shell.
10:47:47
susam
coat: Check *default-pathname-defaults* . Perhaps it is pointing to some directory other than the one you think is the current directory?
10:50:02
coat
susam: thanks. it is pointing to a different directory. i thought it would be automatically set to the directory of my current .lisp file.
11:02:33
prxq
has anyone here used this?: https://marketplace.eclipse.org/category/free-tagging/common-lisp
12:30:17
lisp123
(slime-eval ...) works on basic forms, but I want to call functions stored in packages loaded in my cl image
12:41:17
lisp123
Looks like this works: (slime-eval '(cl:eval (cl:read-from-string "(package-name:exported-function \"test string\")")) "CL-USER")
12:42:03
lisp123
or just (slime-eval '(cl:eval (cl:read-from-string "(parser:parser \"The sentence x and y gives 3 and 4.\")")))
12:44:11
beach
_death: Does that mean that packages in the Common Lisp image must also exist in the Emacs Lisp image?
12:45:40
lisp123
I wonder if this answer needs updating - maybe I missed the point, but the above solution by _death is much easier https://stackoverflow.com/questions/49476788/how-to-evaluate-common-lisp-code-in-non-slime-buffers
13:19:25
_death
it also has this erroneous note in https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Symbols.html : "Common Lisp note: In Common Lisp, you can intern an existing symbol in an obarray. In Emacs Lisp, you cannot do this, because the argument to intern must be a string, not a symbol."
13:27:26
_death
I'm guessing they intended to compare against multiple conceptual obarrays for accessible symbols in a package
14:35:48
Josh_2
with format can I conditionally print elements from a list? basically can I reduce this:
14:36:05
Josh_2
(format nil "~{~A~^,~}" (loop :for ele :in '(1 3 4 5 6) :when (oddp ele) :collect ele)) into a single format call?
14:56:09
Josh_2
I'm trying to represent a tree of products, their subproducts and varying lengths of time and prices for each product
14:57:52
Josh_2
with product A having two sub products A.b and A.c with A.b and A.c having the same number of months but varying prices on each
15:09:11
shka
which will group all time version of the particular product in order, so you can binary search (or something) given the date
15:11:18
shka
next, you gonna want something to map the name of the product to the product, given the time domain
15:12:42
shka
alternative solution is to have another hash-table mapping product-name to subproducts
15:16:07
Josh_2
I think I may not have been clear enough, when I say months I mean say you can get the product for X months, and the X is adjustable with different prices say 1, 2, 3, 6, forever, etc with each seller being able to change the number of months and their prices
15:56:57
Josh_2
shka: got this so far, I think it will work https://plaster.tymoon.eu/view/2513#2513 each user will have their own product tree which they can modify as they wish, taking away and adding
15:57:45
Josh_2
Thank you for helping me, feels like you sprayed a bit of WD40 on my brain, lubricating it a bit
16:03:28
beach
You should avoid structs unless performance measures indicate that they would have a certain advantage to standard classes.
16:10:24
beach
Also, we keep inventing new techniques, like call-site optimization, that make it possible to inline slot accessors of standard objects in many cases. It would be silly to dumb down your programming style for reasons that may go away in the future.
16:13:19
beach
Same thing with generic functions. It would be silly to avoid generic functions in favor of ordinary functions if we can make generic dispatch as fast as ordinary function calls in many cases.
16:15:56
shka
keyword arguments are way to useful to not use even despite theoretical performance hit
16:17:42
shka
i've been programming in golang lately, lack of optional/named arguments lead to some intriguing oddities in the language
16:19:25
beach
Oh, just wait for the new version of the language. I presume it is like every other language in that the specification changes every year or so.