freenode/#lisp - IRC Chatlog
Search
19:13:27
pjb
By the way, is there any blind (or vision impaired) lisper? There's this hackernews question: https://news.ycombinator.com/item?id=18414562 ; I've commented suggesting lisp, but I'm not blind, so what do I know?
19:14:12
pjb
matzy_: a useful function for this kind of expressions is LIST* It's like CONS, but with several elements before the rest: (list* 1 2 3 '(4 5 6)) #| --> (1 2 3 4 5 6) |#
19:14:48
pjb
Of course, it can also be used with a single element: (list* 1 '(2 3)) #| --> (1 2 3) |# (cons 1 '(2 3)) #| --> (1 2 3) |#
19:15:45
pjb
To merge lists, use MERGE: (merge 'list '(1 3 5) '(2 4 6) (function <)) #| --> (1 2 3 4 5 6) |#
19:18:17
pjb
append doesn't copy the last argument. apply does like list*: (apply 'list 1 2 3 '(4 5 6)) #| --> (1 2 3 4 5 6) |#
19:18:52
matzy_
so your cons gets (cons progn (*a*) (*b*) (*c*)) at the end of macro execution, right?
19:19:38
jackdaniel
if anyone wonders what's going on with McCLIM, here are pixel-perfect bounding rectangles for a multiline text: http://i.imgur.com/1Ki3Uid.png :-)
19:19:55
pjb
you can use PRINT to see: (defmacro defvars (&rest vars) (let ((defvars (mapcar (lambda (x) `(defvar ,x)) vars))) (cons 'progn (print defvars))))
19:20:09
pjb
(macroexpand-1 '(defvars *a* *b* *c*)) #| ((defvar *a*) (defvar *b*) (defvar *c*)) --> (progn (defvar *a*) (defvar *b*) (defvar *c*)) ; t |#
19:21:08
pjb
(multiple-value-call #'+ (truncate 10 3)) #| --> 4 |# (multiple-value-call #'+ (print (truncate 10 3))) #| 3 --> 3 |#
19:27:23
pjb
Well, the function operator is the operator that creates closure, so it's the most important operator of lisp, I'd say :-) lambda is a macro that expands to (function (lambda …)).
19:28:58
LdBeth
pjb (IRC): even in (setq lexical-binding t), what (function foo) is still return 'foo
19:28:59
pjb
#+emacs (setf lexical-binding t) #+emacs (let ((x 42)) #'(lambda () x)) -> (closure ((x . 42) t) nil x)
19:29:57
pjb
#+emacs (let ((x 42)) (cl-flet ((foo (y) (+ x y))) #'foo)) --> (closure ((x . 42) t) (y) (+ x y))
19:30:34
pjb
of course, you are right for old emacsen and the legacy mode, so it makes emacs lisp rather complicated…
19:33:28
wusticality
pjb: i spose the tricky thing in general is memory management, I need to look into how that works with cffi
19:36:50
matzy_
pjb: ok i've been playing around with the solution you helped me come to in slime. so does @, mean in english"evaluate everything in the body AND splice the resulting list"?
19:38:01
matzy_
i took out the @ and saw the only difference is our result is wrapped in one extra list
19:38:35
anamorphic
LIST* has been quite handy when adding a new property to a plist: (list* :foo 123 '(:bar 456)) => (:FOO 123 :BAR 456)
19:39:46
White_Flame
matzy_: `(literal-term ,outer-term ,@outer-term) a term can be a symbol or a sexpr
19:49:33
matzy_
so if you have `(one two ,@(three four) five) -- three and four are the only things that are evaluated in that statement, right?
19:50:26
pjb
matzy_: this comes from the fact that there's no statement, only expressions and that expressions are lists, with a uniform format: the operator in the first position, the arguments in the rest).
19:51:54
matzy_
so the expression itself is evaluated, but that doesn't mean things in that expression will also be evaluated?
19:53:20
pjb
If it's a function, then yes, the arguments are evaluated, and the results are bound to the parameters of the function that is called.
19:54:28
pjb
(eval (let ((a 1)) `(+ ,@(+ 3 a)))) #| ERROR: The value 4 is not of the expected type list. |#
19:55:00
pjb
You cannot have dotted lists or circular lists in forms (programs). Only in data, as quoted literals.
19:56:37
pjb
but (let ((a 1)) `(+ ,@(+ 3 a) 4 5)) #| ERROR: The value 4 is not of the expected type list. |#
19:57:13
pjb
matzy_: it doesn't matter. You can just use variables: (let ((x 4)) `(+ ,@x)) #| --> (+ . 4) |#
19:58:16
matzy_
ok, but when i'm writing a macro, and it's backquoted, and i use a ,@ before my sexp, do i still need to force things in that sexp to eval or will ,@ take care of it? That's my entire question
20:00:13
pjb
The question is that you want to build a list. What kind of list do you want? What form should it have?
20:01:25
pjb
If you want a list of the form (+ <x> <y>) with <x> and <y> replaced by some expressions that you will compute and produce, then you can do it with LIST:
20:02:18
pjb
backquote which is a reader macro reads as an expression equivalent to my (list '+ <x> <y>):
20:05:13
pjb
matzy_: finally, you would use ` if you can write a model of the form of the list you want. And you would use list, list*, cons, append, etc if you are building a more abstract data structure.
20:05:52
pjb
But even considering that, often it will be clearer to use the list operators, possibly wrapping them in functional abstractions.
20:06:21
matzy_
so back to our solution real quick: (defmacro defvars1 (&rest vars) `(progn ,@(mapcar (lambda (x) `(defvar ,x)) vars))) -- why is lambda not just treated as a symbol, like we do for progn?
20:07:12
pjb
For example, you could write: (defun toplevel-expressions (expressions) (list* 'progn expressions)) (defun make-defvar (var) (list 'defvar var)) (toplevel-expressions (mapcar #'make-defvar '(*a* *b* *c*))) #| --> (progn (defvar *a*) (defvar *b*) (defvar *c*)) |#
20:07:48
pjb
(defmacro defvars (&rest vars) (toplevel-expressions (mapcar #'make-defvar vars))) ; is way clearer!
20:08:40
matzy_
but that was my question i've been wondering about - why is lambda evaluated in that backquoted sexp?
20:09:05
pjb
The only detail is that you need to have the functions toplevel-expressions and make-defvar defined in the compilation environment, since they're used at macroexpansion time. So if you define them in the same file as a the macro, you need to put them in an (eval-when (:compile-toplevel :load-toplevel :execute) (defun …) …) form.
20:10:46
matzy_
got it! i didnt know if ,@ was one symbol that acted on the whole sexp or if , applied to each thing in the sexp and @ affects the resulting list?
20:11:28
pjb
Well, technically it's not a symbol, it's pure syntax, parsed and interpreted by the ` reader macro, but yes. , and ,@ are two different things.
20:12:11
pjb
`(let ((x '(1 2 3))) `(a ,@ x b)) #| --> (a 1 2 3 b) |# `(let ((@ '(1 2 3))) `(a , @ b)) #| --> (a (1 2 3) b) |# ;-)
20:12:43
matzy_
if i need to escape backquotes will @, do that and splice or does it just splice? seems to be the former
20:13:55
matzy_
it's like in my macro, if i didnt have @, there at all the lambda wouldn't be evaluated, right?
20:14:56
matzy_
if i just use , it evaluates everything in the sexp. if i use ,@ it evaluates everything in the sexp, splices the resulting list, and inserts it back into the resulting list
20:15:04
pjb
`(progn (mapcar (lambda (x) `(defvar ,x)) vars)) #| --> (progn (mapcar (lambda (x) (list* 'defvar (list x))) vars)) |#
20:15:48
pjb
Well, more precisely, ` builds an expression where those expressions will be evaluated.
20:17:02
pjb
So you can see that x and xs are not evaluated. But they're inserted in the resulting expressions in such a way that if you evaluate this resulting expression, they will be evaluated.
20:17:20
pjb
(let ((x 42) (xs '( 4 2))) (list* 'foo (list* x (append xs '(bar)))) ) #| --> (foo 42 4 2 bar) |#
20:18:07
pjb
matzy_: indeed, we have to be careful and distinguish read-time, compiltion-time, macroexpansion-time, and run-time and sometimes several instances of them embedded.
20:19:19
pjb
So if you don't evaluate the backquoted expression, then the subexpressions are not evaluated.
20:20:24
pjb
But: (quote `(1 (+ 1 2) ,(+ 1 2) #.(+ 1 2) 2)) #| --> (list* 1 (list* '(+ 1 2) (list* (+ 1 2) '(3 2)))) |#
20:20:52
pjb
,(+ 1 2) implies that (+ 1 2) will be evaluated at run-time, while #.(+ 1 2) evaluates (+ 1 2) at read time; it's like if we read 3.
20:21:35
pjb
matzy_: notice you can prevent the expressions read by #. to be evaluated by setting *read-eval* to nil.
20:22:25
pjb
(setf *read-eval* nil) (quote (#.(+ 1 2) 3)) --> Reader error on #<string-input-stream #x30200236649D>, near position 33, within "(quote (#.(+ 1 2) 3)": #. reader macro invoked when *read-eval* is false .
20:23:17
pjb
But be careful with C-x C-e, since this evaluates the expressions in a separate REPL, those variables must be set globally in the slime-repl, before they can be taken into account in the threads used by C-x C-e.
20:24:08
pjb
alternatively, you can set swank::*swank-bindings* and also swank:*default-worker-thread-bindings* SWANK:*MACROEXPAND-PRINTER-BINDINGS* SWANK::*INSPECTOR-VERBOSE-PRINTER-BINDINGS* SWANK::*INSPECTOR-PRINTER-BINDINGS* swank::*backtrace-printer-bindings*
20:26:11
pjb
So you can use it to generate some code or some data when you program. In effect, this adds an edit-time to the various lisp times :-)
20:33:07
pjb
matzy_: yes, C-x C-e displays the result in the minibuffer. C-u C-x C-e inserts it in the buffer.
20:33:28
pjb
matzy_: C-u is a prefix modifier to emacs commands. A lot of commands can perform variants with it.
20:34:26
matzy_
but i use evil, so i feel like there are a lot of keybindings i'm missing out on that dont get ported
20:42:30
matzy_
but do you ever really think about which vim state you're in? do you think you're in "highlighting mode" when you drag your mouse across text while holding down left click?
20:43:08
matzy_
it's just natural, when you want to type you go in insert and leave immediately after. i've never had to really think about it, since my first week probably (been awhile now)
20:43:52
matzy_
plus i dont see how people live without text objects - ci(, da', vi{......i use those more than any other command
20:46:02
matzy_
i agree, but something that's semantic (like vim's text-objs and motions) comes pretty damn close (if you speak english)
20:46:48
esper0s
i do agree that vi had it pretty well down when it comes to semantically differentiating between text
20:48:52
matzy_
esper0s: does it? i'm curious, i never got beyond the motion keys in the tutorial because i found them so ridiculous
20:59:36
fiddlerwoaroof
matzy_: I use a weird mix of vim and emacs keybindings now, things like C-M-k for (delete a sexp) are particularly useful.
21:02:48
esper0s
have you guys heard of the book "Structure and interpretation of Computer programs" written by MIT and using lisp
21:06:08
on_ion
i've started it. heard very great things about it -- close to one of the best books on such topic
21:06:55
on_ion
https://knowyourmeme.com/forums/meme-research/topics/47038-structure-and-interpretation-of-computer-programs-hugeass-image-dump-for-evidence
21:07:54
aeth
Humans were essentially the same as humans today in behavior and anatomy 40k to 30k years ago. Human civilization started roughly 10k years ago and slowly developed since then. The difference between us and the humans before us is better tools. Tools matter. That's why the editor war absolutely matters. I suspect both vim and GNU Emacs are way better than the competition as far as productivity goes, though.
21:08:44
on_ion
jcowan: is that intended for esper0s ? i was responding to his approach to the channel. he doesn't know this place is *only* Common Lisp - which i already do, too
21:12:30
matzy_
yeah got a bit off topic, i was originally just curious about the cool CL keybindings i'm missing out on in emacs
21:13:48
matzy_
pjb: that actually doesnt help with evil - that shows the replaced bindings (i.e. evil)
21:19:39
flip214
esper0s: on_ion: SICP is really great. It talks about Scheme, but if you manage to rewrite the example on-the-go to Common Lisp, you've got quite an experience before you!
21:19:57
minion
esper0s: please see PCL: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
21:21:40
flip214
matzy_: as a vim user, perhaps you feel more at home with the slimv or vlime plugins for vim8 resp. neovim.
21:23:03
matzy_
I really like PCL cause it's the first book i've read that assumes you actually know how to program
21:23:20
matzy_
versus taking pages upon pages to explain basic things every programmer already knows
21:23:59
matzy_
flip214: there's no going back to me sadly :) just this mixed-up world i now live in
21:24:25
matzy_
as much as i miss vim keybindings (which i do get), i would miss all the crazy crap i've done with emacs even more
21:25:24
matzy_
on_ion: yeah i probably just didnt go far enough, the beginning was too basic and slow for me. then i found PCL, and i'm letting it slowly rape my brain
21:25:48
no-defun-allowed
Per number of anime edits, SICP is more popular than many, many programming languages.
21:26:11
no-defun-allowed
That's the figure I usually use just to show that SICP is a very popular book regardless of who is reading it.
21:27:28
flip214
on_ion: regarding "mind trip" I can also recommend "Gödel, Escher, Bach". And for non-technical literature (but still a mind-trip ;) I value "The Illuminatus! Trilogy" (Robert Shea, Robert Anton Wilson)
21:27:53
on_ion
i see quora etc questions "why is the book so good" and recently read an article (from HN i believe) praising its otherworldly affect or effect
21:27:57
no-defun-allowed
(if you read it long enough, it was trying to tell you to put it down. No one should put a programming text through that kind of torture.)
21:28:29
on_ion
flip214: oh yeah!! thats actually the one singular book i really really want to read. some day i will find it
21:30:33
no-defun-allowed
I think I should add a callback thing to cl-decentralise, so I don't fry anyone's minds with the normal event loop.
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