Search
Thursday, 27th of August 2020, 0:40:03 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
Thursday, 27th of August 2020, 12:40:03 UTC