freenode/#lisp - IRC Chatlog
Search
22:54:55
phoe
so I guess buy it now, mostly because I don't know if asking you to wait for a new edition is asking you to wait forever
0:03:35
nij
For instance, I want the :nickname slot of 'person to be a string that only contains lowercase letters a-z. And whenever an instance of 'person to be constructed, the check is performed; and an error will be signaled if test fails.
0:08:09
lotuseater
or use DEFTYPE to construct such a special string type and use that for the :type field for the slot (that's only checked at initialization if safety is high)
0:09:30
pjb
but types may be ignored by an implementation. Better write the :before method, it's their purpose.
0:10:55
pjb
But using check-type in a :before method would be useless, you could only signal an error.
0:12:14
pjb
So it's better to use the main method: (defmethod initialize-instance ((p person) &key nickname … &allow-other-keys) (assert (and (stringp nickname) (< 3 (length nickname))) (nickname) "Nickname must be a string of more than 3 characters, not ~S" nickname) … (call-next-method) p)
0:12:42
pjb
Well: (defmethod initialize-instance ((p person) &key nickname … &allow-other-keys) (assert (and (stringp nickname) (< 3 (length nickname))) (nickname) "Nickname must be a string of more than 3 characters, not ~S" nickname) … (when (next-method-p) (call-next-method)) p)
0:12:50
nij
pjb: even with initialize-instance, sometimes if the user is not careful, they can still use make-instance to surpass my test?
0:13:32
pjb
nij: but you may prefer to use shared-initialize instead, in case there's a change-class involved.
0:13:39
Bike
technically they could bypass initialize-instance by using allocate-instance and setting slots manually, but if they do that they are beyond the protection of god or man
0:14:28
pjb
The generic function shared-initialize is used to fill the slots of an instance using initargs and :initform forms. It is called when an instance is created, when an instance is re-initialized, when an instance is updated to conform to a redefined class, and when an instance is updated to conform to a different class. The generic function shared-initialize is called by the system-supplied primary method for initialize-instance,
0:14:28
pjb
reinitialize-instance, update-instance-for-redefined-class, and update-instance-for-different-class.
0:15:17
pjb
(defclass animal () …) (change-instance 'person (make-instance 'animal :race 'werewolf) :nickname "Woof")
0:16:17
pjb
But yes, shared-initialize should be used in general, instead of initialize-instance. We can cope with initialize-instance just because we don't re-initialize, redefine a class or change of class often.
0:17:21
pjb
nij: go to #sbcl or some other implementation specific channel to discuss why they don't allow you to lock any slot. For example (lock (aref v 42))
0:18:15
nij
Some object really needs to be checked in order for it to fit into the expected abstraction framework.
0:18:59
pjb
nij: you are asking the questions wrong. You should notl say "I find it weird we cannot do X in lisp", you should say "How do I do X in lisp?"!!!
0:19:12
pjb
nij: the part where you are asserting things that are wrong, instead of asking how to do it!
0:20:43
pjb
nij: that said, I agree that there could be some macrology, to specify invariants, pre and post conditions in a more declarative way, and have the functions and method definiting macros use those declarations.
0:20:46
nij
Or instead I should have said: "I find it wierd to not being able to automatically assumption-check in the thing provided already by CLOS." Is that better?
0:21:26
pjb
nij: you can (shadow '(defclass defun lambda defgeneric defmethod defmacro)) and implement them to process such declarations.
0:21:40
no-defun-allowed
pjb: Stop complaining, start googling https://github.com/sellout/quid-pro-quo
0:22:18
pjb
(defgeneric foo (x) (declare (precondition (< 0 (bar x))) (postcondition (= (bar x) (- (old (bar x)) 1)))))
0:23:23
pjb
nij: some declaration would be needed to specify the allowed conditions. (like throws declarations in C++).
0:25:50
nij
I.. I need time to comprehend quid-pro-quo.. but first I'll do pjb's advice. If someone would, could you please tell me how quid-pro-quo would fit into my need? I will get back to that soon after digesting pjb's word.
0:26:59
nij
===> (defmethod foo ((x c)) …) would automatically insert the test ;; !!!!! I didn't know this.
0:27:44
pjb
Once a symbol from CL is shadowed, we're not talking about CL anymore, but about your own operators!
0:29:34
nij
I'm melt. Sounds exactly what I want: "The client must guarantee certain conditions before calling a method specialized on the class (the preconditions), the class guarantees certain properties after the call (the postconditions)."
0:31:52
pjb
nij: also, note that just using ASSERT in your code, let you insert explicit pre-conditions post-conditions and invariants.
0:32:12
perdent
Hey is anyone interested in a crypto/hardware challenge i made involving DPA/CPA on AES-128? So I captured the embedded device that was used to encrypt the ciphers you are trying to break. are you able to recover its Encryption Key? here is the socket_interface: https://pastebin.com/cLuqmZyY and here is the remote lab layout: https://ibb.co/q9j59Mq PS, his might b helpful, message me if you need any hints, and if you manage to solve it
0:32:13
perdent
Can communicate to the remote device with netcat or or with the socket interface script to receive traces etc.
0:32:13
perdent
Here is the host you can netcat to and communicate via the socket script: 206.189.121.131:32384
0:38:09
nij
quid-pro-quo seems to be a stronger version of dbc, according to someone on the internet
0:41:41
nij
What if I just use deftype.. and make a new type? Then use :type? What are some ways for the users to workaround this scheme?
0:45:56
lotuseater
and then eg (deftype special-string () '(and string (satisfies special-string-p)))
0:48:53
pjb
nij: :type in defclass is a DECLARATION, not a check! "The :type slot option specifies that the contents of the slot will always be of the specified data type. It effectively declares the result type of the reader generic function when applied to an object of this class. "
0:49:15
pjb
nij: it is YOU who are telling the compiler that it does not need to perform any check, that the slot will always contain the type you specify.
0:49:49
pjb
What you want is to check the parameters for the right type. Ie. use CHECK-TYPE in the shared-initialize method.
0:51:32
pjb
(defclass c () ((x :initarg :x :initform 42 :type fixnum :reader x))) (make-instance 'c :x "foo") is undefined, but worse, it makes (declaim (safety 3)) (+ 3 (make-instance 'c :x "foo")) undefined as well AFAIUI.
0:52:27
pjb
Because :type fixnum in the slot works as a declaration, (+ 3 (x (make-instance 'c :x "foo"))) should behave as (+ 3 (the fixnum (x (make-instance 'c :x "foo")))) and therefore cannot signal a type-error.
0:55:53
pjb
well, we're still in undefined waters for (+ 3 (x (make-instance 'c :x "foo"))), so I guess a type-error would be acceptable. But anything else too.
0:56:19
pjb
THE specifies that the values returned by form are of the types specified by value-type. The consequences are undefined if any result is not of the declared type.
0:57:44
nij
https://github.com/sellout/quid-pro-quo/blob/master/README.md ;; see the last code block.
0:58:11
nij
The tests are put in that slot! How did it do it?! Did it redefine the macro defclass as pjb said?
1:00:00
nij
It also says "in order to have invariants on a class, the metaclass must be specified as contracted-class." - metaclasses are still beyond my knowledge.
1:01:50
pjb
nij: nope, there's no shadow in https://github.com/sellout/quid-pro-quo/blob/master/src/package.lisp but dbc shadows defclass and make-instance.
1:02:35
Nilby
My opinion is that until you have a lot of CL experience, it's probably better not to mutate the language too much, until you understand the trade-offs.
1:02:54
pjb
nij: Perhaps the presence of a source file named metaclass is a hint? https://github.com/sellout/quid-pro-quo/blob/master/src/metaclass.lisp
1:03:15
nij
Nilby: Yeah I think so. So I'm trying to find out if it mutates the lang, or actually it's playing in the circle.
1:04:28
Nilby
With Lisp, it's hard to see a circle. In some way every function and macro mutates the language.
1:05:36
lotuseater
hehe, yeah nij, there you could learn also more about where parser-combinators come from
1:06:14
nij
lotuseater: I got irritated when there's no checking performed for a, say monad, when you claim your data is a monad..
1:06:33
lotuseater
and for what Nilby says, it's also not bad for knowing how the MOP works and how (or maybe why) it differs
1:06:34
nij
I think dbc is very important.. I cannot imagine a lang without that. At least, I need to know how to dbc.
1:07:07
nij
lotuseater: Are you hinting that maybe the magic here is played by MOP? I have no idea what that is yet.
1:08:05
lotuseater
when you talk about type signatures in haskell, that's checked at compile time by the GHC type inferencer
1:09:46
nij
Perhaps - in readme it says "Corman – NO[T supported], it’s not supported by Closer-MOP"
1:15:50
saturn2
nij: all the pieces of CLOS - classes, generic functions, and so on - are themselves objects which you can subclass and define your own behavior for. that's what MOP is
1:20:00
zacts
can a lisp program with included quicklisp libraries be compiled into a single binary?
1:21:03
saturn2
yes, as long as those libraries don't depend on reading any files after being compiled
1:22:39
no-defun-allowed
Same as how you'd make a binary without dependencies. Load your code, then dump an image.
1:23:18
zacts
no-defun-allowed: I'm a complete beginner, I don't even know how to do that yet. Can I lookup how to do this in the SBCL doc?
1:24:19
White_Flame
saves a snapshot of the current state of the running lisp image, and give it a function to run when it starts up again
1:24:33
no-defun-allowed
zacts: Yes, but in summary, assuming you have another system with your code, you are looking at (ql:quickload :your-system-name) (sb-ext:save-lisp-and-die "binary-name" :executable t :toplevel #'your-system-name:start)
1:25:39
zacts
would this binary be portable enough that I could post it as a Linux release for a project on GitHub?
1:27:40
zacts
Like, would I be able to publish a single x86 Linux static binary image that others could run on an x86 Linux without them needing to install SBCL?
1:29:43
White_Flame
however, if some of the QL dependencies rely on native .so's being present, those aren't going to be statically linked
1:30:32
White_Flame
so the target machine might hopefully just need some apt installs or whatever to get them
1:34:54
lotuseat`
hm i wasn't aware you can compile static binaries. but that would loose the ability being redefinable at runtime, wouldn't it?
1:39:31
Nilby
zacts: There can be problems, but here's a couple recent successful stories of binary packaging: https://www.timmons.dev/ and https://nyxt.atlas.engineer/article/continuous-testing-and-packaging.org
1:41:17
White_Flame
well, at the OS & C lingo, a static library means it's fully included into your executable when you compile it. A dynamically linked library means it looks for the shared installed separate library file when the executable runs, meaning the executable is smaller and the OS could have a different version and still work
1:42:10
White_Flame
SBCL, for instance, uses a zlib dynamic library to support compressed cores, so it's not fully static
1:46:29
White_Flame
so really, I'm not sure how many "static binaries" there are in existence anymore, but rather you have static libraries vs dynamic libraries
1:49:25
etimmons
definitely no libc.so and libpthread.so. Not sure if there's any special magic for linux-vdso.so on static binaries
1:50:29
etimmons
And possible to do with ECL (definitely easier than SBCL, and actually supported by upstream)
1:52:16
etimmons
libc.so madness was one of the reasons I pursued static binaries with SBCL. I was tired of always needing to remember to compile with an old glibc for the broadest support
1:53:21
Nilby
zacts: There's also this https://github.com/Shinmera/deploy from the first persone, that we know of, to heroicly make CL Steam games.
1:55:46
etimmons
zacts: definitely recommend starting with deploy or linux-packaging. Making static binaries definitely has some quirks that it's best to avoid unless you *really* know that's what you want
2:06:26
etimmons
Yes. and linux-packaging is https://gitlab.com/ralt/linux-packaging/ (also referred to in the Nyxt link)
2:07:31
etimmons
In that case, just use asdf:program-op and compile on the oldest version of your linux distribution that you're willing to support
6:46:33
splittist
I don't see any need for a 2e of TCLCS (I don't have any problems with the style). Perhaps a companion volume in a few years: ITCLCSB - Implementing the Common Lisp Condition System in Blub
7:18:22
phoe
splittist: I actually thought that a second edition of TCLCS could include such a chapter - e.g. a description of implementing a CS in Java (see cafe-latte), and maybe in a non-memory-managed language too if we want to be extra risky
7:21:41
phoe
and there is still stuff that needs to get integrated into the main body from the appendices
7:27:12
phoe
I don't think that a ITCLCSB would be large enough to warrant its own existence, unless we actually do the work and implement those in multiple distinct languages, noting the quirks everywhere
7:33:53
splittist
phoe: I was thinking of your next N papers (as co-author as necessary) as Implementing TCLCS in X, and then the book as a compendium (:
7:43:50
splittist
or just have others write the papers and you can be the editor of the book - "Phoe on Condition Systems" ...
7:45:50
splittist
ACTION imagines the "International Condition Systems Conference" co-located with ELS
7:48:15
no-defun-allowed
"Here we have phoe representing the Common Lisp condition system, and here is psoe representing the Dylan condition system."
7:49:30
p_l
no-defun-allowed: and ploe on "adventures in mandatory stack unwinding land - systemwide exception and condition system in NT"
7:52:07
splittist
Isn't Success (TM) in Academia (TM) mainly about gaming the system? (As opposed to excellence in being an academic, which doesn't seem to be particularly valued.)
7:53:10
p_l
> The machine state of the thread in which the exception occurred is saved in a CONTEXT structure. This information (called the context record) enables the system to continue execution at the point of the exception if the exception is successfully handled.
7:53:35
p_l
so... I can do CL-like conditions in C, so long as it's WinNT and preferably compiled with MSVC
7:54:55
no-defun-allowed
We also have xoe with the intermediate Ralph condition system in the middle.
7:55:53
p_l
so you get cases like ReFS "forking" NTFS driver because of fear of modifying working code
7:56:54
p_l
despite how NTFS logical structure makes it easy to extend (just like ZFS) while most FFS derivatives are hard
7:57:37
phoe
we have somehow strayed from the true path of #lisp on-topic onto the paths of windows kernel quirks
7:57:40
p_l
moon-child: I/O can be plenty fast, especially when you go native, process init is due to different ideas on handling things in NT/VMS vs Linux, which don't really matter for lisp programs
7:59:46
moon-child
my understanding is that nt's i/o is modular in a way that prevents effective caching
7:59:48
splittist
lukego: for playing with CLIME, one would work with your forks of McCLIM and SLIME?
8:01:24
p_l
moon-child: nothing prevents caching, native referred to async I/O instead of sync wrappers, and modularity is problem mainly in the form of annoying other crap injecting itself between cache and your program
8:05:51
no-defun-allowed
I want to implement green threads in SICL. It's not portable across implementation-space, but you can make all your synchronous code "asynchronous" enough.
8:12:25
lukego
splittist: Right. If you check them out and e.g. link the McCLIM into your ~/quicklisp/local-projects/ and put (load "~/git/slime/slime.el") into your .emacs then you should be in business
8:13:34
lukego
(the idea is very much to upstream all this ASAP but I haven't really engaged with that problem yet)
8:19:24
lukego
I've finally (?) fixed some weirdness in Emacs ignoring properties that I put onto images like mouse regions for presentations, the workaround is bizarre but it seems to work now.
8:20:17
lukego
I've also implemented like 80% of ACCEPT now. On the Lisp side you can call the CLIM ACCEPT function and it will bounce that over to Emacs and back to get you an object. the only catch is that Emacs will currently choose that object arbitrarily :). I'm looking at how to do Emacs mouse events now...
8:21:21
lukego
Maybe 80% is a stretch, depends how Emacs will feel about me updating the list of mousable regions on images. maybe I could look at that right now
8:24:53
lukego
that handle is meant in the spirit of carefree innocent hackery, as depicted by e.g. https://www.shutterstock.com/image-vector/two-funny-cheery-exuberant-characters-dressed-114750592, but is probably a poor choice :)
8:30:29
waleee-cl
does anyone know how to explicitly select the gtk3-namespace with https://github.com/andy128k/cl-gobject-introspection ?
8:32:11
waleee-cl
(gir:ffi "Gtk") has the sad property of returning the namespace for gtk4 on my gtk4-recently-added linux distro
8:38:19
waleee-cl
... and (gir:ffi "Gtk" "3.0") fails for reasons. While (gir:ffi "Gtk" "2.0") works peachy
9:27:20
splittist
lukego: I'm getting "CLIME-ACCEPT-IN-EMACS" not found in SWANK package. (And swank-clime.lisp is essentially empty.) I'm sure it's user error...
9:33:24
lukego
Maybe you pulled the clime branch before I pushed that? it went in here: https://github.com/nuddyco/slime/commit/f930f6473b1f4af57d561d62d6cbefd4492015a9. But ahem I see a typo in that commit so let me check and fix that now.
9:38:08
splittist
lukego: same thing. I feel I should be loading the clime contrib somehow (but I'm not)
9:41:11
lukego
Sorry this is horrible for of me to have not tried it on my other computer or at least in a fresh emacs :(
9:43:43
lukego
splittist: okay I tried this in a fresh Emacs now and it worked - got the red circle in the repl - but also an error message that I'll take a look at
9:44:47
lukego
(there's something funny happening where the shape is drawn after the new REPL prompt rather than before it. must be a recent goof. fixing.)
10:07:16
splittist
lukego: On the red circle example I get "error in process filter: Text is read-only", but also a black circle (and a giant cursor afterwards). So I'd call that a qualified success (:
10:07:51
lukego
great perseverance! thanks and congrats! :) the fix I pushed is for that "error in process filter" glitch
10:10:03
lukego
if you're feeling brave you can try https://gist.githubusercontent.com/lukego/e6707cb121224a0d4092577d102a9690/raw/fba491ced67cd93a1e5c83a775054a7e01f40500/gistfile1.txt
10:10:25
lukego
which is supposed to look like https://twitter.com/lukego/status/1389180878757273602/photo/1 including the tooltips over the presentations
10:15:35
lukego
if you hop into *slime-events* and search backwards from the end for :write-clime you can see the SVG code that came over. (Or indeed if you place the Emacs cursor on the image and eval '(text-properties-at (point))'.) but as you say this is already a qualified success :)
10:16:02
lukego
I'm always using absolute RGBA values so there shouldn't be any funny business about color names missing from one side etc.