freenode/#lisp - IRC Chatlog
Search
13:15:04
xificurC
compile time is a moving target when the compiler is available at runtime :) a defun in a library will be AOT compiled and a defun at a lisp file will be JIT compiled
13:22:05
xificurC
I'm doing something similar to this https://github.com/fare/command-line-arguments , just wanted to avoid the replication of the options (he writes check, verbose, warn ... twice) and skip the creation of a +command-line-spec+
13:25:44
xificurC
nowhere_man: I meant (load "x.lisp") and (load "x.fasl"). A library loaded with asdf will be precompiled into a fasl, isn't that right?
13:27:32
beach
Here is my latest suggestion with respect to the stepping commands of a good debugger: http://metamodular.com/stepping.pdf
13:28:33
xificurC
LdBeth: why would that matter. I was talking about handing a lisp file or a fasl to e.g. sbcl
13:32:00
xificurC
LdBeth: how does that relate to my point? I was saying compile time is a moving target. Think eval-when
13:36:27
phoe
beach: 5.2.1 - the debuggers I know behave as "step over" in that case. If you cannot step into an instruction, you step over it.
13:36:48
phoe
Your debugger may behave differently, though - *especially* if it informs the user that the instruction at point cannot be stepped into.
13:37:52
beach
phoe: In that situation, step over also has no effect. So it does behave like step over.
13:40:03
xificurC
White_Flame: here's a simplified piece of generated code i need - http://ix.io/1d6h/lisp . Think of that being e.g. in a (setf (symbol-function 'foo) snippet-here). The problem that is still baffling me is how to design the macro to take the data that defines the API (the '(:args ... :options ...) part) in a way it can be reused between different i
13:49:00
White_Flame
(defvar *shared* '(:key val)) is in the same format as what (mymacro (:key val)) receives
13:49:58
White_Flame
it's a statement. There's no difference in format between lists that a macro sees, and lists that are stored in variables
13:50:16
White_Flame
the quote is needed when things are being evaluated, but it's still just a list
13:51:12
xificurC
White_Flame: there's no defun, as I wrote the expansion should have been (setf (symbol-function 'foo) :snippet-here)
13:51:57
xificurC
White_Flame: (mymacro (key val)) is different to (myfunction (key val)) though, that's the point.
13:52:26
White_Flame
sure. (mymacro (key val)) vs (myfunction '(key val)) if you want to interchanget hem
13:53:45
White_Flame
or with (defmacro mymacro (paramlist) `(myfunction ,paramlist)), you can use (mymacro list-var) vs (mymacro '(key val)). It's your call
13:54:12
White_Flame
but if you have parameters that need to be evaluated, then you can't evaluate them at compile-time
14:11:40
xificurC
White_Flame: those examples are fine, I used them, but I'm stunned here because I'm trying to pass in code and use it as code in one spot and as data in another one
14:12:17
xificurC
White_Flame: as you said if you do `(func ,val) then val can be '(a b c) or (defparameter *x* '(a b c)) and then just *x*
14:13:09
White_Flame
one big issue is that build-cli is being called at runtime and is getting passed source code for lambda functions
14:14:12
White_Flame
if it's used in compile-time, then you can simply walk the structure and place the lambda clauses where they need to go
14:16:17
White_Flame
but stlil, with the backquote, your macro can't really do anything with walking it
14:17:22
White_Flame
I think at compile-time, you should walk the list structure and generate code for the clauses it encounters
14:20:19
White_Flame
but even with what you curretnly have, it doesn't work with (defcli dockerfile-generate (:args ...)), with (apply #'build-cli ',clidef) inside defcli?
14:20:51
White_Flame
ah, no, because you still have the lambda problem, and the lambdas need to be pulled out at compile time
14:36:51
White_Flame
there's no barrier to do what you want; the fact that you've written so much to be runtime instead of compiletime is constraining you
14:37:14
xificurC
actually I'm giving up on the macro because the function I want to generate I might want to use with other arguments than what comes from argv, right
14:40:11
xificurC
White_Flame: because '(:args ((file)) :options ((down #\d ".." :flag) (create #\c ".." :flag))) *is* runtime data
14:41:46
White_Flame
of course, it could simply be a stated requirement that it can be dynamically generated, which would force you to handle it at runtime
14:42:29
xificurC
White_Flame: I don't see how can it be compile time constant if I want it to be composed
14:43:23
White_Flame
so if you want a function whose arguments are extracted from that, it must be EVAL'd up at runtime
14:43:42
xificurC
the purpose of code is to automate tasks. I don't want to copy-paste common arguments all over the place :)
14:44:22
White_Flame
a macro can simply add &allow-other-keys to your defuns, and pass those through to the common handler
14:47:12
xificurC
White_Flame: I just don't see how to not have the quote there if I want it to be runtime composable
14:48:03
White_Flame
a function in that sense would do exactly the same as a macro in your broken case
14:48:23
White_Flame
a macro takes a spec, generates source code, and returns it to the current evaluator
14:51:33
xificurC
http://ix.io/1d5U/lisp didn't work. If you replace ,(cli-arglist def) with ,(cli-arglist (eval def)) it works. If you replace it with ,(cli-arglist (cadr def)) it works too
14:52:44
White_Flame
basically, he has runtime code to handle the spec list, but he also wants compile-time code to create a DEFUN whose arguments are defined by teh spec. The spec must be runtime-evaluated, as it might not be lieteral
14:53:08
White_Flame
xificurC: that doesnt' help you actually execute a DEFUN or instantiate a lambda
14:56:16
Bike
CADR will only work if it's a quote form. If it will always be a quote forom, you should just not have it be quoted instead.
15:00:20
xificurC
I'll just avoid the macro for now and have 2 steps - defining the spec and defining a function. Then there can be a helper function that parses the argv based on the spec and hands it over to the function
15:01:00
xificurC
and the function will stand on its own so it can be called and tested outside of an "argv context"
15:09:34
Xach_
Since macros don't evaluate their arguments like functions do, you can't use function-style tricks for reducing repetition.
15:10:21
Xach_
You have to work within the evaluation rules, or wrap them in things that expand into what you want instead.
15:13:57
xificurC
Xach_: the problem was I didn't realize that I'm trying to reduce repetition across 2 different times, run- and compile-. Novice lisper
15:18:16
xificurC
FYI I will release this code at some point so more criticism will be more than welcomed
16:11:46
jmercouris
I tried to do something like (loop for i in #*0110110001101111 do ...) but it complains
16:14:23
sjl
it's so lisp knows the kind of iteration you need at compile time, instead of having to have both code paths available and only one used at runtime
16:15:46
sjl
otherwise every IN would have to support both walking lists by CDR, and walking arrays with an index variable
19:00:25
makomo
beach: found a typo in http://metamodular.com/environments.pdf, "that the extension* incurs"
20:59:10
dxtr
Hmm, when I try to inspect an object in slime with C-c I I get: illegal sharp macro character: #\<
21:00:35
Xach
dxtr: When I want to inspect such an object, I make sure it's the most recent repl result and then inspect "*"
21:01:15
dxtr
I actually had a brain fart because it didn't dawn on me that I'm inserting expressions
21:02:42
Xach
ealfonso: not by itself. you would need something to parallelize it. i like lparallel but raw threads would work too.
21:04:30
dxtr
Xach: Speaking of parallelization; my company (Well.. I. I'm the only one coding lisp here) used your s3 library for quite a while and it was pretty heavily parallelized!
21:05:23
Xach
dxtr: so glad to hear it! i wish i had time to add to it but things have been pretty busy
21:07:59
dxtr
It's quite funny because it was actually intended to be a one-off thing - which is why I made it in lisp in the first place (Because no one else would be able to maintain it otherwise) - but it ended up being run quite heavily and it worked really well
21:09:11
dxtr
It has served its purpose now, though, so we're not using it anymore. It involved synchronizing around 150k images downloaded via HTTP, normalizing file names and stuff and uploading it to our s3 bucket. Saved us quite a bit of labor.
21:18:55
ealfonso
is there something like (nthcdr n ...) that I can combine with loop's "by" without creating a function?
21:20:21
phoe
you could theoretically (alexandria:compose #'cddddr #'cddddr #'cddddr) but that might not be the way
21:36:46
pjb
(loop for start on big-list by (lambda (x) (nthcdr n x)) while start collect (subseq start 0 (min (length start) n)))
21:39:09
pjb
you could add a variable: (loop for l = (length big-list) :then (- l n) for start on big-list by (lambda (x) (nthcdr n x)) while start collect (subseq start 0 (min l n))) ; but it would still read the big-list twice.
21:42:05
pjb
personnally, I just write: (com.informatimago.common-lisp.cesarum.sequence:group-by big-sequence n)
21:53:05
pjb
dxtr: it uses a global namespace. In the Internet age, were you get systems from anywhere, you can easily have package name collisions.
21:54:05
pjb
Local package name systems have been defined and implemented, but there are variants, and it's not integrated in all implementations yet.
21:54:44
aeth
There are several issues with the package system. (1) No portable local package nicknames and it's very easy for nicknames to conflict. (2) You will wind up with a million exports for any decently sized program, and the verbosity of it seems very unlispy. (3) There's no easy way to check for unused imports or nonexistent exports because of the dynamic nature of it.
21:55:10
aeth
(2b) That verbose million exports thing could easily also apply to imports, which is why most imports are just used with :USE instead of :IMPORT-FROM
21:56:06
aeth
pjb: I do one package per file to keep the exports down and I *still* sometimes wind up with dozens of exports for a moderately sized (400-800ish) file
21:57:05
aeth
https://gitlab.com/zombie-raptor/zombie-raptor/blob/161143c74c456393a28ccb8618d86dd42444eaf7/math/matrix.lisp#L16-61
21:57:44
dxtr
I buy the package nickname/alias argument and the unused checking. The rest is like.. If you need that many imports and exports you need that many imports and exports
21:59:28
aeth
Actually, you don't. Most of the time when you get tons of exports it's because of struct or CLOS object accessors. If you're okay with forcing the user to use with-foo-accessors (a specific version of with-accessors) you can do something like this: https://gitlab.com/zombie-raptor/zombie-raptor/blob/161143c74c456393a28ccb8618d86dd42444eaf7/util/util.lisp#L263-292
22:00:06
aeth
The only imperfection there is that it doesn't check that it's a valid accessor first. I went for simplicity of definition/implementation, at least for now
22:00:41
copec
shka_ I assume you know more than I and I would like to compare/contrast package systems
22:01:13
aeth
(with-foobar-accessors ((foo foo) (bar bar) (baz baz)) foobar ...) ; 1 export instead of 3. adds up if you have tons of structs and CLOS objects all over the place
22:01:36
aeth
Except it's really 2 exports because I also have (with-foobar-accessors* (foo (bar* bar) baz) foobar ...)
22:02:14
shka_
aeth: https://github.com/sirherrbatka/cl-data-structures/blob/e5b8bf35f906790be83b3ca99f3de1a60ce5fa3f/src/utils/macros.lisp#L299
22:02:36
aeth
Oh and my macro system supports prefixes, too. If you want safety, use one prefix for public accessors. The prefix is implicity added.
22:04:02
aeth
In case I was unclear, the accessors could be foobar-foo, foobar-bar, and foobar-baz, and the syntax would be identical in my examples above.
22:04:27
aeth
So it's not just for simpler imports/exports. I also use it internally within the same package to eliminate prefixes.
22:05:07
aeth
So I'm not sure I need to support some kind of safety to prevent people from using accessors they're not supposed to when the prefix system could work perfectly fine for that.
22:18:41
ealfonso
for the chunking issue, I used my own macro, even though sub-chunk elements are reversed https://pastebin.com/gpduRSqD
22:19:35
ealfonso
(loop-do-chunked chunk '(1 2 3 4 5 6 7) 3 (format t "chunk is ~A~%" chunk)) => chunk is (3 2 1) chunk is (6 5 4) chunk is (7)
22:20:43
dxtr
Possibly. I just want to remove a function because I accidentally made it a defun when I wanted it as a defmethod
23:10:35
dxtr
And when I try to prepare a statement it says my table doesn't exist - although I can select from it from the cli
23:26:50
pjb
Notice how you can thus define as many packages as you want, as different interfaces for different clients.
23:49:38
dxtr
Well, what I'm making a sort-of wrapper around some cl-dbi functions and I've defined my execute like (defun execute (conn query &rest parameters)) - but that fails with prepared statements that is supposed to have zero parameters
23:50:26
dxtr
But I can't just do (if parameters (dbi:execute ... parameters) (dbi:execute ...)) because I don't know if parameters actually is nil