freenode/#lisp - IRC Chatlog
Search
16:53:10
jmercouris
I don't want to make two systems, I want to be able to specify some flag or option somewhere
16:56:45
jmercouris
I remember something someone said about a year ago on this topic ,but I can't find it
17:06:50
p_l
there was also at one time "ASDF-system-connections" that provided conditionals based on presence of other ASDF systems
18:51:31
jcowan
Does SBCL provide a compact format for (vector boolean), or is it better to use (vector bit) and a few shim macros?
19:27:39
Bike
i was going to say that might trip the u-a-e-t rules but i guess it's "okay" as long as you have nil arrays
19:33:04
Josh_2
I do love it when I'm typing a question to ask for help on a problem I've had for the last hour and I figure it out :P
19:38:03
aeth
And shouldn't they work because they're "immutable"? In the sense that you can't unintern them, etc.. Sure, you can symbol plist them or whatever.
19:38:22
hjudt_
a question about :around methods: i use an around method to track the time a method takes. in this around method, i do not use the multiple values that the method returns. do i need to capture these multiple values and return them in the around method in this case or not?
19:41:33
hjudt_
in the keene book (Object-Oriented Programming in Common Lisp) they say "It is customary but not required for around-methods to return the value or values of call-next-method."
19:41:55
pjb
Bike: it's only an internal optimization. aref would still return a boolean, ie. either cl:t or cl:nil.
19:42:30
hjudt_
so is it really that customary? in my case, it is only causing more lines of code and further indentation.
19:43:06
pjb
Bike: and (upgraded-array-element-type 'boolean) -> boolean doesn't break any rule AFAICS.
19:43:45
pjb
hjudt_: it's not a more lines of code. It's whether you want to return the same value or not!
19:43:59
Xach
hjudt_: it is customary in the sense that that is the typical default behavior, but returning some other value is not explicitly forbidden. some value must be returned.
19:44:12
pjb
hjudt_: for example, you could have a around method weight that adds a tare to the weight returned by the main method.
19:45:05
Bike
like, if the method you're wrapping will always return exactly one value, you don't need to worry about it
19:45:43
Bike
and then have to be like "hey, how come when i enable the profiling method my code stops working?", which is never a good bug to have
19:46:59
Xach
hjudt_: (let ((start (timestamp))) (multiple-value-prog1 (call-next-method) (record-timing start))))))) maybe?
19:47:18
aeth
pjb: Afaik, a wrapper could only potentially break rules if you could unintern the symbol like (let ((foo (vector 'a 'b 'c))) (unintern 'a) foo) => #(#:A B C) because now any new 'a won't be EQ (or any form of equal) to the old 'a, now just an #:A
19:48:36
aeth
pjb: well, yes, conceptually it could also just be an array storing the actual symbols themselves, even though then it would probably be 64x larger in memory
19:49:48
pjb
aeth: (defun aref (array &rest indicies) (if (eq (array-element-type array) 'boolean) (if (zerop (apply (function aref) (%array-internal-bitvector array) indicies)) 'nil 't) (%internal-aref array indicies)))
19:50:06
hjudt_
yes, i simply want to return the values that (call-next-method) returns. i do not want to alter or enhance the results in the around method. that is, the behaviour should not be changed, and i probably will not care what the around method does because it's only purpose is to set some times on other fields. so if i leave it as is and do not capture the multiple values, would that be ok?
19:51:01
Xach
hjudt_: you don't have to capture them if you return them in some other way. but the return value of the :around method is the return value of the GF. there is no other mechanism to get the "inner" value.
19:51:53
pjb
hjudt_: then either call-next-method is a terminal call, or you need to save the values and return them.
19:53:12
hjudt_
pjb: ok, so i _need_ to capture the values and return them. because if it was a terminal call, i could also have used a :before method.
20:00:48
hjudt_
anyway, i tried it now with a small example, and have ascertained that i _need_ to capture the return values in the around method, otherwise the values of the :around method itself will be returned.
20:02:29
hjudt_
i was confused by the statement in the book that "it is customary but not required."
20:03:00
Bike
I mean: how :around works is that the values of the :around method are always returned
20:03:19
Bike
those values could be the same as the values returned by an inner method, though, and usually are, but you have to write the :around method in such a way that that is accomplished
20:03:57
hjudt_
Bike: if i think about it a bit more, it makes sense because otherwise there was no way to return other values from :around.
20:04:37
Bike
plus otherwise the generic function machinery itself would have to keep track of the return values, which might take consing, which would be kind of a silly reason to cons
20:16:11
hjudt_
i like this elegant way of using an around method, it makes that code smaller and more easily comprehensible.
20:25:03
flip214
hjudt_: if you use SBCL, you could also look at TRACE to get a kind-of around method... or just use (sb-profile:profile function) ;)
20:27:26
flip214
hjudt_: http://www.sbcl.org/manual/#Deterministic-Profiler, http://www.sbcl.org/manual/#Function-Tracing
20:39:18
hjudt_
flip214: thanks. in my case, i really need the around method to be part of the program, not only for profiling. i track the durations an action takes and present it in the web ui. but your hint will make me read up on these sbcl features ;-)
21:46:10
Bike
did you think that it wouldn't change the functionality? could you describe what you think lambda does?
21:50:25
Bike
Your repl is weird. Why is it printing numbers like emacs does? Where's the NIL coming from?
21:52:21
pjb
Also, when you redefine a macro, you need to recompile and reload all the functions that use it.
21:53:19
Bike
Could you show the entire session? Like the part where you define the functions and macro as well?
22:02:16
Josh_2
Well anyway I have another issue along the same lines https://plaster.tymoon.eu/view/1722#1722
22:03:57
Josh_2
The form is printed fine, but when funcalled with 2 as the argument, instead of throwing an error it returns the value of byte
22:09:11
Josh_2
I do not understand why a condition is not signalled. in the example I sent byte is 1 not 2..
22:16:24
pjb
Josh_2: nope, this is not the error one gets: https://termbin.com/38mq You are using an undefined operator tlet, which leads to this error!
22:25:19
pjb
Well, it's not easy. You are wanting to build a form at run-time, and get it evaluated in a lexical scope. This is not possible directly in CL.
22:26:25
pjb
But you can keep susbtituting, because the lexical scope is known to you, at program editing time. SO you can write the code that will substitute, not with 'byte, but with the value of byte!
22:27:53
pjb
Now, if you prefer, you may generate a lambda-expression, and use eval coerce or compile to get a function.
22:29:03
pjb
But it won't be a closure. you must substitute into the lambda-expression all the values you need.
22:29:53
pjb
Now, since your function is named generate-<something> I would let it return the lambda-expression, and call eval, coerce or compile outside of it.
0:20:41
Bike
you could wrap the repl with a muffler, i guess, but i don't think slime has that as an option
0:28:43
amazoniantoad
I am new to lisp. This is my partners code in an assignment. I'm just trying to suppress this warning
0:32:26
Bike
well, i'm going to guess here, but wherever the (ignore arg1 arg2) line is, try replacing that with (cl:ignore arg1 arg2)