anticomputer_ has quit [Remote host closed the connection]
azimut has joined #commonlisp
Lycurgus has joined #commonlisp
jeosol has joined #commonlisp
random-nick has quit [Ping timeout: 268 seconds]
Lycurgus has quit [Quit: Exeunt: personae.ai-integration.biz]
son0p has joined #commonlisp
NotThatRPG has joined #commonlisp
brettgilio has joined #commonlisp
attila_lendvai_ has quit [Ping timeout: 256 seconds]
anticomputer has quit [Remote host closed the connection]
anticomputer has joined #commonlisp
azimut has quit [Ping timeout: 255 seconds]
azimut has joined #commonlisp
akoana has quit [Quit: leaving]
tyson2 has quit [Remote host closed the connection]
jeffrey has quit [Ping timeout: 252 seconds]
<NotThatRPG>
For a lazy person, anyone have a reader macro that reads the following s-expression into a particular package? Put differently, that replaces the source expression with the results of calling a (constant) function on the expression? I can figure this out, but... lazy
<fe[nl]ix>
NotThatRPG: SBCL has that built-in, FWIW
<NotThatRPG>
fe[nl]ix: If you mean <package-name>::<s-expression> yes, and Allegro has it as well. Unfortunately, CCL does not appear to.
<fe[nl]ix>
asdf::'(foo)
ec has quit [Ping timeout: 255 seconds]
ec_ has joined #commonlisp
<NotThatRPG>
So I was looking for a portable solution that would let me write, for example #F'(foo) and work everywhere (that I care about)
nij- has joined #commonlisp
<nij->
Any de facto package for deep copying?
cercopith has joined #commonlisp
ec_ has quit [Ping timeout: 255 seconds]
ec_ has joined #commonlisp
<NotThatRPG>
nij-: Not as far as I know. In general CLOS is too flexible to permit automatically building a copy method.
NotThatRPG is now known as NotThatRPG_away
<hayley>
I recall someone linking Pitman before, so I'll refrain from linking it again.
<nij->
Hmm...
<nij->
Pitman has a blogpost about it.
<nij->
But I don't recall an actual package.
<hayley>
Pitman explains why it can't be done "generally", I believe.
<nij->
Hmm.. I wonder how the immutable data structures are done. There, I believe things could be copied.
<nij->
Oh.. maybe they don't even have to copy things.
waleee has quit [Ping timeout: 260 seconds]
enzuru has quit [Ping timeout: 255 seconds]
Josh_2 has quit [Ping timeout: 268 seconds]
thoughtron has joined #commonlisp
Lycurgus has joined #commonlisp
Lycurgus has quit [Quit: Exeunt: personae.ai-integration.biz]
aartaka has joined #commonlisp
rgherdt has joined #commonlisp
anticomputer has quit [Ping timeout: 255 seconds]
anticomputer has joined #commonlisp
aartaka has quit [Ping timeout: 256 seconds]
aartaka has joined #commonlisp
aartaka has quit [Ping timeout: 268 seconds]
aartaka has joined #commonlisp
frgo has quit [Ping timeout: 256 seconds]
genpaku has quit [Remote host closed the connection]
genpaku has joined #commonlisp
ec_ has quit [Ping timeout: 255 seconds]
cage has joined #commonlisp
ec_ has joined #commonlisp
Lycurgus has joined #commonlisp
MajorBiscuit has joined #commonlisp
rainthree has joined #commonlisp
ec_ has quit [Remote host closed the connection]
ec_ has joined #commonlisp
Lycurgus has quit [Quit: Exeunt: personae.ai-integration.biz]
seletz has quit [Ping timeout: 256 seconds]
pve has joined #commonlisp
shka has joined #commonlisp
ttree has quit [Ping timeout: 256 seconds]
aartaka has quit [Ping timeout: 256 seconds]
seletz has joined #commonlisp
aartaka has joined #commonlisp
aartaka has quit [Ping timeout: 252 seconds]
aartaka has joined #commonlisp
torhex-pasmul[m] has quit [Quit: You have been kicked for being idle]
azimut has quit [Ping timeout: 255 seconds]
White_Flame has quit [Quit: No Ping reply in 180 seconds.]
aartaka has quit [Ping timeout: 246 seconds]
White_Flame has joined #commonlisp
pranavats has left #commonlisp [Error from remote client]
aartaka has joined #commonlisp
aartaka has quit [Ping timeout: 272 seconds]
MajorBiscuit has quit [Ping timeout: 272 seconds]
aartaka has joined #commonlisp
aartaka has quit [Ping timeout: 272 seconds]
aartaka has joined #commonlisp
<AadVersteden[m]>
I have a misunderstanding with respect to types. I generate a type through a macro which yields something like: (progn (defun #:gensym-123 (thing) (some-test thing)) (let ((type-spec '(and hash-table (satisfies #:gensym-123)))) (deftype my-type () type-spec)) ;; this sometimes indicates the gensymed function is undefined.
<AadVersteden[m]>
What silly thing am I missing? I'm trying to create a dynamic satisfies function through some abstraction so I can better defined a typed list, a typed hash table, and similar.
Cymew has joined #commonlisp
<AadVersteden[m]>
Perhaps to add, satisfies takes a predicate-name, which must be a symbol whose global function definition is a one-argument predicate. It is not allowed to use a lambda expression there.
<phoe>
are the two gensyms EQ to one another? I assume they are because this code is generated
<AadVersteden[m]>
phoe: tehy come from the same gensym
<phoe>
maybe it's an issue with externalization; if you dump this into a FASL and then reload, the gensyms are allowed to no longer be EQ
aartaka has quit [Ping timeout: 265 seconds]
<AadVersteden[m]>
phoe: within the same progn, the gensym used in the defun and in the deftype could be different after FASL loading? Wouldn't that lead to many issues with macros in general?
aartaka has joined #commonlisp
<phoe>
I'm looking into CLHS, maybe I remember wrong
<phoe>
something in clhs 3.2.4 maybe
<phoe>
IIRC
<AadVersteden[m]>
Perhaps it doesn't go haywire within the definition, but rather later when the deftype is assigned. That (to my understanding) expands the type definition, which means it reuses the symbol in a different context.
<phoe>
in what context does the error occur?
Cymew has quit [Ping timeout: 256 seconds]
<AadVersteden[m]>
When trying to evaluate the satisfies clause at runtime.
<AadVersteden[m]>
Though 3.2.4.2.2 says Two apparently uninterned symbols S and C are similar if their names are similar.
<phoe>
I have a file containing (progn (defun #1=#:foo (thing) (declare (ignore thing)) t) (deftype my-type () '(and hash-table (satisfies #1#))))
<AadVersteden[m]>
But I always need to read the hyperspec a few times.
<phoe>
I compiled it into a fasl, I restarted lisp, I loaded that fasl
<phoe>
(typep (make-hash-table) 'my-type) seems to work
Lord_of_Life has quit [Ping timeout: 256 seconds]
<AadVersteden[m]>
I have this in a separate file but it failed beforehand too when re-evaluating the declamation of an ftype
Lord_of_Life has joined #commonlisp
<phoe>
still seems kinda vague, too vague to be a decent reproducer
<AadVersteden[m]>
I'll share links to the effective code, though I was experimenting so maybe not great either.
<AadVersteden[m]>
I get better (erroring) results by interning though. So good shot it's something like that. Also: it has worked this way but failed when re-evaluating the file.
<phoe>
oh, hm
<pjb>
AadVersteden[m]: you need to define the function at compilation-time. Use eval-when in the macro expansion.
<phoe>
maybe the type redefinition has caused some problems
<AadVersteden[m]>
pjb: okay! I know how to do this, but could you explain how I should discover that, and should it only be evaluated at compilation then?
<ixelp>
sparql-parser/support.lisp at master · mu-semtech/sparql-parser · GitHub
<pjb>
AadVersteden[m]: you will probably need the type also at run-time, so better define the function in all situations.
<AadVersteden[m]>
(progn (eval-when (...) (defun ,symbol ...)) is legal, right?
<pjb>
definitely.
<phoe>
yes, a toplevel PROGN of forms is a PROGN of toplevel forms
epony has quit [Read error: Connection reset by peer]
<AadVersteden[m]>
Hmm, it still indicates it's an undefined function
<phoe>
I wish I had a reproducer
<AadVersteden[m]>
You are right phoe , I should take a moment to pause and try to reproduce in a silly example. This larger code-base does not help much in debugging.
MajorBiscuit has joined #commonlisp
<AadVersteden[m]>
Thank you
pranavats has joined #commonlisp
easye has quit [Remote host closed the connection]
easye has joined #commonlisp
<pjb>
AadVersteden[m]: did you put the deftype in the progn, but outside the eval-when. You should do that.
aartaka has quit [Ping timeout: 272 seconds]
scymtym has quit [Ping timeout: 256 seconds]
Brucio-61 has quit [Ping timeout: 260 seconds]
aartaka has joined #commonlisp
<AadVersteden[m]>
yup
_cymew_ has joined #commonlisp
thuna` has joined #commonlisp
pranavats has left #commonlisp [Error from remote client]
Brucio-61 has joined #commonlisp
scymtym has joined #commonlisp
azimut has joined #commonlisp
rainthree has quit [Read error: Connection reset by peer]
frgo has joined #commonlisp
attila_lendvai_ has joined #commonlisp
azimut has quit [Ping timeout: 255 seconds]
azimut has joined #commonlisp
<AadVersteden[m]>
Didn't make a minimal test-case yet, but I did notice that each time typed-list is called (a function that does a macro expansion and creates one of the symbols), it creates a symbol with the same number.
<AadVersteden[m]>
ie: #:typed-list-test0
<AadVersteden[m]>
(which it doesn't do when calling the same function from the REPL)
<pjb>
this shouldn't be a problem: the uninterned symbols should be distinct anyways.
epony has joined #commonlisp
<AadVersteden[m]>
But then that is strange with 3.2.4.2.2 symbol similarity (though I have to read that within its context, I'm assuming things)
attila_lendvai_ has quit [Ping timeout: 272 seconds]
jeffrey has joined #commonlisp
scymtym_ has joined #commonlisp
scymtym has quit [Ping timeout: 256 seconds]
son0p has quit [Read error: Connection reset by peer]
Brucio-61 has quit [Ping timeout: 260 seconds]
Brucio-61 has joined #commonlisp
Ellenor is now known as Reinhilde
cage has quit [Remote host closed the connection]
nij- has quit [Ping timeout: 246 seconds]
cage has joined #commonlisp
rainthree3 has joined #commonlisp
Josh_2 has joined #commonlisp
pranavats has joined #commonlisp
pranavats has left #commonlisp [Error from remote client]
nij- has joined #commonlisp
<nij->
Has there been any attempt to create a CLOS-like system based on immutable data structure?
<beach>
I would think that would completely defeat how we work interactively.
<beach>
If you "redefine" a class because you are working on some application, it will then create a new class, and all the existing instances will have the old class as their class.
pranavats has joined #commonlisp
<beach>
And if you add a method to a generic function, a new generic function would be created.
<beach>
So then, if you had #'NAME, then it would still refer to the old generic function.
<beach>
nij-: How do you imagine yourself working in such an environment?
<nij->
One step at a time. On redefining a class, I think the (still imagenary) immutable CLOS can also "update" the objects by changing the API?
<nij->
For examples, suppose before update we have slot :A and :B.
<nij->
And suppose after the update we have :B and :C.
<nij->
We can change the accessor API so that :A no longer works, but :C does.
<nij->
Upon :C is called, simply return a representation of UNBOUND.
<Bike>
what if you redefine a class to have more or less slots.
<nij->
If we have :d, then expose an API as :c.
<nij->
If we have only :b at the end, then just remove the API for :a.
azimut has joined #commonlisp
<nij->
(Sigh I gotta go for another while again. Will be back soon.)
tyson2 has quit [Remote host closed the connection]
<beach>
Maybe it's just me, but I can't follow what this is supposed to mean. So I think I'll do something else instead.
pranavats has left #commonlisp [Error from remote client]
jeosol has quit [Quit: Client closed]
nij- has quit [Ping timeout: 264 seconds]
<Bike>
if you're changing the interface i don't see how it's not mutation, really
ec has joined #commonlisp
<Bike>
i do think it might make sense to treat redefining classes as an exceptional event and just have objects that are otherwise immutable, though
<beach>
Especially since CLOS-like would then be a lot less so, since in CLOS, classes are just standard objects as well.
Reinhilde has quit [Remote host closed the connection]
<Bike>
the other thing i've wondered about doing immutable objects wise is setting it up so that "redefining" a class of immutable objects actually just makes a new class. then all the old objects are still of the old class, and old methods apply to them and not to any objects you make of the new class. so you'd have to do more redefinitions than you do for normal class redefinitions, but it might still be
<Bike>
responsive enough
pranavats has joined #commonlisp
<nij->
Yeah.. I figure that's a problem now.
<nij->
Probably upon any redefinition of an immutable class, a coerce function should be given. (I'm still thinking about that.)
<nij->
Or we can just have the objects remembering the NAME of its class,
<nij->
and when we update a class (with NAME preserved),
<nij->
the object will point to the updated class naturally.
Ellenor has joined #commonlisp
<Bike>
that would put the actual contents of the object out of sync with the class.
<Bike>
if you then add a step to detect this situation and resolve it by changing the object, you're back to how clos already works.
<nij->
I don't have to change the object.
<nij->
Suppose an object has slot values of slots A B being 1 2. And the new class defines the slots B C D.
<Bike>
if you have a "coerce" function that makes an object of the new class based on an object of the old class, you're consing up a whole new object every time you call a function on an old object, which is suboptimal.
<nij->
(Bike yeah coerce isn't a good idea. I agree.)
<nij->
Suppose so, just raise a condition when the A slot to be accessed, and return UNBOUND when C D slots are accessed.
<Bike>
about that - i hope you realize that when you try to read the value of an unbound slot normally, you don't get a marker object back, you get an error
notzmv has joined #commonlisp
<nij->
Yes, as in CLOS.
<nij->
(Ah, I see what you mean. I shouldn't have said `return` UNBOUND.)
Cymew has joined #commonlisp
_cymew_ has quit [Ping timeout: 272 seconds]
Ellenor is now known as Reinhilde
Josh_2 has quit [Remote host closed the connection]
<Bike>
so, with that in mind, you're saying to signal a condition when A is to be accessed, and to signal a condition when C or D is accessed
<nij->
Yes. In the first case, signal a condition that indicates slot A is not available; in the second case signal a condition that indicates C and D slots are unbound.
aartaka has quit [Ping timeout: 246 seconds]
_cymew_ has joined #commonlisp
<Bike>
that would be slot-missing for the first one
<Bike>
anyway, in this system, you end up with an old object that has the new class, but which you can't use the new class's accessors on?
<nij->
Yes.
<Bike>
So something like (when (typep obj 'new-class) (c obj)) will signal an error if obj is an old object.
aartaka has joined #commonlisp
<Bike>
That seems pretty confusing. You're basically pretending an old object is a new object, but not well enough to actually do anything.
Cymew has quit [Ping timeout: 246 seconds]
<jackdaniel>
nij-: I'm curious why would you want for classes to be immutable?
<pjb>
nij-: note that the notion of object and that of immutability are contradictory. An object encapsulate state. The purpose of an object is to control the mutation to that state (and avoid mutation of the state of other objects). If you don't use mutation, then you don't need objects and classes.
<pjb>
(that's why haskell is not an OO programming language).
<pjb>
Of course, that doesn't prevent you to define immutable objects. But most of your objects in a program will be mutable.
domovod has joined #commonlisp
tyson2 has joined #commonlisp
notzmv has quit [Ping timeout: 265 seconds]
seletz has quit [Ping timeout: 248 seconds]
<pdietz>
Immutability is interesting when combined with non-EQ forms of equality. In CL we see this with numbers and characters.
<Bike>
pdietz: i like the characterization of equivalence functions in Kernel, where you have two: eq? is equivalence (eql, basically) and equal? is equivalence up to mutation
<Bike>
two objects are equal? if there's no way to tell them apart without using eq? or mutating one. so for example conses are equal? if their elements are equal and they have the same tree structure
seletz has quit [Ping timeout: 264 seconds]
terrorjack has quit [Ping timeout: 264 seconds]
terrorjack has joined #commonlisp
rainthree3 has quit [Ping timeout: 246 seconds]
seletz has joined #commonlisp
seletz has quit [Ping timeout: 260 seconds]
tyson2 has quit [Remote host closed the connection]
<nij->
Bike sorry to reply late. I mean the object doesn't point to the old class, but merely point to the NAME of the class. When the old class is updated to a newer one, the NAME doesn't change. So something like (when (typep obj 'new-class) (c obj)) shouldn't signal a condition.
<nij->
jackdaniel In general I think immutable data has their advantages (for some specific problems). But CLOS is also very nice and useful. I wonder if the idea of merging them together is even possible.
epony has quit [Quit: QUIT]
<Bike>
why wouldn't it signal a condition? you just said it would signal a condition if the c slot had been removed.
<nij->
Oh sorry I forgot the context. I thought you mean (typep object ..) would signal a condition. Ok, so in this case a condition will be signaled, because the slot C is unbound.
<nij->
"That seems pretty confusing." -- Why is it confusing?
<Bike>
because you can't tell what slots an object has based on its type.
<Bike>
and in fact there's no way to tell what slots an object has without trying to access them, i guess?
<Bike>
functions work differently on objects of the same class depending on whether they're old or not.
<nij->
You can. Resolve the NAME of the class that object points to. There you can get the list of slos.
leeb has joined #commonlisp
<Bike>
that would be the list of new slots.
<nij->
Yes, when the class is updated, we no longer care about the old slots.
<Bike>
we'd better care, because the old objects are still floating around, and they still have the old slots, leading to (c obj) signaling an error
jeffrey has quit [Ping timeout: 265 seconds]
<nij->
Why should we care if the old slots and their values are still floating around? For GC issue?
<Bike>
because they'll signal an error if you pass them to a function like i wrote.
<Bike>
you can have two completely different objects with completely different slots, and no way to tell if a function will work correctly on them other than trying it.
<Bike>
there's hardly any point to generic functions like that.
aartaka has quit [Ping timeout: 248 seconds]
<nij->
In CLOS, when updating a class and introducing new slots, the objects get more unbound slots too.
<nij->
And when the new slots are accessed, a condition is also signaled, right?
<Bike>
no, the object is updated.
<Bike>
that's the "if you then add a step to detect this situation and resolve it by changing the object" i mentioned
<puchacz>
hi, can I specialise a method on keyword? sbcl complains if I write this: (defmethod write-json-element :around ((element keyword) stream)
<Bike>
keyword is a type not a class, so no.
<Bike>
you can specialize on symbol and then check keywordp.
<puchacz>
Bike, good idea, thanks
aartaka has joined #commonlisp
scymtym has joined #commonlisp
<jackdaniel>
nij-: I mean - what particular advantages of having an 'immutable structure' would you derive if clos class had exhibited that property
<nij->
I can write code more easily for some problems, while maintaining the advantages of CLOS (ofc, that's based on the assumption that it's possible to merge both worlds).
<jackdaniel>
ok, so how will that make writing the code more easily for some problems? (i.e example)
* jackdaniel
tries to address his lack of imagination, not to persuade something
<beach>
jackdaniel: Isn't that the argument that is behind purely functional programming?
<nij->
Recently I have a class whose objects are "annotated strings". Basically, each instance has a STRING slot, and some extra things telling me some more information about the string.
<nij->
From a bunch of such annotated strings, I want to do some computations that use the extra information.
ttree has joined #commonlisp
<jackdaniel>
beach: yes, I can see what is good in immutable structures in general, I'm curious how that could be utilised when used with clos
puchacz has quit [Quit: Client closed]
<jackdaniel>
nij-: and how does immutability help you here? knowing that instances are immutable you can memoize results?
<nij->
Some computations involve manipulating the annotated strings. And sometimes I need to copy the slot values just to make sure that particular computation do not alter the outcome of anotehr computation.
<nij->
Is this example concrete enough @@?
<nij->
Basically, inputs are a bunch of "annotated strings". And the main functions call many computations on them.
<nij->
I don't want to keep track of if any computation has changed the content of the inputs.
<jackdaniel>
OK, but if it is your computation, then you may simply decide to not mutate inputs right?
<jackdaniel>
or you want to ensure, that some downstream user won't mutate your instance?
<nij->
Yes, I can do that. But then the code does something else that's not in my intention.
<nij->
I'm not saying mutable system cannot do this. It just makes the code appear in the form that I like more, and thus I feel easier to cope with codes like that.
<nij->
jackdaniel No, I'm not worrying about the downstream user.
puchacz has joined #commonlisp
<nij->
Mutable system can do that, and I can manually copy indeed. But that makes the code deviate from my ideal.
<nij->
Maybe my ideal is wrong. But if such immutable CLOS really exist, then why not?
<jackdaniel>
if the code is all yours, and you may decide that your code does not mutate instances, then how is this different from having an immutable instance? (from your ideal program perspective)
<nij->
But sometimes 'mutation' is the right thing to do. Currently, I avoid that by copying the object, mutate the new object, and continue.
<beach>
nij-: I am not convinced that immutability is as universally good as the functional-programming people claim. I think they might be right that it makes it easier to reason about programs and the correctness of those, but I think it comes at a huge cost in productivity. So that would be my take on "why not?".
epony has joined #commonlisp
<nij->
Yeah, I'm aware of some cost in productivity. Whether it's a *huge* cost depends on the problem and how the programmer thinks and designs.
<beach>
I agree that it depends on the problem (and the amount of money it is allowed to cost), but I am assuming expert programmers in both camps.
<nij->
I also agree that it is not as universally good.
<nij->
But sometimes I really want the code to resemble the algorithm (written in pseudo code or whatever), and don't care about if we should mutate or not.
<nij->
(Fortunately for the current project I don't have to write many copy methods.)
tyson2 has joined #commonlisp
<nij->
(beach jackdaniel I appreciate the conversation. I will come back later, and will be interested if you want to extend the conversation. Brb.)
rainthree has joined #commonlisp
<jackdaniel>
I think that various properties of the program are a result of the coding regime; the programming language may nudge you to do something in a particular way but that's all; I don't see a reason why someone couldn't write (for example) functional programs in assembly or oop programs in C
<nij->
You can, but most likely you'd also want to implement immutable data structures in that case.
<nij->
Without immutable data structures it's hard to write pure functions.
<nij->
You can do lots of ad hoc copying, but that's likely boilerplate code, and also it would mostly be less efficient.
<jackdaniel>
why do you need to copy the element if you are not mutating it anywhere?
<Catie>
cl-ppcre has an s-expression regexp syntax if I recall correctly
<nij->
jackdaniel Well, in some algorithm, it is natural to derive a new object from an old object.
son0p has joined #commonlisp
<nij->
How would you not mutate nor copy them in CL?
<jackdaniel>
OK, now that makes more sense. and how, assuming that #<foo :string "foo" :annotation "bar"> is immutable, would you derive the object?
<jackdaniel>
if it is only about changing the value of individual slots in the dynamic scope of the computation (without modifying it elsewhere), then you could use dynamically scoped slots from contextl
epony has quit [Ping timeout: 268 seconds]
<nij->
(iset (slotval :annotation obj) "bar2")
<nij->
This imaginery iset will create a new object and assigns it to the variable OBJ.
<jackdaniel>
I see, now I have a better picture what you want; thanks
<nij->
Thanks :)
<nij->
Catie I see that cl-ppcre:parse-string can parse regex to expressive lists.
<nij->
The converse of that is what I'm looking for..
<Bike>
no, ppcre also accepts the s expression syntax
<Catie>
cl-ppcre:create-scanner can take a "parse tree", which is an S-expression
<Catie>
You want to convert it into its equivalent string?
<Bike>
by "regex", you mean like a perl type regex string? i don't think it does a reverse parse
<nij->
Yeah
<nij->
regex -> parse-tree -> scanner -> regex
<nij->
The last arrow seems to be missing.
jeosol has joined #commonlisp
Josh_2 has joined #commonlisp
jes2 has joined #commonlisp
theBlack1ragon has joined #commonlisp
<nij->
(The first arrow is #'parse-string, while the second arrow is #'create-scanner.)
<Bike>
well, sure. cl-ppcre is an implementation of regexes. it assumes that you want to give it a regex for scanning, not to just make a string to throw at perl or something instead.
greaser|q has joined #commonlisp
jfb4_ has joined #commonlisp
<nij->
Yep, hopefully the cycle is completed somewhere else.. I think it will be helpful if somehow Lisp needs to communicate with other programs - then using regex is better as it is more universal.
ecocode[m]1 has joined #commonlisp
<Josh_2>
Hey
<nij->
(Ok, gotta go! I appreciate the conversations and I will be back around 1 hour if anyone is interested in talking more about my stupid idea.)
<nij->
o/
<Josh_2>
Is there a generic function overloading library?
<nij->
generic-cl
sunarch_ has joined #commonlisp
<Josh_2>
I dont want to change half the standard library into generic functions
jkamat has joined #commonlisp
<Bike>
what is a generic function overloading library?
<Josh_2>
Id like to have generics that accept variable number of arguments
<nij->
Hack its package.lisp.
<nij->
Oh that.
<Josh_2>
I dont remember if filtered functions have that ability :thinking:
jes1 has quit [Ping timeout: 252 seconds]
sunarch has quit [Ping timeout: 252 seconds]
sunarch_ is now known as sunarch
xaltsc_ has joined #commonlisp
<Josh_2>
Nope dont think so
theBlackDragon has quit [Ping timeout: 252 seconds]
ym has quit [Ping timeout: 252 seconds]
GreaseMonkey has quit [Ping timeout: 252 seconds]
ecocode[m] has quit [Ping timeout: 252 seconds]
jfb4 has quit [Ping timeout: 252 seconds]
ixelp has quit [Ping timeout: 252 seconds]
jgkamat has quit [Ping timeout: 252 seconds]
xaltsc has quit [Ping timeout: 252 seconds]
pok has quit [Ping timeout: 252 seconds]
jaimelm has quit [Remote host closed the connection]
leo_song has quit [Ping timeout: 252 seconds]
jfb4_ is now known as jfb4
leo_song has joined #commonlisp
<yitzi>
Josh_2: Are you specializing on the variable number of arguments?
<Josh_2>
Yes but also on the class of the arguments
<Catie>
I have a vague recollection of a library that will do arity and type overloading, similar to how C++ does it, but I cannot for the life of me find it
tyson2 has quit [Remote host closed the connection]
ym has joined #commonlisp
domovod has quit [Quit: WeeChat 3.7.1]
seletz has joined #commonlisp
pdietz has quit [Quit: Client closed]
seletz has quit [Ping timeout: 252 seconds]
MajorBiscuit has quit [Ping timeout: 256 seconds]
pdietz has joined #commonlisp
xantoz has quit [Read error: Connection reset by peer]
_cymew_ has quit [Ping timeout: 272 seconds]
<pve>
Josh_2: I mean you can play around with it sure, but don't like "use it" use it
<Josh_2>
Right well its a "use it" use it application :joy:
<pve>
maybe learn from its mistakes and make a better one
xantoz has joined #commonlisp
varjag has quit [Ping timeout: 252 seconds]
<pve>
I guess the simplest thing you could do is just adopt a naming scheme for your generic functions, like foo-bar/2 where 2 is the arity. You know, just to get a feel for it. It has the advantage that jump-to-definition etc will work as expected.
<pve>
I think there's a language that actually uses that convention, was it Erlang?
<Catie>
Sometimes the C standard library will append the number of arguments to the end of a maddeningly short function name
akoana has joined #commonlisp
<pve>
Josh_2: And if you're so inclined, you can call the first argument "self" :)
<Bike>
/# is prolog, i think.
<pve>
Josh_2: or if you're into smalltalk, you could instead have a naming scheme like (defgeneric copy-to/on-error (self target handler) ...)
<Josh_2>
Thanks for the suggestions
aartaka has quit [Ping timeout: 256 seconds]
<Josh_2>
Does a defmethod (setf ..) () take the class or new-val first in the arg list?
<Josh_2>
val then class
nij- has joined #commonlisp
ttree has quit [Read error: Connection reset by peer]
random-nick has quit [Ping timeout: 260 seconds]
<Bike>
Josh_2: new-val first.
<Josh_2>
Thanks. Its not often that I write setf methods
ardon` has joined #commonlisp
ardon` has quit [Remote host closed the connection]
varjag has joined #commonlisp
<AadVersteden[m]>
pjb, phoe: it fails when the type is being used in the verification of an ftype, not when using typep. Not sure how to formalize this thought. I can publish a repository with two approaches yielding the same results.
random-nick has joined #commonlisp
<pjb>
AadVersteden[m]: verifying ftypes has other limitations… here for typep https://termbin.com/oegfe
tyson2 has joined #commonlisp
<AadVersteden[m]>
pjb: Yeah, but it crashes by having this as an ftype, which is why it's failing. I know that SBCL will not be able to statically check the satisfies constraint.
<AadVersteden[m]>
pjb: https://termbin.com/libcr defines functions that I cannot evaluate without error.
phoe has quit [Ping timeout: 260 seconds]
cercopith has quit [Remote host closed the connection]
cercopith has joined #commonlisp
jeosol has quit [Quit: Client closed]
thuna` has quit [Remote host closed the connection]
<AadVersteden[m]>
hmmm, perhaps it might be a bug then?
<AadVersteden[m]>
pjb: I should add assertions to be certain, though I think the SBCL manual says it executes them as assertions depending on the safety level.
seletz has quit [Ping timeout: 272 seconds]
v88m has joined #commonlisp
Brucio-61 has quit [Read error: Connection reset by peer]
<dbotton>
Is there a reason I would want to use defsetf instead of (defun abc() ...) (defun (setf abc)(val) ...) ?
<AadVersteden[m]>
or were you hinting at something else?
Brucio-61 has joined #commonlisp
<jackdaniel>
dbotton: multiple values is one
attila_lendvai_ has joined #commonlisp
<dbotton>
how so?
<jackdaniel>
generally some non-obvious evaluation rules too
<dbotton>
not sure I understand as I can return VALUES?
<jackdaniel>
I'm not using defsetf often, so I may botch the syntax, but (defsetf foo (value-form) (store) `(setf store (multiple-value-list ,value-form)))
<jackdaniel>
,store
<ixelp>
store ERROR: Unbound variable: STORE
<jackdaniel>
or the other way around, (setf ,value-form (multiple-value-list ,store))
<jackdaniel>
also if you want to associate already existing setter function with a reader, (defsetf car rplaca)
greaser|q has joined #commonlisp
greaser|q has quit [Changing host]
greaser|q is now known as GreaseMonkey
<dbotton>
ok, getting the multiple values but I will sit on it more
<dbotton>
what would using foo look like?
<jackdaniel>
(setf (foo woah) (values 1 2 3)) I suppose
<dbotton>
I frequently write things like - (defmethod (setf style) (value (obj clog-element) style-name) ..)
<dbotton>
why would I want to do that?
<dbotton>
When I can use a defun/defmethod (setf xxx) (arg1 arg2 arg3)
<dbotton>
Even if I did want it, why not just pass it as a single argument?
<jackdaniel>
beats me, I don't know what you may want it for
<Bike>
cos you'd have to cons a list or something for that single argument.
<jackdaniel>
as of multiple arguments, the standard does not guarantee that a setf function will accept multiple arguments
<jackdaniel>
some implementation do that as a reasonable extension though
<dbotton>
are there any that do not currently? it works on sbcl and ecl I know
<jackdaniel>
last time I've checked these were the only two implementations
<jackdaniel>
but that was long time ago
<jackdaniel>
(and I've checked that while implementing this extension for ecl)
<Bike>
wait, "accept multiple arguments" in what sense?
<_death>
how does that extension work?
<jackdaniel>
(defun (setf xxx) (a b c place) …) (setf (xxx place) (values a b c))
<jackdaniel>
afair the standard requires only a single value to work
<dbotton>
I use it all over clog - so for (setf (stlye clog-obj "color") :red)
<jackdaniel>
but I may confuse things
<Bike>
huhh. i am a little surprised that's workable
<dbotton>
the values thing I do not use
<_death>
jackdaniel: in standard CL that means (setf (xxx b c place) a) .. are you saying the last form may work as an extension?
<dbotton>
is my use the extension or jackdaniel's is?
<pjb>
dbotton: sometimes you already have both a reader and a writer functions, so defsetf let you bind them into a place.
<jackdaniel>
_death: I'm talking from a memory about things I'm not usually using, so I might have confused things
<dbotton>
(cltl2e says values is an extension)
<dbotton>
pjb that use I am aware (ie is a convenience)
<dbotton>
I am looking for any thing that would be a real use beyond that
<dbotton>
A bit confused now as to if the use I showed of a function-name of (setf x) for defun or defmethod is an extension or the normal expected use
rainthree has quit [Remote host closed the connection]
rainthree has joined #commonlisp
<dbotton>
the (values x x x) version is cltl2e mentions it as a potential extension - and bike said to avoid a cons exists
<jackdaniel>
sorry, I've confused things
<jackdaniel>
I've meant (setf (values a b) (values 1 2))
<jackdaniel>
what is not related to functions like (setf foo)
<jackdaniel>
fwiw for multiple value "setf function" clim has defgeneric* and defmethod*
cage has quit [Quit: rcirc on GNU Emacs 27.1]
<_death>
to be able to say (setf (foo) (values 1 2)) and have foo receive both values, you need defsetf/define-setf-expander or use a macro
n1to has joined #commonlisp
doyougnu has quit [Ping timeout: 272 seconds]
<dbotton>
_death not sure I understand. I can do (defun (setf foo) (obj val) (print val) obj) and then say (setf (foo x) (values 1 10)) - so I can pass a values object in a single argument
<pjb>
this assigns only 1.
<_death>
I guess the confusion comes from mcclim's "abuse", where it defines say (defgeneric (setf cursor-position-star) (x y cursor)) and has setf expander call it
<jackdaniel>
_death: that may be it, and the fact that I've implemented earlier (setf (values place1 place2) (values 1 2)) too
rainthree has quit [Ping timeout: 256 seconds]
<_death>
in actuality, that generic function need not use a name like (setf cursor-position-star)
<jackdaniel>
(and (shiftf (values a b) (values c d) (values 1 2))
<dbotton>
if you use the macro creates all sorts of issues, I got rid of them through out clog
<dbotton>
from methods
<_death>
jackdaniel: note that VALUES already has a setf expander, per CL
jeffrey has joined #commonlisp
<jackdaniel>
hm, what is the purpose of the multiple-value-setq then?
<_death>
jackdaniel: analogous to setq
<jackdaniel>
then it could have been a bug in ecl perhaps
<jackdaniel>
(that it was not implemented)
<_death>
interesting.. I don't remember ecl having trouble with it.. is it an old bug?
<jackdaniel>
I've checked in the log and that's how I've confirmed that I have remembered wrong, the fix has 7y :)
<_death>
ok :)
Inline has quit [Quit: Leaving]
aartaka has joined #commonlisp
jmdaemon has joined #commonlisp
n1to has quit [Quit: Leaving]
tibfulv has quit [Remote host closed the connection]
tibfulv has joined #commonlisp
<Josh_2>
otherwise or t in case? :thinking:
<Josh_2>
I like otherwise
knusbaum has quit [Ping timeout: 260 seconds]
knusbaum has joined #commonlisp
son0p has quit [Ping timeout: 248 seconds]
puchacz has joined #commonlisp
<_death>
jackdaniel: so that explains why ecl has m-v-setq as a special operator ;)
nij- has left #commonlisp [Using Circe, the loveliest of all IRC clients]
triffid has joined #commonlisp
aartaka has quit [Ping timeout: 265 seconds]
<_death>
maybe its macroexpansion can be improved now
<AadVersteden[m]>
pjb worked around it by creating real symbols, that works too with sbcl.
attila_lendvai_ has quit [Ping timeout: 252 seconds]
v88m has quit [Ping timeout: 252 seconds]
<pjb>
AadVersteden[m]: perhaps there's a bug in sbcl?
MajorBiscuit has joined #commonlisp
scymtym_ has quit [Ping timeout: 252 seconds]
scymtym has quit [Ping timeout: 256 seconds]
Brucio-61 has quit [Ping timeout: 260 seconds]
puchacz has quit [Quit: Client closed]
seletz has joined #commonlisp
shka has quit [Ping timeout: 252 seconds]
<phoe>
AadVersteden[m]: do you have a minimal example then?
<phoe>
s/then/yet/
seletz has quit [Ping timeout: 272 seconds]
waleee has joined #commonlisp
scymtym_ has joined #commonlisp
scymtym has joined #commonlisp
Brucio-61 has joined #commonlisp
Lycurgus has joined #commonlisp
MajorBiscuit has quit [Ping timeout: 246 seconds]
<AadVersteden[m]>
yeah, higher up. will paste again tomorrow
mingus has quit [Quit: mingus]
<phoe>
oh right, I must have disconnected
<phoe>
I can see it in the channel logs
szkl has joined #commonlisp
<phoe>
AadVersteden[m]: you have (PROGN (LET (...) (DEFTYPE ...))) as the expansion of WITH-SUMS-TO
<phoe>
this causes DEFTYPE to not be toplevel
<phoe>
which causes type TEN-LIST to be undefined at compilation time
<phoe>
is this the problem you are having, or...?
<AadVersteden[m]>
no, it's complaining it can't find the function bound to the gensym, but only when executing typechecks for calling these functions. typep works.
<phoe>
oooh, I can reproduce this
<AadVersteden[m]>
everything works with interned symbols (my current workaround)
tetsuo91 has quit [Quit: WeeChat 2.3]
rgherdt has quit [Remote host closed the connection]