libera/commonlisp - IRC Chatlog
Search
8:05:18
jackdaniel
it is not part of the common lisp standard, but some implementations offer such functionality
10:15:52
rotateq
lisp123: iirc one can define a compiler-macro for a generic-function too if it makes sense
10:50:55
lisp123
beach: I finished reading http://metamodular.com/SICL/call-site-optimization.pdf , very enjoyable - thanks for writing
13:13:09
pl
namely, modify readtable to turn all line and block comments into forms, then shadow block forms to let those forms record their contents *somewhere* and make it accessible akin to documentation slot on a symbol
13:17:57
beach
Eclector? Sure, I use it from SBCL every day. That's how SICL code is read for bootstrapping.
14:05:08
yitzi
rotateq: It happens on my repos too sometimes. I have use the gitattributes file to override the linguist settings.
14:09:35
jackdaniel
should structure slots in defstruct should be matched with string= (not with eql) for sake of avoiding conflicts in /structure-name/-accessor and :accessor-initarg ? I think so
14:10:02
jackdaniel
and if yes - is it specified in the standard? if not - is it a good candidate for wscl?
14:11:25
pdietz
As I recall, the standard doesn't say exactly which package the various constructed symbols go into.
14:12:01
jackdaniel
so the third option would be interning /structure-name/-accessor in the symbol home-package?
14:12:10
rotateq
i learned this week by trying out that (string= 'foo :foo) => T, as (format nil "~a ~a" 'foo :foo) => "FOO FOO", if the keyword should really print as such the "~s" directive is useful
14:12:47
pdietz
It goes into the package that is the value of the *PACKAGE* variable at the time the defstruct form is expanded.
14:19:25
rotateq
i'm still not sure what a correct way is to transform a symbol from normal (quoted) to its keyword form, 'foo <- :foo. (read-from-string (concatenate 'string ":" "FOO")) maybe? cause with INTERN it returns it with pipes
14:22:12
jackdaniel
pipes are just the printer hinting you that symbols are case sensitive and your symbol name does not match the printer case (so probably it is not what you really wanted)
14:22:24
rotateq
no i tried additionally (intern (concatenate 'string ":" "FOO")) => |:FOO| and this surely can't be equal to :foo under EQ
14:22:59
pdietz
You should never call INTERN without specifying the package explicitly. It's a code smell to depend on *PACKAGE* there.
14:24:57
rotateq
ah now with (inspect :foo) it gets clearer why string= return T. the same name, but another special package
14:25:32
dbotton
is there some convention of expressing, even if just a matter of documentation, what the expected return value of a function will be?
14:26:26
pdietz
STRING= and similar functions take string designators as arguments, not strings. String designators can be symbols (which designate their symbol-name) and characters (which designate the string of length 1 containing that character).
14:28:41
rotateq
and thx pdietz, this with the string designators i learned some months ago from here too :)
14:28:59
pdietz
"The symbol values is not valid as a type specifier; and, specifically, it is not an abbreviation for (values)."
14:30:15
rotateq
dbotton: you could write #+(or)(declaim (ftype (function * type-of-return-value) the-function-symbol)) or so ^^
14:44:44
dbotton
THE looks like it may work for my intent (just need simple way to document return values), I do some experiments. Thank you
14:52:23
jackdaniel
sbcl won't trust your the on default optimization settings, you need sb-ext:truly-the for that ;)
14:52:43
jackdaniel
and if your declaration happens to be incorrect you may have interesting results at runtime
15:08:28
rotateq
even just how many additional sb-* packages brings SBCL with it still overwhelmes me
15:16:34
pdietz
I found a real use for the DECLARATION declaration. https://github.com/pfdietz/disable-inline
15:18:34
jackdaniel
is this really enough for cover? the implementation may inline without any declarations
15:26:15
pdietz
COVER works even w. inlining, since it alters the source s-expr during macroexpansion.
15:57:34
jackdaniel
more seriously though: https://european-lisp-symposium.org/static/2020/heisig-slides.pdf
18:14:56
lisp123
When do lists outshine arrays? Is it in creating new lists by using CONS or something similar? Is there any other area where they are better
18:21:54
Bike
there's also structural sharing, i guess, but circular lists aren't super commonly used
18:26:12
lisp123
I am thinking maybe I should just write an "array-list" "array-car" "array-cdr" etc. functions for use where I am not creating my own lists on the fly but rather just accessing them
18:28:53
lisp123
Yeah, I need to think about how its done and figure out how this row-major-aref works
18:31:07
rotateq
lisp123: i see lists way more flexible and that you can implement most other data structures potentially in an elegant way
18:33:38
lisp123
Is there like a number of elements, where lists are quite efficient vs. arrays? Say 5 elements
18:34:31
_death
(defun vcons (x y) (vector x y)) (defun vcar (vcons) (aref vcons 0)) (defun vcdr (vcons) (aref vcons 1)) ;; todo: add support for vnil
18:34:48
rotateq
or next time when someone praises turing machines too much, ask about how to have it recursive :D
18:36:00
Bike
getting the head element will pretty much be one memory read either way, and for anything past that the list has to do more reads
18:36:35
Bike
did a quick test and getting the third element of a list is (very slightly) slower on sbcl already
18:37:42
lisp123
Bike: Interesting, that's very early in the cycle that vectors are more efficient. I was also thinking in terms of space storage, but is it fair to say that generally read access is the more important consideration?
18:38:05
Bike
lisp123: lists are also going to do worse in space storage, since you have N conses and each cons has two fields
18:38:11
rotateq
_death: the vcons i would expect working a bit different, that eg 1 consed to #(2 3) produces #(1 2 3)
18:39:08
rotateq
okay the thing with displacing arrays and how and when i didn't understand till now
18:41:21
_death
rotateq: the point is that it's not lists, it's conses.. like Bike said, the point of "lists" (built from conses and nil) is structure sharing and the related fact that it's a recursive structure
18:42:12
jackdaniel
rotateq: I've written about conformal displacement on my blog some time ago - that would be quite convenient
18:43:05
jackdaniel
lists are convenient for representing environments, because front elements naturally shadow things down the line
18:43:30
_death
the problem with using a displaced array is that it conses ;).. the problem with vcons is that it's inefficient, a cons is an efficient two-element array