freenode/#lisp - IRC Chatlog
Search
17:17:05
phoe
and because small integers and characters are allowed to be stored inside pointers but also may not be stored there, it means that EQ may not work well on those
17:18:13
galex-713
but is there a way to declare something so that you declare a member of a struct as, say, a cons, so that eq won’t work anymore on it, though eql would, but it would only compare its car and cdr, not going deeper (contrarily to equal)
17:21:20
phoe
there's a concept of places in Common Lisp that works sorta similarly to what you describe
17:22:18
galex-713
initially I thought there was a trinary separation between variable, place and value, and that each involved a pointer
17:22:28
phoe
but no, I don't think that you can tell Lisp to do things like that without breaking object identity in some way; for simple tagged structures like conses it might work, but for more complex objects that require having headers in memory that's going to break
17:22:54
galex-713
rpg: yes but I guess it won’t be inlined, especially as I don’t see a way of indicating the “fixed size” of a list, and it looks a dumb thing to do
17:24:44
phoe
I mean, you could cheat by explicitly allocating foreign memory, but that's only going to give you foreign types + overhead for converting between Lisp and foreign worlds
17:28:01
phoe
it's an abstract thing, and sometimes a lexical thing, and a second-class citizen in CL
17:29:09
phoe
(that's a basic Lisp question and #clschool is designed exactly for that sorta questions)
17:29:37
galex-713
I’m not interested in cl because I got how it is defined so how it can work, or not work
17:29:53
phoe
other examples of places include CARs and CDRs of conses, AREFs of arrays, ELTs of sequences, GETHASHes of hash tables with given keys, SYMBOL-FUNCTIONs of functions, etc..
17:30:54
galex-713
no your vision of it is perfectly correct so I don’t understand why you made a connection I would have made before and wouldn’t anymore now I got how it work
17:32:33
galex-713
sorry, indeed, you are right, I’m too quick to type return while I think, instead of afterthought, thank you for the notice
17:33:41
galex-713
okay my idea is definitely complex to implement, but doable, and not definable according current standards
17:39:51
galex-713
are there or were there cl implementations that optimized so much so as to stop storing the size of arrays?
17:40:26
galex-713
for instance if som eprogram never asks for it, and because it keeps it in some data elsewhere and doesn’t need one per array
17:40:29
phoe
that would have to be nonstandard because ARRAY-DIMENSIONS must return a meaningful value
17:40:58
Bike
well, it would be fine if array-dimensions etc aren't called. however it would be hard to impossible to maintain this across function boundaries
17:41:46
galex-713
unless the function is really unsafe, but that particular unsafety ought to be declared as such and no such standard declaration exist
17:42:20
Bike
i mean, for some cases maybe, like if you have a constant array and access it only in one function
17:43:25
galex-713
I thought like imagine I have a datatype which is a list of arrays whose length change in a predictible manner
17:44:01
galex-713
for instance (a b c d) where a is #(nil), b is #(nil nil), c is #(nil nil nil), d is #(nil nil nil nil), etc. if you grow the list
17:44:38
galex-713
since you can predict it, in some portion of program that access a such object, you would never call array-dimensions, nor length, etc.
17:45:07
galex-713
Bike: indeed it is, but it is one of the possibilities that makes C lower level than lisp in the sense that it can do some things that lisp couldn’t
17:46:16
phoe
link them to https://pvk.ca/Blog/2014/03/15/sbcl-the-ultimate-assembly-code-breadboard/
17:46:30
Bike
i mean, you're right, lisp does not let you specify memory layouts even to the limited extent C does.
17:47:28
phoe
when it comes to allocating memory then you can go full FFI way and allocate and access it yourself
17:49:21
galex-713
Bike: I know someone else who defined a language that allows to *specify* that kind of low-level memory nitpicking in a turing complete way, his language/software is called Poke
19:31:37
aeth
galex-713: I mention a few of the differences between Common Lisp and Scheme here: https://gitlab.com/mbabich/airship-scheme/-/blob/master/CONTRIBUTING.md
19:33:17
aeth
I leave out some of them (like Common Lisp macros preferring TAGBODY and Scheme macros prefering tail recursion... also Schemers prefering hygienic macros... well, maybe I should add something for that) that are irrelevant for the project of implementing Scheme in Common Lisp.
19:34:37
aeth
I put it all in CONTRIBUTING.md because it's quite possibly the only project where knowing the differences between Scheme and Common Lisp is relevant and almost a prerequisite for contributing. :-)
19:46:47
pve
Hi, I wonder if someone could shed some light on how conses are (generally) represented in memory. I'm looking at the output from (room) on SBCL, and dividing the number of bytes (used by conses) with the number of cons objects gives me 16 bytes.
19:47:51
pve
so does that mean a cons in this case is simply 8 bytes for the car and 8 bytes for the cdr?
19:52:05
White_Flame
if you disassemble CONSP checks, it hcecks to see that the pointer's low 4 bits has the value 7
19:52:46
White_Flame
I believe the allocation granularity is 16 bytes (two 64-bit words), so the bottom 4 bits can be used for tagging
19:53:28
White_Flame
so if you know it's a cons pointer, the car is at [ptr-7] and cdr is at [ptr+1], since the pointer already contains an offset of 7 for the tag
19:56:35
pve
White_Flame: thank you, so would a fixnum sit directly in the car? (i'm not super familiar with this stuff)
19:57:05
White_Flame
yes, fixnums have a low 4 bits of xxx0, and all other types use xxx1. So the fixnums can use 63 bits of the 64-bit word
19:57:32
White_Flame
and are shifted left 1 bit, so plain adds/subtracts/etc can work directly without masking off a tag
19:59:17
White_Flame
fixnums, characters, and single-floats all reside literally in a word without indirecting
19:59:44
White_Flame
double-floats have to be boxed, as they require the full 64 bits of a word, and obviously multi-word elements are always pointed to as well
20:01:24
pve
ok great, this brings me to my second question: when I do (defclass kons (car cdr)) and allocate a long chain of them with fixnums (< 100000) in the car, i get something very close to 48 bytes per kons instance
20:01:57
White_Flame
well, the allocation reporting is probably rounding up to whatever block size it uses
20:02:29
White_Flame
but for an object instance, that'd be 6 words per, which probably isn't that bad?
20:02:50
White_Flame
obviously 2 words for the data, but 4 words of overhead does smell a little high. I think structs only have 1 word of overhead
20:03:29
Bike
a standard object is probably going to indirect its slots in a vector, plus there's a link back to the class somehow, and possibly more header
20:04:25
White_Flame
pve: I do default to structs, and only move to defclass if I really need it, to keep things lightweight
20:05:30
Bike
so four words of overhead could be the object header, pointer to the class, pointer to the slots vector, vector header
20:32:41
aeth
galex-713: If you *really* want to hate the modern web and Gitlab in particular, try using Gitlab's snippits (pastebin-esque) system. I used it for > 1.5 years after lisp paste shut down, but it's now entirely unusable for about 4 months because the dumb text input is gone
20:33:09
aeth
Now, it has a "smart" editor that reindents anything that you paste into it, and has no knowledge of Lisp, thus ruining any code you paste into it.
20:36:26
aeth
I think I'll just make a git repository next time I need pastebin-like functionality, and maybe I'd link to the /raw/ which doesn't appear to require JS
22:19:57
dim
if you're after a self-hosted web git thingy I've been told nice things about https://gitea.io/en-us/
22:42:00
z3t0
how is lisp land these days! I've been out of touch for a few weeks playing with freebsd
22:45:06
dra
z3t0: I doubt you have missed much. A new book was announced: https://www.apress.com/gp/book/9781484261330
23:32:04
sm2n
aeth, sourcehut is quite nice because it avoids modern web practices like the plague but this is offtopic
0:15:40
_death
I took a first step towards that not long ago.. porting the pertinent bits from gogs and creating a hunchentoot dispatcher to support git-clone
0:17:01
_death
but gogs seems to work ok with javascript off, so I'm not pressed to take further steps
3:56:56
contrapunctus
(Oh god. I can't believe it took me this long to realize the Strandh/beach pun 🤦)
4:16:03
contrapunctus
beach: been designing a markup language - https://github.com/contrapunctus-1/TheatreScript ...thinking of making a fork of 3bmd to parse it. (Or maybe it can be extended instead of forking...)