freenode/#lisp - IRC Chatlog
Search
10:51:40
Xach
jmercouris: You write nonsense and don't seem to be able to accept correction. I don't want to expose that to a wider audience.
10:54:54
Xach
Or rather, I don't want to actively help expose it - it can get plenty of exposure through many other means without my assistance.
11:27:44
Nilby
The things in https://nyxt.atlas.engineer/articles don't trigger my lisp nonsense meter very strongly. Is there something I'm missing?
11:28:58
Xach
I skimmed through the non-marketing articles for Lisp info - one of the first that jumped out says "closer-mop is not portable"
11:29:54
Xach
It's certainly possible that closer-mop is unsuitable for some reason but portability is a goal and if it falls short some context would be useful.
11:34:56
jackdaniel
portability libraries are not "universally" portable by definition, because their purpose is to span multiple implementations (so each implementation is special-cased)
11:35:45
jackdaniel
still, they are far more portable than implementation-specific package; also they usually leave door open for adding support for new implementations by providing convenient api
11:58:34
jmercouris
here is the context: "We first tried to set the slot default value directly by leveraging the introspection library closer-mop. It worked with the SBCL compiler but was not portable and very brittle, it was particularly difficult to handle inheritance correctly."
12:02:25
jmercouris
jackdaniel: interesting how you didn't make a comment when Xach said that I just "spew nonsense", apparently, not a personal attack?
12:04:12
cl-arthur
how did you try to use closer-mop to set the default values of the slots? Isn't setting the default values as easy as supplying a :initform or some :default-initargs?
12:04:32
jmercouris
cl-arthur: it is about taking a class that exists, and changing the default value
12:04:40
jackdaniel
putting my opinion aside, the former was explanation why he refuses to included what you write (i.e "because it is a nonsense"), the above otoh is ad hominem kind of argumentation
12:07:47
jmercouris
See through your bias, and see what you've written is false, he did not say my writing was nonsense, he said I write nonsense
12:08:15
jmercouris
We've had this exact discussion many times, where you point out the difference between the noun and the verb
12:09:38
jackdaniel
if you want to customize the initform, you are looking for the generic function slot-definition-initform
12:10:24
jackdaniel
s/customize the initform/customize the form used to initialize the slot when no initarg is supplied/
12:18:39
cl-arthur
should be possible to e.g. setf the initform/initfunction of the existent slots of an existent class appropriately when loading a config, yeah
12:21:14
jackdaniel
cl-arthur: afaik it is not an accessor (only a reader), so you can't effectively setf it and expect that make instance will work
12:21:24
Nilby
Is there some accepted way or library for user object configuration/customization? I know about Shinmera's ubiquitous, but it's a little diffrent goals. I have a couple of ways that I'm not statisfied with. How does CLIM handle it? It seems like anything in CL must be better than "custom" in Emacs.
12:22:50
jackdaniel
(also, changing a method a standard slot definition won't probably have an effect, one would need to have their own slot definition class)
12:26:09
scymtym
Nilby: i made https://github.com/scymtym/configuration.options which has a moderately flexible core but is a bit biased towards configuration via files, environment variables and commandline options. i think i made a CLIM-based configuration editor for it, but there would be no way to persist the changes, so that's only semi-useful
12:30:01
jackdaniel
jmercouris: one way to do that (and it will /probably/ work) is: http://turtleware.eu/static/paste/3094e785-zzz.txt
12:38:33
jackdaniel
or, you could return some function that is global and is properly redefined (that is that after redefinition it is eq to itself - i.e a generic function)
12:45:35
cl-arthur
or metaclass -> slot-definition subclass w/ config-value as extra slot -> populate those when loading config -> make a method on slot-definition-initfunction like (if (config-value ...) (wrap-config-value ...) (call-next-method)).
12:46:27
jackdaniel
yes, having a custom effective slot definition class is the way, that's why I've said "probably"
12:47:54
jmercouris
we’ve already committed to a different strategy for now, but maybe some of these concepts could be useful again for us
12:49:07
jackdaniel
if I had wanted to customize a new instance slot values, I'd simply write initialize-instance method, there is no need to use mop here
12:49:55
jackdaniel
(defmethod initialize-instance :after ((thing foo) &rest args) (setf (slot-value thing 'x) *my-new-default-value*))
12:53:13
cl-arthur
a global map from class/slotd to config values, and some initialization method specialized on a mixin also seems decently clean yeah
12:55:13
jackdaniel
hm, til you could put a form as a default-initarg, however it is not surprising after a thought, so scratch the part "if it is a value, not a form"
14:35:48
jmercouris
globals, and we wanted to actually change the classes themselves so that inspecting them would show new default value init forms
14:37:19
_death
from what I gathered it sounds like you wanted to avoid something like "factory method" and instead chose to redefine classes?
14:51:05
_death
by "factory method" I mean you could have something like a *configuration* special variable that a user sets to (make-instance 'my-configuration ...) and then there are methods like (defmethod config-create-buffer ((config my-configuration) &rest args) (apply #'make-instance 'my-buffer args)) and possibly a convenience function create-buffer that passes *configuration* to config-create-buffer
14:59:42
jackdaniel
the most portable way to change the initform (and the associated function) is to redefine the class, common lisp has your back and that operation has well-defined semantics (i.e your instances won't stop working etc)
15:10:10
cl-arthur
That reminds me - what's the cleanest way to invoke a macro at runtime? Any better option than giving a list-representation of the macro form to eval/compile?
15:11:18
beach
Or (funcall (macro-function 'foo) <form> <environment>) if for some reason you don't want to use macroexpand.
15:11:23
phoe
a macro function is a standard function that translates from Lisp data to Lisp forms; you can call this function it by calling MACROEXPAND{,-1}
15:11:28
jackdaniel
if you need to expand the code at runtime, then eval is /the/ way (another is to rethink design, it is usually some misconception about your own program)
15:12:32
jackdaniel
also, if you have a macro that takes a few parameters and a body to create a context, you may consider creating macros in a style that it expands into a funcall that passes a continuation
15:13:16
jackdaniel
i.e (defmacro foo (x &body body) `(flet ((,gensymed () ,@body)) (invoke-with-foo x (function ,gensymed))))
15:13:23
_death
beach: wouldn't first class environments also make sense in that configuration scenario?
15:13:58
jackdaniel
_death: wouldn't there be two different classes then? I think that would be undesireable
15:16:40
_death
jackdaniel: I'm suggesting a user create his own class that inherits from the default class (or some subclass of it)
15:18:29
jackdaniel
unless you want to have two classes designated by the same symbol in different environments
15:18:53
cl-arthur
"invoke" - expand the macro form and execute the results. Yeah, seems to be eval.
15:18:53
_death
jackdaniel: so in E1 there'll be a buffer class, and in E2 there will be a different buffer class that inherits from e1:buffer.. then (make-instance 'buffer) can be used
15:20:01
_death
jackdaniel: exactly.. because from reading jmercouris's article, it sounds like they go through all that trouble just so they can say (make-instance 'user-buffer)
15:20:08
cl-arthur
I've seen some (funcall `(lambda () (some-macro ...)) which incidentally work in certain implementations but just hide the eval-iness, I suppose.
15:20:24
jackdaniel
I think that this could be done, however I would argue that packages are much better fit (and of course all other ways we've discussed)
15:21:23
phoe
both are ways to sidestep eval at runtime, and are mostly equivalent to eval at runtime except they can form closures
15:21:24
_death
jackdaniel: packages always seemed a clunky way to do that.. you can't even redefine them
15:22:24
jackdaniel
perhaps, either way thanks for elaborating, now I understand better what you've meant
15:22:38
cl-arthur
jackdaniel: Agree that creating function seams to expand to when possible is nice. (invoke-with-foo)
15:25:12
jackdaniel
cl-arthur: it may be event easily automated, you may check out a function gen-invoke-trampoline in climi package (McCLIM repository)
15:31:02
_death
redefining classes is setting globals.. whereas with my "factory method" approach there is a single global that determines everything
15:31:57
_death
(so it's likely you don't want to set it directly, but call a function that can have hooks etc.)
20:15:26
_death
jmercouris: if you're referring to my paste, I didn't intend it as a solution to your issue
22:24:44
dbotton_
is there a squeak/pharo like x-platfrom graphical environment available for common lisp? in some ways portacle/emas (sans graphics) fills that niche but even so