freenode/#lisp - IRC Chatlog
Search
21:48:06
elderK
Also thought of simply: world-state. But that makes you think of the state of the entire world, not just one cell in it.
21:48:42
Xach
I like to use un-prefixed names. If multiple objects can reasonably work with STATE, that's good. If the argument lists aren't compatible, I try to find a different name, or use different packages.
21:49:07
elderK
Well, these all operate on world alone. They are not meant to be generic in any way.
21:50:16
elderK
I understand that a method specialized on some type, is used for that type when you invoke the generic with an argument of that type?
21:50:19
Xach
elderK: in c++ and many other languages you prevent name clashes by using classes as the way to separate names.
21:50:49
elderK
Also to group them, though. You know for instance, that these methods are to be used only on "world", since they are methods.
21:53:26
Xach
I'd expect something named STATE to take a single argument and return some state object. The extra stuff makes me think a more specific name would help.
21:55:15
sjl_
some day I'm just going to (defmacro href (hash-table key &optional value) `(gethash ,key ,hash-table ,value)) and be done with it.
21:58:36
elderK
I would ask for comments about a certain function, but, I think I'll just write it all up, finish it, and ask for a critique on the entire thing :)
21:58:37
Xach
i had a thing i made where i had a bunch of functions that acted on an object and it turned out for most of it i really only needed the name of the thing to do most of the work, so i was glad i didn't make specialized methods or a lot of type checks. i could treat the string name as the object and save some work.
21:59:58
elderK
Even if you used check-type a ton, couldn't you use like, deftype to kind of decouple the real type from the name you use for that type? Kind of like using or typedef in C++?
22:00:02
asarch
One stupid question: Can you connect Slime in one PC to a SBCL session in another different host?
22:03:32
Xach
asarch: when i did it, i used an ssh tunnel. there is some fiddling with filename translation required to get things to work properly. (i think the specifics are in the manual but i haven't checked recently)
22:03:58
Xach
asarch: i found it to be a bit painful when i tried it several years ago so i usually edit on remote slimes with remote emacses.
22:11:59
oni-on-ion
when sbcl or impl runs swank and server, slime can connect considering version compat
22:12:30
josh5tone
asarch: do these details help? https://common-lisp.net/project/slime/doc/html/Connecting-to-a-remote-lisp.html
22:13:23
oni-on-ion
its always worked for me, not much special things. ssh like xach says for if you have a proper secure network setup. =)
22:13:40
oni-on-ion
(which one would already know how to set up, else would have a network admin whom to ask.)
22:21:54
asarch
Another stupid question: Is SBCL a distributed environment (this SBCL can use that SBCL capabilities)?
22:25:00
elderK
I thought of map, but it's not producing any output. Just, calling a function on each adjacent cell.
22:28:12
sjl_
as long as you don't do my personal pet peeve of calling a boolean parameter somethingp I'm happy
22:33:40
void_pointer
The first if you mean equalp equality, the second if you mean equal equality, and = if you mean numeric equality.
22:34:45
void_pointer
Especially the convention for ? for predicates and ! for anything that mutates its arguments
22:35:14
aeth
void_pointer: There's one problem with the naming conventions in Scheme. Because they improved the names (e.g. map instead of mapcar) that means that good names aren't available (i.e. a sequence-generic map cannot be called map in Scheme)
22:36:24
aeth
Additionally... CL requires you to help the compiler out if you want efficient array/sequence code. Scheme wants to keep dynamic typing at maximum efficiency which means no generic aref... which also means instead of one type declaration you have potentially dozens of de-facto declarations right there in the foo-ref name.
22:37:31
aeth
In Scheme you could have stuff like ub8-ref instead of just declaring the array once as (unsigned-byte 8)
22:40:50
aeth
(Technically you do (simple-array (unsigned-byte 8) (*)) in CL... But inconvenient syntax like that can always be fixed with macros.)
22:41:32
void_pointer
Reminds me, I've been trying to get half decent array math performance. If I have two arrays that are for sure the same size with the same type which is known to be (unsigned-byte 32) and then doing an element-wise multplication in place. I can't seem to get more than 70 M/s out of SBCL on my computer even with declarations so far.
22:42:04
aeth
elderK: CL is a safe language so it probably will try to find a reasonable initial-element (NIL or some numeric type's 0 or #\Nul) even if you don't provide one, although that's implementation specific
22:42:25
aeth
It might notice that you set every element right afterward and optimize that away, but I don't think even SBCL is that sophisticated
22:42:52
void_pointer
the make-array function has an :initial-element keyword to pass an initial element. It defaults to nil
22:43:35
jcowan
and there is universal polymorphism, like cons, and there is "universal polymorphism by cases", like write/display.
22:44:13
aeth
void_pointer: But when it is nil that does not mean the initial element is nil, at least in SBCL. It will use the numeric type's 0 or the character #\Nul in SBCL e.g. (make-array 42 :element-type 'character)
22:44:14
void_pointer
aeth: if it was that smart, it would take a lot less time to do the multiplciations. I am doing it several times in a row and it could just do it once and be done, but the time scales with the number of times it is done
22:44:56
void_pointer
aeth: oh, that is convenient. I've always been scared to not give some :initial-element to avoid a crash
22:45:33
jcowan
I have only ever seen trash in numeric arrays and only in some implementations; the rest are all about 0.
22:45:43
void_pointer
aeth: which is funny given that it would just drop into the debugger if there was a problem rather than crash (I still think a lot like a Python programmer)
22:46:36
aeth
jcowan: specifcially, the numeric type's 0 if numeric *or* #\Nul if character *or* NIL if generic
22:47:51
aeth
|3b|: Or define this behavior explicitly in a macro even though every reasonable implementation already has it
22:48:56
aeth
(In case I was unclear, I was explaining why NUL might be undesirable but why CL doesn't care)
22:50:03
jcowan
R7RS allows #\nul to be forbidden in strings, but I don't know any implementation that actually does it. Some store a #\nul invisibly after the actual characters to prevent runaway behavior if you pass the string to C, but if there's a #\nul in it, C will of course act on that.
22:50:08
void_pointer
if one is doing floats, nan is a common "null" that is used, in as much as there is only one nan (there are many many nan, most are signaling nans)
22:50:24
aeth
void_pointer: Make sure to wrap your unsigned integer arithmetic in MOD with a power of 2 if you want C-style efficiency and wrapping semantics, at least if the compiler is smart enough.
22:51:46
aeth
void_pointer: CL doesn't have a NaN. Well, officially it doesn't. Unofficially there's this whole mess: https://github.com/Shinmera/float-features/blob/master/float-features.lisp
22:52:42
aeth
I don't know why float-features isn't in QL yet. The alternatives to that library generally are a fast path for SBCL and a slow path for everyone else.
22:53:50
void_pointer
aeth: just tried wrapping it in mod and it made it slower. Seems SBCL figured out the fast path on its own
22:54:41
aeth
void_pointer: for me this is better in SBCL than the non-mod version based on disassemble: (defun foo (x y) (declare ((unsigned-byte 32) x y)) (mod (* x y) (expt 2 32)))
22:56:38
void_pointer
Got one thing switched up, I was doing (unsigned-byte 8) arithmetic, not (unsigned-byte 32)
22:56:49
void_pointer
(let ((a (make-array '(800 600 3) :element-type '(unsigned-byte 8) :initial-element 0))
22:56:49
void_pointer
(b (make-array '(800 600 3) :element-type '(unsigned-byte 8) :initial-element 0)))
22:58:21
jcowan
There is or was one Scheme that takes advantage of the permission to use random-looking (but consistent) integer codes for characters, just to screw you up if you assume it. This permission has been withdrawn in later standards. Now you have to use Unicode codepoints, although you can (theoretically) have characters with bucky bits set provided the codes exceed #x200000.
23:01:13
no-defun-allowed
https://gitlab.com/Theemacsshibe/cl-vep/blob/master/cpu/masks.lisp#L43 is pretty fast image stuff
23:01:18
aeth
void_pointer: Technically speaking you don't need a type declaration if the type inference can infer it, like with the LET, unless you're doing something that uses CLtL2 (e.g. introspect-environment) to do fancy type-declaration-based macros (which cannot access the type inference).
23:02:12
aeth
void_pointer: If you're doing that at the top level of the REPL, you might get better numbers if you first define it as a function.
23:02:13
no-defun-allowed
(declare (optimize (speed 3))) will find anything and everything to complain about
23:02:30
aeth
void_pointer: If you define it as a function, of course, you'd need the type declarations
23:03:12
aeth
void_pointer: (safety 0) is unnecessary unless you're bounds checking. Even if you are removing bounds checking, you should declare the (safety 0) at the most local place possible because you lose the useful static type checking in SBCL if you have (safety 0)
23:04:25
aeth
(You also lose the runtime type checking, but if you're working with specialized arrays and :type slots in structs, then that really doesn't matter at all. You won't really gain much with (safety 0) there. (safety 0) should only be used to remove bounds checks, and some people would even say that goes too far.)
23:05:16
void_pointer
I avoid (safety 0) like the plague, but was just using it here to see what the max limits I could get out of it
23:05:44
void_pointer
turning it to a function made it slightly faster (a couple percent) and didn't raise any of SBCL's optimization hints
23:06:08
aeth
If you're doing (safety 0) you might not get all of the messages you could otherwise get
23:06:27
sjl_
How to use (safety 0) properly: 1. Write with (safety 1) and benchmark. 2. Switch to (safety 0) and benchmark. 3. Compare benchmarks and say "huh, that's neat". 4. Change back to (safety 1) because you're a responsible human being.
23:07:33
void_pointer
still didn't get any compiler messages, but (safety 1) decreased performance some
23:07:51
Xach
elderK: you can create an array without specifying the initial element but the consequences of reading from it are undefined.
23:08:07
aeth
void_pointer: If you're programming to remove bounds and type checks, (safety 0) normally won't buy you much
23:08:10
Xach
elderK: some implementations use 0 as the initial element, some use nil, some use garbage
23:08:59
aeth
sjl_, void_pointer: The correct way to get (near) maximum performance in SBCL is to find a way to remove all bounds and type checks by providing enough information to the compiler in a way that SBCL likes it imo.
23:09:30
jcowan
The trouble is that you don't know which declarations are optimizing and which are pessimizing a priori
23:09:47
no-defun-allowed
1. use (safety 0) cause you are bored 2. (defun f (x) (declare (optimize (safety 0) (speed 3)) (fixnum x)) (the fixnum (1+ x)))
23:11:09
aeth
jcowan: What I like about SBCL is a combination of the optimization notes at (speed 3), the commented DISASSEMBLE that comments the parts you might want to optimize away, and the extensive benchmarking tools available.
23:11:19
jcowan
ACTION thinks type declarations should be explicitly marked "assertion" or "assumption"
23:12:06
void_pointer
looked at the disassembly and it is not doing bounds checks. Only comparison is the end of loop condition
23:12:46
void_pointer
however, the assembly code is quite ugly. I am not very familiar with amd64 assembly, just 16-bit x86 and it has been well over a decade
23:13:21
jcowan
ACTION decided when he saw the VAX assembler with its 256 opcodes that PDP-11 assembler was going to be the last one he ever learned
23:14:12
void_pointer
One curious thing which may explain the performance issue. SBCL seems to be storing the (unsigned-byte 8) as two bytes each with one wasted byte based on the termination index
23:14:20
jcowan
At one time the Chicken compiler would *always* inline any function declared "inline".
23:14:45
no-defun-allowed
what that does in the words of joe strummer, "gencgc copies garbage! ooh bub-bub-bye-bye!"
23:15:18
aeth
The only legitimate use of SBCL's (safety 0) imo is a locally to remove a bounds check that you know cannot be violated in a loop but that the compiler does not know. I'm not sure that that ever comes up.
23:15:52
aeth
Unfortunately, even that's not ideal beacuse you can't just say remove-bounds-checks, you'd also remove other things you might want. So even when you have a legitimate case, just accept the slight performance hit
23:15:59
jcowan
Well, sometimes you need code to run really reallly fast 90% of the time and crash the other 10%.
23:16:48
jcowan
"If it doesn't have to be right, I can make it as fast as you want." Rejoinder: "<large program> has 1000 bugs. Which would you rather, that I removed all the bugs or made it run 1000 times as fast?"
23:17:44
aeth
The only time you'd need it off is if you're doing something like calculating pi and you might save a few days/weeks
23:17:54
jcowan
I think max optimization gets you a factor of 2, which however might be the difference between brakes that work and those that do not.
23:19:18
aeth
jcowan: Well, SBCL is roughly 3.5x slower than C in certain workloads, so maximum optimization and maximum unsafety would get a roughly 3.5x speed increase in certain cases assuming SBCL can be patched to do all the optimizations GCC/LLVM can do.
23:20:15
|3b|
aeth: only place i've seen it was in complicated loops over multiple arrays at once, where it could figure out some but not all
23:21:35
void_pointer
goint up to (unsigned-byte 16) didn't change the termination condition while it reduced the instructions to 7 before the multiply and 6 afterwards
23:22:28
void_pointer
when you have a problem where it will take a week on a 4096 node cluster, factors of 2 mean a lot of time
23:23:13
void_pointer
|3b|: are you referrring to the instruction count or the size of the array elements in bytes?
23:23:47
|3b|
ACTION is pretty sure sbcl stores unsigned-byte 8 packed, or i'd have had a lot more problems with textures in the past
23:25:12
jcowan
someone said that in SBCL array-total-size-limit is always a fixnum, but I think the spec requires that.
23:25:43
void_pointer
well, it does look like that is the case |3b| with the lowtags. Changing the size up to uint16, uint32, and uint64 didn't change the loop end condition
23:25:57
|3b|
there is a bit of unclear things in the spec regarding largest allowed array size though
23:26:05
void_pointer
interestingly, the time the multiplications took reduced with each step up in size
23:26:35
|3b|
fixnum array indices aren't a good thing when you want large bitvectors on 32bit clisp :(
23:28:16
void_pointer
|3b|: as for the GPU question, if the problem fits a GPU, then yes. the random example I was pulling out is one that has one part that is amenable to GPUs and another part that isn't. If both are done on the one cluster, it is over a week for one round. If the first part is done on a GPU cluster, we shave a few days and make less unhappy other users on the same cluster
23:29:31
void_pointer
|3b|: I am trying to render something and there is one step in the pipeline that depending on what I have to work with to render, could have to be done in software. It is luckily a giant pointwise multiply
23:30:05
|3b|
multiply corresponding elements of 2 arrays is definitely GPU side, though if it is mixed in with other part i could see moving between clusters being way too much overhead :/
23:31:06
void_pointer
the GPU part is a first step before some human intervention has to be done for a few hours or so before it can be ready for the second part
23:31:24
void_pointer
the second part is the one that one might want to redo. First one once done, there is often little reason to redo
23:34:57
void_pointer
I'm basically doing an axpy operation, but rather than being purely floating point (and then being able to use BLAS), it has integers. In principle, I could just convert the Fortran axpy function in refblas and wrap it
23:39:58
|3b|
also, just out of curiosity have you tried (map-into a #'* a b) rather than manual loop?
23:43:13
void_pointer
but, in this case, scalar and y are arrays. I'm pretty sure there is a BLAS level 2 or 3 function for this but I don't remember its name
23:44:01
|3b|
ACTION doesn't know blas, but a vector scalar sounds like an interesting thing to have :p
23:45:34
void_pointer
BLAS is a lot of fun, especially trying to write one's own and the struggles that go with getting it right
23:46:42
|3b|
yeah, it's right on the edge of stuff i do, but i usually just write it myself on GPU for that sort of thing rather than trying to figure out CL<->fortran stuff
23:49:24
|3b|
ACTION used my own opencl bindings last time i used opencl, but most of my hardware is NV and their opencl support isn't good enough for me to bother with anymore :(
23:49:49
|3b|
(and i'm mostly doing graphics stuff so gl/vulkan compute shaders are more appropriate anyway)
23:50:02
aeth
I'm probably going to write my own BLAS at some point. Technically, you don't want one BLAS. That's not the point of BLAS.
23:50:42
aeth
You'd want e.g. SBCL/x86-64, SBCL/x86, SBCL/arm64, etc., each one probably heavily using define-vop (or the equivalent if a different implementation)
23:52:41
void_pointer
for what I am doing, gl is my eventual goal (it is graphics), but I can more easily reason with and debug array operations on the CPU or using simple 2D drawing commands (which use gl in the background). Also means I have a fallback.
23:52:45
no-defun-allowed
i'll probably move to arch since the wiki and resources are less headache-inducing than ubuntu for the new stuff
23:53:46
|3b|
void_pointer: well, combining 2 textures even with simple 2d stuff is pretty trivial in GL
23:55:07
aeth
Porting the concept of BLAS to CL is a bit tricky because you have two representations for 2D stuff (i.e. matrices): 2D arrays and 1D arrays.
23:55:42
aeth
And you want both, e.g. if those matrices are going to be fed into OpenGL they have to be 1D
23:56:39
void_pointer
|3b|: good to know. Part of it is that I don't know GL yet. Tried for a while and struggled. Decided I would come back to it once I had my rendering pipeline figured out and proofed in SDL or on arrays on the CPU
23:57:59
void_pointer
aeth: yeah, it would be messy. Did it in Fortran a decade ago and was pretty easy, but that is no surprise because BLAS was designed around Fortran and Fortran was designed just for these sorts of things
23:59:02
aeth
void_pointer: Unfortunately, F2CL generates some pretty trash SBCL based on disassembling what it generates, so either you write your own translator or do it manually.
23:59:59
void_pointer
aeth: and that is not even getting into some of the dark corners of Fortran I take it
0:00:40
void_pointer
aeth: like arithmetic if statements, the not technically standard but defacto standardized cray pointers, etc.
0:01:16
aeth
Yeah, I suspect you'd want a hand translation because efficient SBCL and efficient FORTRAN are two different things even though SBCL can get pretty efficient.
0:02:40
aeth
(I'd expect at most a 4x performance loss in properly-written SBCL, and perhaps even a performance gain once define-vop is mixed in for the implementation-and-architecture-specific parts.)
0:06:56
void_pointer
Would be hard to imagine getting withen even x2 of refblas. Definitely not within that much of ATLAS or one of the processor vender versions of BLAS (which are extremely tuned to the processor)
0:07:40
aeth
void_pointer: https://www.pvk.ca/Blog/2014/03/15/sbcl-the-ultimate-assembly-code-breadboard/
0:08:38
aeth
void_pointer: If you wanted to do a serious CL BLAS, you'd use define-vop on SBCL and the available equivalent in other implementations if there are any, falling back to the CL as a default for unsupported implementation/architecture combinations or if the user requests the portable CL (in *FEATURES* or something?) which would be safer but slower
0:10:55
aeth
(I'm guessing you'd also want GPU implementations as well, depending on your workload.)
0:48:38
Xach
many years ago on another channel i maintained an xearth markerfile for all the regulars so you could see what timezone they might mean when they said such things
1:23:55
aeth
To put that in perspective, most people would have been using single-core 32-bit processors and 32-bit Lisps. I'm guessing CLISP was probably the most popular back then based on the material from the period that survived.
1:26:21
aeth
I was using a Windows 2000 system (not mine) as late as 2008. Obviously not my choice in that case.
1:26:39
housel
I have some channel logs from 2003-2004; SBCL, CMUCL, OpenMCL, GCL, ECL, CLISP all get mentions
1:29:25
aeth
The other two log sites seem to have issues from time to time. Tymoon doesn't seem to have any gaps
1:32:13
lyf[kde]
I was trying to borrow The Seasoned Schemer from my university library. The book has bee overdue since 10/27. :(
2:17:33
pfdietz
I don't think gcl can be considered to have survived as a living project. ACL2 was the big supporter, and it's moved to other lisps.
2:30:07
fiddlerwoaroof
Yeah, adding clos is on their list of planned changes here: http://git.savannah.gnu.org/cgit/gcl.git/tree/gcl/readme
2:31:27
fiddlerwoaroof
That kinda makes it interesting, if one were interested in implementing CLOS from scratch
2:52:06
LdBeth
Both CCL and LispWorks use their own implementation, because they are commercial products
2:56:47
PuercoPop
I know this is only tangentially on-topic, but does someone know how to configure the shift keys to work like the space cadet ones, when they are pressed by they own they insert a shift
3:00:41
PuercoPop
fiddlerwoaroof: yeah, paren. I look into xcape. Was hoping that I could setxkmap my way to it
3:01:27
jcowan
Windows definitely supports sticky-shift as part of the disability accommodations, and I bet the Mac does too.
3:01:31
fiddlerwoaroof
However, I set this up everywhere I work (ever since reading sjl's article) and it's amazing
3:01:57
fiddlerwoaroof
jcowan: know this is "push shift by itself and get a paren, push it with another key and get a capital/symbol"
3:05:37
oni-on-ion
hmm i like the idea. already using snoopy-mode so the whole number row is preshifted ; xcape can do this ?
3:08:17
oni-on-ion
i had the idea to move backspace to top left (tilde) and space to top right (backspace.) which i then understand is similar to commodore 64
3:10:48
fiddlerwoaroof
I have also recently switched to having capslock be C-M-s, so C-M-s-g is just Caps Lock-g, which is really nice too
3:13:48
fiddlerwoaroof
I use C-M-s- for global keybindings such as "capture the current safari tab url in org-mode"
3:17:49
oni-on-ion
oh, oops. [meanwhile i've been using s- for everything becaues its my windows key and exwm has it locked down.]
3:59:06
ski
(<https://upload.wikimedia.org/wikipedia/commons/e/e9/Commodore-64-Computer-FL.jpg>. cursor arrows are on bottom right. shift needed to go up and left. C128 added four separate cursor keys)
4:36:49
White_Flame
petscii has an up-arrow for exponentation in BASIC, and a left-arrow for ... nothing in particular?
4:37:24
White_Flame
a lot of DOS wedges used it, but other than that it's basically like any other graphics glyph. Not sure why it got its own key
4:40:32
no-defun-allowed
(in gnu smalltalk, `x _ 2` assigns 2 to x, so i assume that the codepoint was also used by <-)
4:51:17
ski
hm, Turbo Assembler uses left-arrow as an escape key (cf. `^A' in GNU Screen). perhaps it was intended that applications could use it like that ?
5:42:44
oni-on-ion
for a big standard theres a lot of libs. uiop, alexandria, trivia, optima, series, incf-cl; does anyone know the status of the most recent/complete CL community spec? i forget what it was called.
5:47:04
beach
I think the work on the UltraSpec is stalled. You can ask phoe who is the one who starte it.
6:27:00
jackdaniel
for instance the one written by Didier Verna about format interpretation differences (and proposal of how to unify them)
6:50:54
elderK
I really wanna play more with Lisp atm but RSI is acting up :| WANNA HACK. But shouldn't
6:56:45
elderK
Thanks shka_. The RSI seems to come in fits and bursts. It gets really bad for a time and then... seems to vanish.
7:01:19
shka_
in my case, i switched into different keyboard layout (colemak) and this seems to helped, but my evidence is purely anecdotal and therefore you may ignore this
7:01:43
shka_
for sure learning how to type with all the fingers instead of the 3 on each hand helped
7:05:22
elderK
Nice :) I need to invest in a new ergonomic keyboard. My last was destroyed due to well, acids. That's a long story.
7:05:52
elderK
And yeah, bad habits are surprisingly easy to slip back into wrt posture and typing and stuff.
7:06:39
jackdaniel
if you abstract things as macro you'll type less, your wrists will heal back and we'll praise the elaborate macro system in Common Lisp ;-)
7:09:11
elderK
:( Aye. I've had it... for some time. Other than get a new keyboard and try to adjust my angles - and make sure I don't "skip" exercizes, I'm not sure what else to do.
7:09:53
elderK
I mean, from what you've said, you know how it goes. Sometimes, it's merely annoying. Other times, it's so bad you have trouble holding a cup.
7:10:46
elderK
One thing I need, is a proper... desk space. I have a very... skewed setup, mostly due to space.
7:18:54
oni-on-ion
ive no desk or chair, on floor, need to work something out here for the real coding sessions
7:21:36
jackdaniel
given lack of context answer it is a list with letter n in front is as good as any other