freenode/#lisp - IRC Chatlog
Search
21:51:29
makomo
just when i thought i ran into an ""issue"" with its property resolvers, edi has already thought of it https://edicl.github.io/cl-ppcre/#*property-resolver*
21:53:22
makomo
my usage was (let ((cl-ppcre:*property-resolver* ...)) (ppcre:scan <string> <string>))
21:55:38
makomo
also, a very cool late night regex trick: splitting using zero-width positive lookaheads -- use the regex "(?=<delimiter>)"
21:57:17
makomo
the cool thing is that you can use literally any regex for <delimiter>, including stuff like character properties. that way you can split on uppercase letters and such, without removing them
22:46:00
didi
What is the rationale for REDUCE calling FUNCTION with no arguments? I understand the situation (no initial value and empty sequence), but I've never encountered a situation where I wanted it to happen.
22:48:12
pjb
(defun cons* (&optional (a nil ap) d) (if ap (cons a d) '())) (reduce (function cons*) '(1 2 3 4)) #| --> (((1 . 2) . 3) . 4) |#
22:49:14
pjb
(defun cons* (&optional (a nil ap) d) (if ap (cons a d) 'ha)) (reduce (function cons*) '()) #| --> ha |#
22:49:56
pjb
didi: basically, the function without argument returns the neutral element for the operation, so that reduce can return something meaningful when you call it with an empty list and no :initial-value argument.
22:50:37
didi
pjb: I usually put the "neutral element" on :INITIAL-VALUE. Maybe I should rethink it.
22:50:40
pjb
Unfortunately, the function is not called with a singleton: (reduce (function cons*) '(1)) #| --> 1 |#
22:51:57
pjb
didi: as you can see, there's a semantic difference between the neutral element and :initial-value.
22:52:36
pjb
didi: yes. But the same differences exist with them: (reduce '+ '(0 0) :initial-value 42) #| --> 42 |# (reduce '+ '()) #| --> 0 |#
22:54:04
pjb
Then you can have any function and any list, and the function can take 2 mandatory arguments.
23:00:40
didi
I guess by always passing the neutral element to :initial-value I betray the black box that should be FUNCTION.
23:02:39
pjb
reduce should call (funcall f) always (funcall f (first list) (funcall f initial-value (funcall f()))) …
2:23:32
moldybits
is it possible for a method to specialize on two different types for the same argument? ie, that it has to be a subtype of both types specified, to be considered a match.
2:30:49
Bike
ofc you can just define a new class that has both as superclasses, and have your actual class be a subclass of that one
2:31:30
White_Flame
note to self: do not recompile with unfinished code (defparameter *tags* (loop ))
2:33:23
aeth
moldybits: If you must dispatch on types instead of classes, you can use a library like specialization-store, but this dispatch will be slower than even method dispatch is unless it can be inlined. https://github.com/markcox80/specialization-store/
2:33:58
aeth
There might be a few other ways to do it, other than the obvious manual way of having a function with a TYPECASE in it.
2:34:28
White_Flame
or the obvious manual way of having 2 defmethods which call the same shared function
2:36:24
aeth
White_Flame: That's an interesting idea for how to implement this behavior in a define-method extension to defmethod. Perhaps inlining that function.
2:36:38
aeth
White_Flame: Of course, perhaps the proper way to do define-method is to heavily MOP it.
2:44:10
moldybits
the method is object-open and the argument is an instance of door inhereting from object, openable-mixin, and lockable-mixin
2:46:49
moldybits
the problem is when something is lockable but not openable. the object-open method specializing on lockable-mixin will still match
3:06:51
moldybits
i probably shouldn't have lockable and openable be mixins. they could go into a list as properties.
3:07:48
moldybits
either i could have a lock in a list of properties, or i could have a locked-p slot, and check for the existence of that slot. hm.
3:07:50
aeth
moldybits: wouldn't (subtypep (type-of o) 'lockable-mixin) also work like this? (typep o 'lockable-mixin)
3:08:35
aeth
If that works (not sure) then you can just use typecase, and even though that will nest in more conditions, it could potentially be more efficient.
3:11:40
moldybits
i'm slowly reading through Keene's OOP in CL book, and i wanted to try applying CLOS to a text game.
3:11:46
aeth
moldybits: I wouldn't use slot-value... accessors are a better in just about every way afaik, including performance, surprisingly.
3:13:38
moldybits
hm. there are so many ways of implementing this, and i'm having trouble weighing them against each other.
3:14:17
aeth
moldybits: If you're always going to call SAY, I would have one SAY at the bottom and build it at the top. You can do this with multiple-value-binds and values. So (multiple-value-bind (status text) ...) and e.g. inside the conditional (values :success "opened ~A")
3:15:14
aeth
Then you'd just have one (say status text o) at the bottom and the flow is a lot cleaner
3:15:37
aeth
Combine that with with-accessors instead of slot-value and the function should be a lot more readable imo
3:17:09
aeth
Using lots of internal bindings also has the advantage that you can easily spin off helper functions if the function grows too big
5:12:52
beach
jackdaniel: Maybe databases don't have to imply copying. But it seems to me that current technology requres it.
5:34:37
no-defun-allowed
I found a very nice "dictionary" entry on the topic of business objects. It seems to be some kind of way to generate reports without having to know the internal structure of a database?
5:35:21
no-defun-allowed
Or, rather, it's a system of representing orders and reports as objects somehow. Never mind, I don't understand that either.
5:37:47
no-defun-allowed
Scrolling back, I don't think it would be legal to use the source code if it was reachable from inside the environment, especially for developing competing products.
6:35:27
beach
liangchao: This channel is dedicated to Common Lisp, so that's the only dialect discussed here.
6:57:33
loke
The only reasonable way forward if _I_ want to help that happen, is to implement a GTK+ backend (since GTK+ works on Windows). I am not going to do any Windows development.
6:59:21
loke
However, proper native integration would be slightly harder. For example, font management can't use the operating-system provided rendering engine (SDL has its own). Also things like cut&paste will not work as well.
7:00:01
loke
If I use GTK+, then the graphics rendering will be implemented by Cairo, which is _very_ nice.
7:04:31
splittist
Extensive commentary on the process of writing a backend would make subsequent backends easier and, therefore, more likely. (Since there is no consensus on the 'best' gui library.)
8:41:17
White_Flame
how do you fiddle negatives? first test the high bit then do an optional subtraction?
8:42:16
shka__
White_Flame: take the high bit from the integer, dpb into result, take other bits, dpb into result
8:44:26
White_Flame
there's some fancy-pants C code that can do it for a fixed register width, but CL doesn't have that notion
8:45:16
White_Flame
I mean, the naive transformation is pretty straightforward, but as this is in the middle of an emulator, I'd want it to be pretty fast if possible
8:47:25
White_Flame
I do have a ffi union that casts between float, double, signed & unsigned ints, char array, etc that I use for float conversions, but the code ends up being surprisingly large
8:48:00
White_Flame
that needs to be treated as a signed 10-bit number, resulting in that numeric interpretation
8:48:27
White_Flame
erm, wait, I'm shooting off the cuff a bit quick. For a 10-bit value, it's -512 to +511 I guess
8:50:16
White_Flame
I'll play with it, just curious if there was some well-known algorithm for non-fixed-width values