freenode/#lisp - IRC Chatlog
Search
9:51:28
ralt
_death: I've started playing with adding support for FD passing in dbus, do you think the way to do this is acceptable? It's not finished yet, but the rough idea should be pretty clear https://github.com/ralt/dbus/commit/bf1ff352042b317595ee03f61cb57af072e9d11e
9:56:43
ralt
what's essentially left is cleaning up and editing `(define-dbus-type :unix-fd)` to have an unpacker that uses this function
13:38:36
_death
ralt: it looks acceptable, but perhaps there should be a new defgeneric for the connection protocol, receive-file-descriptors, and the method should be in transport-unix.lisp.. the C function's name should be qualified by a dbus library-specific name, like dbus_lisp_receive_fds.. this post https://blog.cloudflare.com/know-your-scm_rights/ seems to put the buffer into a union to ensure alignment
13:46:55
ikrabbe
Good morning: I'm searching for a little example for specifying types: (let's assume I want to define a type workspace, that is a list containing a name, a list of files and an address of a machine, which again is a list, not speicified yet.
13:47:36
ikrabbe
So how do I write (deftype workspace (list string (list pathnames*) (list)))? in a correct way?
13:52:53
jdz
Lists in Common List consist of CONS cells. Fields of CONS cells can be specified, but the n you have to also specify exact number of cells.
13:53:42
ikrabbe
jdz: that is no problem, to specify the number of cells, so cons might be my friend, and yes :CL
13:53:54
jdz
ikrabbe: You might also consider using a class (or structure) for your top-level container (instead of a list).
13:54:12
_death
if you want a type-ish solution, you can use a class or a structure.. (defstruct workspace name files machine-address)
13:55:25
_death
you can always write a function to make an instance out of the list syntax you defined
13:57:13
ikrabbe
_death_: yes, that's where I currently am. Now I wonder if I can use the common-lisp type system to check the structure of a cell.
13:58:46
ikrabbe
As I have strong doubts against type systems and OO (not to be discussed here), I want to find a minimal approach.
14:01:52
ikrabbe
jdz: that looks readonable. Let me check ..., btw: I guess it should be possible to narrow the type: (deftype theanswer '(cons (and number (values 42)) (cons (and string (values "42") null))) ?
14:04:34
ikrabbe
I'm just trying to understand the type system and how to use it to narrow type queries.
14:09:32
jdz
Yes, you can play around in the repl with TYPEP all you want (just try not to copy/paste your session here, use a paste site). But what is the purpose? If you just want to understand, then I'd suggest reading the Types section of the spec.
14:10:03
Bike
if you deal with these kinds of involved cons types a lot, you might consider (deftype list-of (&rest elems) (if (null elems) 'null `(cons ,(first elems) (list-of ,@(rest elems))))), so that (list-of (eql 42) string) = (cons (eql 42) (cons string null))
14:10:50
ikrabbe
Yes, I double pasted it, but I wanted to express the idea of a type match (or not-match more important))
14:12:11
Bike
the reason jdz is asking (i figure) is that there are a couple different possible things the type system is good for. if you want to use it to provide hints to the compiler for optimization, these kinds of types probably aren't that useful. but if you're actually just testing your own data with typep like this that's probably fine.
14:15:56
beach
ikrabbe: Putting your stuff in a standard object wouldn't make your program "OO". And it is almost never a good solution to use lists for this type of aggregation.
14:21:14
nij
What kind of structures aren't #'READable? Or rather, what kind of structures cannot be made #'READable?
14:21:56
nij
I reckon it might be convenient to dump the current state of my REPL in a reloadable bunch of sexprs. Wonder why that's not possible.
14:23:59
beach
nij: Every "transaction" is saved in a READable format so that if you load the transaction log from a fresh Common Lisp system, it creates a "similar" object graph.
14:24:42
ikrabbe
when I think about an algorithm without fixing the types, I often see the abstraction
14:25:08
beach
nij: And Clobber preserves object identity across transactions, so that EQ objects participating in separate transactions become EQ also after the log is loaded.
14:26:45
beach
And there is no such thing as "a lambda" in Common Lisp. There is the symbol LAMBDA, there are LAMBDA lists, and LAMBDA expressions, not "a lambda".
14:27:31
beach
nij: Not every function has an equivalent lambda expression, for example if the function is a closure.
14:29:23
beach
It is not meant for production. I wrote it to make fun of "object prevalence". It does have some shortcomings. Like I don't think you can redefine how hash tables are printed. But otherwise it seems to work.
14:34:58
beach
As far as I can tell, object prevalence does not tolerate redefinitions of classes and such between the time an object was written and the time it is read back. Clobber, on the other hand, is based only on the protocol properties of classes and objects, i.e., initargs for creation and slot accessors for, er, access.
14:36:05
nij
CLOS objects seem to be printly-readable based on https://stackoverflow.com/questions/3086561/make-clos-objects-printable-in-lisp
14:36:49
beach
nij: The term "CLOS object" is meaningless. Every Common Lisp datum is an object, and every object has a class, and every class is part of CLOS.
14:39:17
aeth
nij: "standard object", not "CLOS object"; that distinguishes it from "structure objects" and built-ins
14:39:57
aeth
defclass defines standard classes, whose instances are standard objects: http://www.lispworks.com/documentation/HyperSpec/Body/t_std_cl.htm#standard-class
14:41:08
beach
In Cleavir, we print ASTs (which are actually not trees, they can have cycles) using the notation [package:class-name :initarg1 value1 ... :initargn valuen] and we define a readtable in which [ does (apply #'make-instance (read ...) (read-delimited-list ...))