Search
Thursday, 27th of August 2020, 2:10:15 UTC
2:58:00
beach
Good morning everyone!
3:03:08
fe[nl]ix
good morning beach
3:14:28
PuercoPop
Was there ever a proposal for packages to use symbols?
3:15:58
PuercoPop
As their mainly, although it doesn't make sense, to what package would the symbol belong to if the package doesn't exist when the form is being read
3:16:33
beach
As the name, you mean? Yes, that would be complicated indeed.
3:17:34
PuercoPop
yeah as their name (there was supposed to be name between their and mainly :v)
3:20:11
beach
One could possibly imagine a single pre-existing package that would then be the home package for all package names.
3:23:27
PuercoPop
The keyword package could do
4:37:48
dominic35
** NICK dominic34
4:41:45
Lord_of_Life_
** NICK Lord_of_Life
10:28:23
phoe
but if they're going to be from a single package, what's the real point, then?
10:28:47
phoe
then (find-package string) becomes just (find-package (find-symbol string :keyword))
10:36:20
Josh_2
with the MOP can I create a metaclass that will add slots to my class based on the slot-value of another slot?
10:51:02
Josh_2
basically I would like to have a slot within a class with a set name like 'symbol-slots' then when I (make-instance 'special-class :symbol-slots '(a b c d e)) then I will get an instance with the slots symbol-slots a b c d and e.
10:51:52
Josh_2
so the initarg :symbol-slots would be converted to effective slots and appended to my instance
10:57:14
phoe
this sounds like a method on INITIALIZE-INSTANCE that accepts :SYMBOL-SLOTS and goes CALL-NEXT-METHOD with an appropriately frobbed :DIRECT-SLOTS argument
10:57:55
phoe
like, (defmethod initialize-instance ((class special-class) &rest args &key direct-slots &a-o-k) (call-next-method ...))
10:58:16
phoe
uh I mean &key symbol-slots
10:58:32
phoe
where in ... you remove SYMBOL-SLOTS from the ARGS plist and also pass a modified DIRECT-SLOTS argument
11:00:36
Josh_2
hmm alright I'll look into that
11:00:48
Josh_2
I thought I would have to mess with make-instance
11:01:14
phoe
you don't want to mess with ALLOCATE-INSTANCE by messing with MAKE-INSTANCE
11:01:56
phoe
all you want to do is to modify the way in which the instance is initialized, by means of stuffing more direct slot definitions in there
11:02:02
phoe
(if I understand all this correctly)
11:43:56
Josh_2
okay so I have made my new effective slots that I want to append, I just don't know how to append them in make-instance
11:51:56
Josh_2
https://plaster.tymoon.eu/view/2032#2032
12:09:27
Josh_2
maybe I can use update-instance-for-redefined-class
12:15:20
Josh_2
eh says on clhs that this is not intended to be used by programmers
12:16:01
jmercouris
then you shall make a method
12:18:54
Josh_2
"The generic function update-instance-for-redefined-class is not intended to be called by programmers."
12:18:56
_death
it's not intendede to be _called_ by users
12:20:51
jmercouris
it is it the responsibility of the implementation?
12:21:10
jmercouris
who is supposed to call it?
12:21:45
_death
when you evaluate a defclass it may get called, to update instances for redefined class
12:21:51
Josh_2
It's called when classes are redefined
12:21:54
jmercouris
so the implementation will do it
12:22:54
Josh_2
but I'm trying to add new slots to an instance of a class
12:23:11
jmercouris
Josh_2: we do exactly this in Nyxt
12:23:31
jmercouris
we ended up using another class implementation
12:23:38
jmercouris
in this case hu.dwim.xyz I can't remember what comes after dwim
12:23:57
jmercouris
https://github.com/atlas-engineer/nyxt/pull/889
12:24:30
jmercouris
https://quickref.common-lisp.net/hu.dwim.defclass-star.html
12:27:52
jmercouris
ACTION throws spaghetti at Josh_2
12:30:00
Josh_2
So It's a no go with standard defclass?
12:30:27
jmercouris
it is possible, I'm just suggesting that you may wish to go another route if you will find yourself doing things like this
12:31:15
Josh_2
Well the link to their site is dead and those docs aren't exactly accessible
12:32:24
Josh_2
I was basically just messing around and seeing if I *could* do it because I thought it would be a nice way for users to interact with request objects
12:33:06
Josh_2
instead of having to look through a list they could just set/get from a slot, a slot that is dynamically added depending on some data that is passed
12:33:40
jmercouris
a slot that is dynamically added...
12:33:43
Josh_2
it was a "hmm It's 3am and I'm laying in bed thinking about this" moment
12:34:04
jmercouris
well, it is possible to update the instances
12:34:12
jmercouris
you could also copy the values to a new instance
12:34:34
_death
sounds like work for change-class to me
12:35:01
Josh_2
well the slots would have to be appended based on the value of an initarg when calling make-instance
12:35:50
_death
assuming it's something along the lines of "state pattern"
12:36:04
jmercouris
what is 'state pattern'?
12:36:18
jmercouris
Josh_2: why use slots when you may use another data structure?
12:36:26
jmercouris
why not a linked list of properties
12:36:33
Josh_2
Yes thats what I'm doing right now
12:36:35
jmercouris
UNLESS you will specialize upon these slots
12:36:45
Josh_2
to learn more about MOP really
12:36:51
_death
https://en.wikipedia.org/wiki/State_pattern
12:38:05
Josh_2
using change-class would require creating a class based on what I have parsed
12:38:30
jmercouris
then you will want to redefine the old class
12:38:36
jmercouris
that's exactly what I linked to you in my pull request
12:38:41
jmercouris
you see, we can have (foo) extend (foo)
12:39:02
jmercouris
we replace a class in-place and change its slots etc
12:39:02
_death
if the set of properties is not fixed, then just keep a plist
12:41:29
Josh_2
I'm currently just using an alist
12:41:47
Josh_2
works just fine, but now my curiosity has peaked :P
12:42:03
jmercouris
reminds me of sneak mountain
12:42:23
jmercouris
s/sneak mountain/stealth mountain
12:42:38
jmercouris
"Stealth Mountain (@StealthMountain) is a Twitter bot with a single, simple purpose: It searches for tweets in which a person has typed the words “sneak peak” when they meant to type “sneak peek,” then publishes a reply informing the author of his error. "
12:43:31
_death
if the objective is to learn about the MOP, then I remember AMOP had an example concerning dynamic slot storage
12:44:54
Josh_2
Yes I have read that example
12:45:46
Josh_2
but they have all their slots predefined but wish to only allocate slots when needed
12:47:16
_death
I see.. well, the last time I did something with the MOP was years ago, so someone else may be of help ;)
13:13:33
jmercouris
I'm having some trouble with a macro of indeterminate length
13:13:57
jmercouris
so I am trying to define a defmacro that operates on a list
13:14:03
jmercouris
let me give an example
13:14:40
jmercouris
http://dpaste.com/2SWN6VEXF
13:14:59
jmercouris
ignore "CARP" and "SALMON"
13:15:08
jmercouris
I can't get it to splice how I want
13:15:18
phoe
wait a second though, CL:LIST is predefined
13:15:39
jmercouris
well, in this case, yes
13:15:46
jmercouris
but pretend it is a list of arbitrary length
13:15:57
jmercouris
because that is in fact what it is
13:16:00
phoe
what is the call to your macro supposed to look like pre-expansion?
13:16:15
jmercouris
so you will say something like (macroxyz source)
13:16:20
jmercouris
and it will produce the expansion
13:16:47
phoe
(macroxyz (list (a nil nil) (b nil nil)))?
13:17:14
phoe
if this is a nested list, then this requires either code walking or evaluation
13:17:28
phoe
I still don't understand what you are trying to do
13:17:30
jmercouris
it is not a nested list
13:17:35
jmercouris
I'm sorry let me make a practical example
13:17:40
jmercouris
give me one more moment
13:17:43
phoe
the CL:LIST call confuses me
13:18:13
jackdaniel
you 1) did not paste the macro itself; 2) you did not state the problem correctly
13:18:23
jackdaniel
what is it you want to splice? how does it splice?
13:18:35
jackdaniel
how do you want it to be spliced
13:18:51
phoe
let's get the communication done first and then let's discuss things
13:18:51
jackdaniel
ACTION points out that there was no answerable question stated
13:20:03
jackdaniel
and it is quite surprising given that a considerable wall of text has been written ,)
13:20:16
jmercouris
you know what is surprising to me?
13:20:21
jmercouris
how socially insensitive you are
13:20:34
phoe
heyyyyyyy jmercouris jackdaniel
13:20:37
jackdaniel
please do not attack me presonally, it is a last warning
13:21:10
phoe
calm down both of you, will you?
13:21:27
phoe
stirring this further will bring no good to either of you or to #lisp, and right now it's both of you stirring this up
13:22:33
jackdaniel
phoe: hm, I consider myself perfectly calm, what i'm saying is that he should state a question which could be reasoned about (i.e correctly state the problem), not really sure how is this stirring things
13:23:05
jackdaniel
as of personal attacks, I'm sure it is a reasonable thing to ask to not to that
13:23:46
jmercouris
phoe: http://dpaste.com/GWRE38XLJ
13:23:53
jmercouris
I hope that explains my context a little bit better
13:24:28
jmercouris
actually I do not need the gensym...
13:24:48
jmercouris
I've rewritten and destroyed the macro several times, still not able to achieve what I am trying to...
13:25:31
phoe
okay, so the macro itself is QRT
13:25:59
jmercouris
and in execute-extended-command it would be applying like this: (qrt optional-arguments)
13:26:03
phoe
is it called like (qrt a b c)?
13:27:08
phoe
if these come from the DEFINE-COMMAND lambda list, you might want to use ALEXANDRIA:PARSE-ORDINARY-LAMBDA-LIST to get the required/optional/keyword/whatever arguments and such
13:27:08
jmercouris
the ,@operator is really messing with me
13:27:19
jmercouris
phoe: I am using that
13:27:32
jmercouris
I have just nicknamed it to alex
13:27:35
phoe
let's consider QRT to be a function for a while
13:28:33
jackdaniel
`(with-result* ,(mapcar (lambda (arg) `(,arg (read-from-minibuffer))) symbols))
13:28:46
jmercouris
I was afraid of the double backquote
13:29:01
jmercouris
that is another thing I do not understand
13:29:13
jackdaniel
(let ((clauses (mapcar …))) `(with-result* ,clauses))
13:30:38
phoe
https://plaster.tymoon.eu/view/2033#2033
13:30:51
phoe
I absolutely despise double backquote and avoid it wherever I can
13:31:33
jmercouris
let me try to understand this one second
13:32:05
jmercouris
OK so you've made two functions here in an flet
13:32:11
jmercouris
and these functions return some code
13:32:26
jmercouris
the first one returns a minibuffer creation and binding
13:32:43
jmercouris
the second one returns a form that prints
13:32:46
phoe
I've added the macroexpansion
13:32:56
phoe
yes - there are two parts that need to be generated based on the arglist
13:33:00
phoe
the first - the binding forms
13:33:03
phoe
the second - the body forms
13:33:20
phoe
these do not depend on each other so we can generate those separately via mapcar, just like jackdaniel mentioned earlier
13:33:38
jmercouris
OK and then finally you have the actual function %qrt which basically wraps everything in with-result
13:33:39
phoe
my code is just somewhat more verbose to avoid double backquote and make explicit separation of concerns
13:33:52
jmercouris
I actually understand this
13:33:57
jmercouris
I wonder if I can use this pattern elsewhere
13:34:05
phoe
yes, the actual body of %qrt generates the full form and splices in the results of subfunctions
13:34:06
jmercouris
alright, so I described a very abstract problem, not my actual problem
13:34:10
phoe
likely you can use this pattern elsewhere
13:34:12
jmercouris
let me see if I can apply your methods
13:34:16
jmercouris
to my actual problem
13:34:21
jmercouris
that will be the real test of if I understand
13:34:29
phoe
the macros inside portable-condition-system are all done in this way
13:34:44
jmercouris
thanks for the example
13:34:52
phoe
(mostly in hope that this technique is somewhat easy to grok and understand and then repeat and reuse)
13:35:07
jmercouris
I like the idea of seperate functions to emit snippets
13:35:09
phoe
(so, in a way, you're my experimental animal)
13:35:36
phoe
I mean, you could probably read the PCS source if you want more examples of this macro style
13:36:06
jmercouris
so what is the purpose of using a separate defun and defmacro?
13:36:08
phoe
except there I use global functions instead of local ones for even more verbosity and ease of REPL-based testing and twiddling
13:36:19
jmercouris
just to prove that a defmacro body is not special?
13:36:30
phoe
except for the ability to call (%qrt 'a 'b 'c)
13:36:38
phoe
instead of (macroexpand-1 '(qrt a b c))
13:37:13
phoe
you can get rid of the intermediate function and stuff its body inside the macro, and things will work.
13:38:10
phoe
and inside https://github.com/phoe/portable-condition-system/tree/master/src the files of interest are assertions.lisp, handlers.lisp, restarts.lisp
13:38:15
phoe
these are the macro-heaviest
13:38:34
phoe
oh, and define-condition inside conditions.lisp
13:38:54
phoe
even though that one is really boring except for report methods, because it expands into DEFCLASS :D
13:42:37
jmercouris
also, above you meant (macroexpand-1 '(qrt (a b c)))
13:42:54
phoe
because I was sneaky and modified the macro lambda list
13:43:03
phoe
but I didn't tell you about that fact
13:51:30
phoe
anyway, I think this is how such situations should be handled - in case of not enough information or a poorly specified problem, 1) please ask for more details instead of stating the obvious, 2) please provide more details even if the obvious was stated
13:51:59
jmercouris
it was a poorly defined problem, because I didn't understand it
13:53:03
phoe
truth be told, this might have ended with a firestorm, some banhammering, and overall bad smell on #lisp if I weren't here to calm things down a bit
13:53:10
phoe
and I absolutely *DON'T* want to need to say such things
13:53:22
phoe
cmon, let's just be excellent to one another.
13:53:30
phoe
ACTION afk for real life things
Thursday, 27th of August 2020, 14:10:15 UTC