freenode/#lisp - IRC Chatlog
Search
15:42:41
Josh_2
I use locks quite a lot and It's a bit of a pita, so something like this is certainly a future project idea
15:45:14
pjb
(defclass bank-accound () ((balance :initform 0)) (movements :initform '())) (defmethod deposit (b a) (incf (slot-value b 'balance) a) (push `(deposit ,a) (slot-value b 'movmements))) (defmethod movements (b) (decf +get-movements-fee+ (slot-value b 'balance)) (copy-list (slot-value b 'movements)))
15:46:29
Josh_2
well if I can't change the default behaviour of (slot-value ..) with this class then I'll just say "don't use slot-value" xD
15:51:13
Bike
you can change what slot-value does. i think pjb is attempting to describe the classic bank account problem: https://en.wikipedia.org/wiki/Concurrent_computing#Coordinating_access_to_shared_resources
15:51:31
Bike
in which locking around individual accesses to the quantities is not sufficient to ensure correct behavior
15:56:35
aeth
Don't name your slots the same as their accessors. I always prefix them with %, e.g. (%foo :accessor foo :initform 42)
15:57:46
aeth
But you can do more, e.g. I guard the setting of slot-value (mainly so I can cover both the initial set and the later accessors) with https://gitlab.com/zombie-raptor/zr-utils/-/blob/master/metaobject.lisp
16:04:54
aeth
Your situation would require more, though, since all I'm trying to do with my MOP manipulation is ensure that the type remains unchanged so that I only have to typecheck once. (I came up with my system because I kept getting random NILs and they're particularly annoying in a game engine since they freeze the whole thing and they're never where the NIL was produced.)
16:06:27
aeth
You are probably going to end up having to write custom sequences if you want to guarantee locking and you use sequences.
16:34:35
pjb
Bike: well, the classic bank account transfer operation involves two bank account objects. My example is worse: it's a single operation on a single object, but it involves two slots.
16:34:57
pjb
Monitors don't put locks around slot-value or accessors, but around all the methods of the object.
16:35:31
pjb
My example would be solved by monitors. The classic bank account transfer operation wouldn't be solved by monitors. This is probably why monitors are not in widespread use.
19:14:43
edgar-rft
seok: I think the minimum is 1) lisp-mode (comes with Emacs), 2) Slime for the communication with the external Lisp process, and 3) Quicklisp on the CL side, everything else is optional.
19:23:36
White_Flame
my installation steps are typically emacs, then quicklisp, then https://github.com/quicklisp/quicklisp-slime-helper
19:35:52
mrcom
seok: Other useful packages: company, ethan-wspace, hungry-delete. If using sly: sly-company, sly-quicklisp.
19:42:44
mrcom
seok: Other useful cemacs.d tweaks: cua settings (enabling/disabling Windows/Mac style cut/paste/delete); indent-tabs-mode; mouse-whell-scroll-amount; toggle-comment-on-line; recentf-save-file. If using ethan-wspace: (setq mode-require-final-newline nil)
19:47:23
mrcom
seok: Slime stuff I had enabled before switched to sly: (setq slime-contribs '(slime-editing-commands slime-typeout-frame slime-fancy-inspector slime-repl slime-trace-dialog slime-sprof slime-scratch slime-presentations slime-c-p-c slime-xref-browser slime-autodoc slime-references inferior-slime slime-asdf))
19:55:36
mrcom
seok: (setq slime-net-coding-system 'utf-8-unix) (setq slime-scratch-file "~/.slime-scratch") (setq slime-autodoc-use-multiline-p t)
0:23:09
kinope
In reference to my previous question about logand or mod being performant. I think I get it now, It's not a question of if they are as performant as C/C++. But of how much flexibility I want to trade for the performance. I sometimes forget that a C compiler and a Lisp compiler (some implementations) both generate native code. So in the end it's possible for computation written in CL to be just as performant, given a
0:23:09
kinope
sufficiently capable compiler AND the required declarations so that it may produce the intended result. Am I off the mark?
0:35:20
White_Flame
kinope: if the CL compiler knows that the operands fit in a machine word, you can expect it to be as fast as C
0:51:21
pjb
kinope: you're correct if you are thinking in terms of generated code. (Note that even in the case of C, it's really not obvious what the generated code will be. It is said that C was designed so that it may compile to simple (PDP-7/PDP-11) instructions, but this was in 1969. C17 is quite different, but foremost, the processors used today are very different.
0:51:46
pjb
kinope: so the mapping of the semantics of operators to current processors is not obvious, even for C.
0:53:10
pjb
kinope: and if you compare directly CL to C, the semantics are very different, even if in apparence, there may be direct translations between C and lisp (Ă -la rosetta stone).
1:15:30
Pixel_Outlaw
pjb Any insight on the cost of trashing and reassignment in CL vs mutation? I bet it's a bit more anticipated in Schemes.
1:24:25
mrcom
kinope: Here's what SBCL generates: (disassemble (locally (declare (optimize (safety 0) (speed 3))) (defun foo (a b) (declare (type fixnum a b)) (logand a b))))
1:27:30
White_Flame
Pixel_Outlaw: conses tend to be the cheapest things to allocate, as it's just the 2 cells and no other storage overhead
1:39:57
White_Flame
Pixel_Outlaw: I think in every language, mutation will always be faster to execute for the mainline case. There's simply less related work to do
1:40:09
lottaquestions
how does one know if the original element obtained by rest from a list was an atom or a list?
1:44:01
kinope
pjb: Do semantics differ between CL implementations also? I'm thinking of ecl and how it compiles to C, must one then think in terms of C's semantics when writting optimised code for ecl.
1:44:37
White_Flame
certainly byte-coded implementations will have significantly different performance characteristics than native compiled ones
1:45:08
pjb
kinope: the CL standard indeed let some things undefined, up to the CL implementation. But conforming programs run in conforming implementation have a very specific semantic.
1:46:14
lottaquestions
@White_Flame: checkout this function and the results I get, it explains my conundrum: https://pastebin.com/BrekMZWu
1:46:57
White_Flame
kinope: basically, if something claims to be "Common Lisp", then it should follow the exact same specified semantics. But other non-CL Lisps can do whatever they want to mold to their environment to make them a lighter layer
1:48:03
lottaquestions
because I use rest, an atom is transformed into a list, and I get a match against the second a
1:49:20
pjb
lottaquestions: so what will it be? Do you consider cons cells or proper-lists? What about dotted-lists?
1:50:40
kinope
Okay, so the semantics should stay constant, but the performance characteristics will change depending on where the implementation sits on the stack of abstractions (on a virtual machine, or on top of C runtime)
1:51:03
pjb
lottaquestions: in this kind of functions, you could also want to specify what occurs for vectors and arrays, and perhaps other structures.
1:51:22
White_Flame
kinope: the CL spec is considered quite well specified as far as ensuring semantics goes. Decades-old code still runs
1:52:38
pjb
lottaquestions: you're using first/rest which is ok for a proper-list, but then you're comparing search-expr with the whole-list-of-expr that you have named whole-expr.
1:53:18
White_Flame
lottaquestions: btw, (let ((func (lambda ...)) (funcall func ...)) should be replaced with:
1:54:17
lottaquestions
White_Flame: Thanks. I struggled with that one. Especially since I didn't fully understand the difference between a lisp-1 and a lisp-2
1:54:55
White_Flame
yep, and #clschool might be more appropriate then, as here you'll usually get "very complete" answers with minutia that isn't the best for beginner learning
1:56:53
White_Flame
lottaquestions: your count-adder should be recursive itself, with a single RESULT binding outside that function. A simple incf result inside count-adder will make things easy
2:13:16
pjb
seok: CL has a *default-pathname-defaults* which is bound to a pathname designator, which may contain some directory component (but also other components).
2:13:43
pjb
seok: and of course, there are extensions in CL implementations running on POSIX systems…
2:15:12
pjb
seok: you may try: (uiop/os:getcwd) but only on CL implementation running on POSIX systems that have some posix extension
2:31:03
xristos
i try not to waste time with irc drama, but pjb has given me good advice in the past, and i don't see why a ban is merited here?
2:38:07
xristos
for the record i don't agree with this ban, he's spending his personal time here to help others, i've gotten useful advice from pjb, him mentioning POSIX is informative, i don't see why he should be banned
2:39:06
no-defun-allowed
In #clschool he accused me of only talking "degenerate" stuff and not about Common Lisp, and we generally haven't gotten along well.
2:42:56
PuercoPop
But I would think not. pjb has been giving unhelpful answers here for more than a decade
3:37:45
potta_coffee
I've been using Dr Racket to write Scheme for a while, and I use Sublime at work, I want to write Common Lisp now but nothing really seems to be satisfactory. It looks like Emacs is supposed to be the answer but
3:39:01
potta_coffee
It seems like it's really powerful, lots of features. Just a lot of time investment for me when I really just want to bang out some code
3:39:24
beach
Emacs with SLIME is currently the best development environment we can propose for using FLOSS Common Lisp implementations.
3:39:30
potta_coffee
Just thought I'd ask here and see if anyone is successfully using any alternatives
3:40:00
beach
So you don't really plan to learn Common Lisp? Just "bang out some code" and be done with it?
3:40:16
White_Flame
emacs is just an editor, and only a few keystrokes to do the lisp integration is required to learn
3:40:40
White_Flame
I'm no fan of emacs and use it because it's the best lisp environment; you don' thave to go deep with emacs at all