freenode/#lisp - IRC Chatlog
Search
21:32:19
aeth
on_ion: A callback is not really call/cc, just a higher order function afaik. (Not even technically that since you can do it with non-first-class functions, too.)
21:33:22
no-defun-allowed
So I have a list or structure with all the new callbacks after they get registered in some kind of setup macro, then I just pop em off while I get new data.
21:33:53
no-defun-allowed
Maybe I'll make it capable of lparallel if I want to get fancy and use multiple threads. Node people would lose it though.
21:36:09
aeth
no-defun-allowed: Instead of going through fresh functions, I have my functions that are passed in take a certain data structure that represents its state and keep the function constant.
21:36:34
aeth
no-defun-allowed: i.e. I pass in an init function, that init function returns a state and a function that's called every iteration with that state (and some other things if needed)
21:37:14
aeth
And I have no clue what that state is, or that function is, the init function handles it
21:37:44
aeth
(I even have an optional (could be NIL) call-at-the-end function to close connections)
21:38:01
no-defun-allowed
It's not awfully efficient (or safe, I haven't drop tested it), but so far my only method of programming cl-d programs is using an event "loop" handler which is a little awkward when state gets involved. https://gitlab.com/netfarm.gq/cl-decentralise/blob/master/eventloop.lisp
21:41:41
aeth
As far as style goes I'd use with-gensyms and once-only from alexandria, so (with-gensyms (line block-data) (once-only (connection) `(loop ...)))
21:42:08
no-defun-allowed
I'd rather have an `on` macro which takes similar arguments to one of the cases in the event-loop and a lambda.
21:42:30
no-defun-allowed
Yes, I've loosened up and used Alexandria in Netfarm so I might as well use it in cl-d now :)
21:42:54
aeth
event-loop should probably either be called define-event-loop and create a function or it should be called with-event-loop imo
21:43:09
anamorphic
I'm using CHECK-TYPE and DECLARE TYPE at the top of my function and it's seems kind of redundant. Thoughts?
21:43:19
aeth
A name like event-loop sounds functiony and you can't really tell macros and functions apart without naming conventions
21:43:43
aeth
anamorphic: check-type and declare are redundant. Some implementations ignore declare, and SBCL ignores check-type if a declare is present since it already does the check
21:43:47
no-defun-allowed
I'll probably remove the "loop" part so with-event-handlers is likely to be the new name.
21:44:56
aeth
anamorphic: Use declare if you want performance alone, use check-type if you want to be able to correct the type at runtime (but it will be slower in at least SBCL), and mix the two depending on the implementation (with a macro, obviously) if you want the optimal solution for a given implementation even if the type error isn't always correctable at runtime like check-type gives you.
21:46:09
aeth
anamorphic: I wrote a macro DEFINE-FUNCTION to be a syntactic unification of CHECK-TYPE and DECLARE without using both at the same time. https://gitlab.com/zombie-raptor/zombie-raptor/blob/ab11fe386c84f4d9ac963370275eea2e3f872902/util/util.lisp#L140-240
21:46:49
aeth
In particular, I intend to make the default option eventually depend on the implementation so e.g. SBCL will default to DECLARE and CLISP will default to CHECK-TYPE
21:50:19
aeth
I don't have anything for bindings yet because I intend to have a unified binding eventually (i.e. handling all of LET, LET*, MULTIPLE-VALUE-BIND, FLET, LABELS, MACROLET, etc. and maybe even WITH-ACCESSORS and SYMBOL-MACROLET)
21:50:20
anamorphic
Awesome. Maybe serapeum then perhaps. Don't leave home without (:use #:cl #:alexandria #:separeum)
21:53:52
aeth
My motivation for the LET rework is I want to be able to do (let (((values x y) (floor 42.5d0))) ...) like you can use VALUES in SETF
21:55:28
aeth
That's also why I'm not entirely sure how my macros compare to it. I'm intentionally not reading how it works since my work is MIT licensed.
21:56:19
anamorphic
Yeah might be a big hangup for some. I'm just an enthusiastic amature/noob though so it doesn't matter to me personally
21:56:31
no-defun-allowed
I believe if I'm vague enough, it's legally cleanroom reverse engineering at worst.
21:57:36
aeth
It's quite amusing in check-type mode. It will still work, it just m-v-b's your entire program and then check-types those values and then returns those values
21:57:36
no-defun-allowed
No but actually I use it since I don't want people selling my programs. That'd be rude.
22:01:57
no-defun-allowed
The Cooperative Software License. It's pretty much the AGPLv3, but it has restrictions on who can sell the software, and its grandparent is the CC BY-NC-SA license.
22:08:57
anamorphic
aeth: Wish you the best with define-function. Seems incredibly useful - an easy way to get both safety and type hints to the compiler
22:13:29
aeth
I wonder if it's possible to modify CLOS so you can provide classes for optional and keyword arguments in a method. Then I could have (almost) unified syntax (define-method would use classes, define-function uses types, and there's a difference because types allow things like (integer 0 *)).
22:14:32
aeth
Technically, types in &rest could be handled by default-type (which would have to be renamed for unified define-function/define-method syntax)
22:17:51
bike
as in, if you write (&optional (x integer)), does that mean integer is a variable with whether x was provided, or a type
22:18:21
aeth
bike: I require a default value in optional and keyword arguments, even if the default value is NIL and thus will always error in (x nil integer)
22:22:52
aeth
cgay: I guess I could optionally make default interpreted as type if type is NIL as an option
22:23:21
aeth
that just requires modifying the name-and-options destructuring-bind of (name &key inline optimize debug default-type check-type return) to add a new flag
22:34:26
aeth
It's not as easy as I thought because I would really want to combine the parsing of the typed lambda list (which means LOOP instead of MAPCAR) if I want to configure the parsing like that
22:38:56
aeth
This is probably a bug in SBCL itself. (Alternatively, SBCL might have been corrupted by bad user code, e.g. by an undefined Lisp operation like (fmakunbound 'compile), or by stray pointers from alien code or from unsafe Lisp code; or there might be a bug in the OS or hardware that SBCL is running on.) If it seems to be a bug in SBCL itself, the maintainers would like to know about it. Bug reports are welcome on the SBCL mailing lists, whic
22:52:44
aeth
cgay: I think the most intuitive way of handling the problem is having a type-first? option that provides the alternate syntax (binding &optional type default)
22:58:21
no-defun-allowed
could you get in trouble for intentionally sending someone a zip bomb automatically?
22:58:52
aeth
Is there a way to get an arbitrary-length typed cons? e.g. (typep (list 1 2 3) '(cons fixnum (cons fixnum (cons fixnum)))) => T
23:00:36
aeth
What I'd really want is something like the (obviously invalid) type: `(list ,default-type) for the &rest
23:04:37
cgay
aeth, not sure if we're talking about the same thing, but for the supplied-p issue couldn't you just allow &optional (a 1 integer a-supplied-p)?
23:13:56
aeth
NIL will work unless it's T, SYMBOL, BOOLEAN, or LIST. For the last 3 you can just use some other type or another default value.
23:15:17
cgay
wait, it doesn't completely, right? you might want a valid default and a way to figure out if the arg was supplied.
23:15:52
aeth
I'm not sure how that could be done. I think that's too high-level for define-function
23:17:21
aeth
There are some edge cases I know I don't handle, like trying to use :inline when you're not in a top-level-form (e.g. within a LET or DEFUN instead of PROGN or actually top-level). I inline and ftype with declaim.
23:26:37
aeth
cgay: It seems doable in check-type mode, but with declare mode there's no way (afaik) to tell the difference between the user using the reasonable default as default or the user providing that same reasonable default manually because a fake default value (easiest way to implement this) can't be used without changing the actual type in the declaration. It would also make the default value unviewable in SLIME's API minibuffer thing.
23:28:59
aeth
At least the way I think it could be done is turning any type into (or null type) and then if (null foo) provide the actual default and make a note that that is done
23:29:51
aeth
(Not quite that easy because the type would also have to be parsed to make sure that it is not including SYMBOL, BOOLEAN, LIST, or NULL already)
23:30:46
no-defun-allowed
should test wpscan against magrathea first before doing any fun stuff today
23:31:56
no-defun-allowed
still damn CLOS is really easy to work with how haven't all the c++ plebs heard of it
0:02:36
void_pointer
no-defun-allowed: some C++ people do know about CLOS, but most don't. There are many features a language can have and everyone has a set they haven't heard about. As for those who have heard about it, there are still reasons to use C++ and as well as many use cases where something like CLOS wouldn't be appropriate or desirable anyways.
0:04:39
pjb
aeth: for a finite length, you can (deftype list-of-length (n type) (if (zerop n) `(member nil) `(cons ,type (list-of-length ,(1- n) ,type))))
0:05:14
pjb
aeth: (typep (list 1 2 3) '(list-of-length 4 integer)) #| --> nil |# (typep (list 1 2 3) '(list-of-length 3 integer)) #| --> t |#
0:05:17
void_pointer
C++'s object model allows slot access without having to do a double indirection (first indirection to the instance's data to ge the pointer for the slot and the second to go from that pointer to the location of the value). A good optimizing CL where the slot is given a type which could be stored in place could avoid the indirection, but tht depends on how smart the implementation is among other things.
0:06:37
pjb
aeth: for an unbounded length list, you'd have to use satisfies if you want to check the type of all elements.
0:16:22
emaczen
I'm calling #'sb-ext:run-program and #'ccl:run-program neither work, but SBCL gives the helpful error message of "Permission Denied"
0:17:38
emaczen
I can run the program that I want to without any problems from the terminal and am passing the same arguments, so I don't see why I am having trouble executing it from lisp
0:25:12
aeth
pjb: I don't think any of the presented options are satisfactory for optionally generating a type for type-checking (or type-declaring) a &rest rest in a defun.
0:30:05
aeth
pjb: I'd like to be able to do this (which doesn't work, at least in SBCL): (deftype typed-cons (type) `(cons ,type (or null (typed-cons ,type)))) (typep (list 1 2 3 4 5) '(typed-cons fixnum))
0:31:12
pjb
aeth: (assert (every (lambda (arg) (typep arg 'fixnum)) arguments) (arguments) "All arguments should be fixnums")
0:31:37
pjb
If you define fixnump: (assert (every (function fixnump) arguments) (arguments) "All arguments should be fixnums")
0:31:39
aeth
Even that isn't 100% satisfactory. When I have my fake "cons" struct that acts as a typed cons the checking is O(1) (only need to check the car) but that probably is O(n) checking (it's irrelvant for checking a &rest rest, though, because you'd need O(n) checking on creation no matter what)
0:31:54
emaczen
(ccl:run-program "/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" '("--render" "/Users/thutmose/openscad/bolt.scad") :wait nil) -- uggh it works with #'sb-ext:run-program on SBCL, but not with CCL...
0:33:03
emaczen
with CCL I get a little cocoa window that pops up and says OpenSCAD quit unexpectedly
0:33:24
aeth
pjb: That assert (or a satisfies type) gets the validation side of things but it (probably) does not provide the performance advantage of helping the compiler out with type information (I'm guessing it won't know that (CADDR foo) is a fixnum even though we just validated that)
0:34:22
pjb
(uiop:run-program "/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD --render /Users/thutmose/openscad/bolt.scad &" :force-shell t)
1:26:41
pjb
biscut_boy: UNP uses C. Perhaps you'd want to write a good networking book using lisp? There's a niche to be filled!
1:27:47
pjb
https://www.amazon.fr/s/ref=nb_sb_ss_c_1_10?__mk_fr_FR=ÅMÅŽÕÑ&url=search-alias%3Daps&field-keywords=unix+network+programming&sprefix=unix+netwo%2Caps%2C127&crid=20UFXEMIG6K66&rh=i%3Aaps%2Ck%3Aunix+network+programming
1:29:51
pjb
biscut_boy: most implementations provide a lisp API to the network. But for various reasons (including portability of your lisp code), you may prefer to target the POSIX socket API, using CFFI (thru, eg. libraries such as usocket or iolib).
1:30:32
pjb
In any case, using either the "high level" lisp API or the basic POSIX API from lisp, is better done knowing well the unix C API described in the manual pages of your unix box, and the UNP book.
1:31:18
pjb
Also, there are other books for specific protocols, or for networking on Windows (which may be useful to read if you want to communicate with Windows processes).
1:32:45
pjb
Nowadays, you will also need to include cryptographic and other security considerations not mentionned in UNP (unless there's recent editions with additions?). So additionnal knowledge about SSL/TLS, Kerberos, and stuff like that will be useful.
1:35:52
pjb
So you see, there's matter to collect notes for a big interesting book about Network Programming in Common Lisp.
1:35:54
biscut_boy
I was hoping for something like https://www.amazon.com/Computer-Networking-Top-Down-Approach-7th/dp/0133594149 for lisp x_x
1:36:40
pjb
biscut_boy: but really, learn CFFI, and you can use any of those books using C libraries.
1:37:21
pjb
It might be more difficult to adapt from higher level programming languages since you would have to know well both python and CL to perform a good translation (plus the networking stuff).
2:53:50
emaczen
jusss: AFAIK Something to avoid mutability in programming that is used in statically typed functional languages such as Haskell
2:54:26
emaczen
jusss: It isn't something you will ever have to worry about in usual commonlisp programming
2:56:39
jusss
emaczen: I think those concepts are common in the most languages, but as you see all the examples are haskell, and I can't understand it
2:56:47
pjb
We would need to specify some API that implementations could all provide instead of having their specific variants.
2:58:47
sjl
I'm getting an error when trying to (ql:quickload :drakma) but am not sure if I've just borked something on my end
3:00:57
bike
and monads are a very abstracted concept, they're not promises, although there might be some way to deal with promises in a monadic fashion
3:01:18
no-defun-allowed
I also don't know how monads work, so I can't talk about similarities in CL if there are any.
3:05:40
emaczen
sjl: I compiled all my lisp files with abcl to .abcl files and then made a Java main function that creates a Lisp Interpreter object that then loads all the compiled files...
3:06:09
emaczen
But I was hoping somebody would know something about efficiency and ABCL because my program is using a lot of memory and CPU...
3:06:52
sjl
I haven't really messed with it much, except to try to make sure my libraries' unit tests pass in it
3:12:39
emaczen
Anyone have some experience with ABCL that can give me some pointers about efficiency?
3:23:46
pjb
emaczen: I would have a look at the code generated by abcl. It's probably close to be as efficient as it can be, on a VM specialized to run java code…
3:52:50
on_ion
prolog could help us figure out why ABCL and CCL differ numerically considering the "CL" is shared and there is an extra C. AB must be valued around 14-19 total abouts
3:56:23
no-defun-allowed
Although there's 4 variables and 2 equations which probably means it won't have one solution.
3:58:55
no-defun-allowed
ACTION uploaded an image: Screenshot_2018-11-10-14-58-17-1.png (34KB) < https://matrix.org/_matrix/media/v1/download/matrix.org/QsMnLRylzfeImROlCRbGsrRU >
4:00:28
no-defun-allowed
I assume %r_n are gensyms and can be substituted for their respective named variables.
4:04:43
no-defun-allowed
ratsimp doesn't seem to take systems of equations, but it doesn't look too hard to substitute.
5:08:11
ealfonso
I feel sad that in the end, after giving CL a try for web application development, I need to go back and re-learn clojure again
5:19:01
ealfonso
too many JSON libraries and spending too much time trying out different ones and figuring out json=>lisp problems. no built in support for parallelism. hunchentoot's default dispatcher/handler approach doesn't make it very easy to introduce web app middleware or compose apps
5:20:42
ealfonso
the same problems for DB to lisp. also no assurance that libraries are secure and scalable
5:23:30
ealfonso
in clojure there is built-in support for maps, so I don't need to worry too much about json -> clojure or back
5:27:28
ealfonso
all of this could theoretically be solved in CL with equivalent libraries, frameworks, and a community around them, but I feel the momentum is not there. clojure is opinionated but most of the time this means I don't have to create web development infrastructure from scratch and can just learn and adapt to the "right" way of doing things
5:48:53
capadoodle
can I get a macro to create multiple functions at once? or do I have to write a macro to write each variation of the macro?
5:54:16
no-defun-allowed
ealfonso: i wrote "middleware" for hunchentoot yesterday, in the form of magrathea.
5:55:00
no-defun-allowed
you just subclass (easy-)acceptor and do (call-next-method) when you're done.
5:56:05
no-defun-allowed
i haven't had problems with cl-json, cl-who, hunchentoot and bordeaux-threads or lparallel.
6:04:27
ealfonso
in clojure I can use the built-in mapc, but when I look at this I have no idea where to start: https://www.cliki.net/concurrency and may have to spend time evaluating things. I guess lparallel is the most popuplar one, but it's hard to tell. but with clojure I can just rely on concurrency primitives with confidence. with cl-who I was having problems with excessive compilation time and had to switch to static html + JS.
6:08:02
no-defun-allowed
lparallel provides parallel clones of map, remove-if-(not), reduce and sort and probably some more
6:08:42
no-defun-allowed
bt has locks and threads and is a bit more bare but works when lparallel doesn't expose the primitives you need (eg working with generators)
6:09:41
ealfonso
no-defun-allowed I'll give it a try. and maybe I should also try a compiler other than sbcl.
6:36:43
matzy_
why are '(1 2 3) and (list 1 2 3) equivalent, but (list 'a (+ 1 2) 'c) and '('a (+ 1 2) 'c) not?
6:38:15
no-defun-allowed
there's some intrinsics about which can be mutated but that's not too useful right now if that's something on your mind
6:44:43
LdBeth
because LIST means contruct the list each time called, while QUOTE means a constant value
6:50:23
LdBeth
yes, so (list ...) returns new address when called, while the QUOTE form return a fixed address
6:53:22
LdBeth
yes, in foo the same address is passed to nreverse, and in bar each time a new list is constructed with its address passed to nreverse
6:56:22
LdBeth
It may be confusing to see the difference of items that printed the same but in slime you can click the item and usually the address of that item can be seen in the popup window
6:57:43
matzy_
it's funny, cause i was just thinking to myself, learning macros are really weird, because you think you get it one second, then you dont the next, and the only other time i felt like that was when learning pointers for the first time
7:00:18
no-defun-allowed
double quoting is still way off for me but i can write macros, it's pretty straightforward
7:02:11
matzy_
see i always think that, but then you get into double parens, and weird situations where it's confusing...i dont know. it seems so clear and then i try and build a function and i can't get anything right
7:04:04
capadoodle
writing a macro for the first time and feeling it click (even temporarily) is the most amazing high *o*
7:08:03
LdBeth
first you have ideas on what the code will like after macro expending and then invent code do that for you
7:25:11
no-defun-allowed
beach: indeed, the odds are highly against python but somehow people use it.
7:25:37
no-defun-allowed
it's not compiled, it can't make use of posix threads but somehow it's a good teaching tool or something
7:26:08
beach
Now THAT I can understand. In fact, I made the decision to use it as the first language here at the university.
7:26:44
beach
But I can't understand how, in a professional setting, someone would decide to use it for a project.
7:32:38
no-defun-allowed
however, a more interactive system like pharo or squeak would be much easier for learning in IMO, beach
7:33:02
no-defun-allowed
a few years ago when i got IDLE running for the first time it was very underwhelming
7:33:55
LdBeth
ha, many lisp systems were that quality, especially some INTERLISP systems from Xerox
7:34:09
beach
My situation was extremely particular. Here, first-year students have not yet chosen between physics, chemistry, math, or computer science. Also at the time, the scientists (physics, chemistry) were in control and despised anything CS.
7:35:06
beach
I convinced them that Python was not used in CS, but it was used a lot in the sciences.
7:36:13
beach
They would not have had the time to learn Fortran or C++, and I certainly did not want to teach it.
7:46:49
no-defun-allowed
shka_: though you could probably golf it more, i did this in a boring computing class: https://twitter.com/theemacsshibe/status/1034584788470915072